Documentation

Errors

Every status and code the API returns.

Error shape

Errors match OpenAI's shape. Branch on code — it is stable, while message is written for a human and may change.

JSON
1{2  "error": {3    "message": "Insufficient credits. Add credits to keep using the API.",4    "type": "insufficient_quota",5    "code": "insufficient_credits"6  }7}

Status and codes

StatusCodeMeaning
400missing_model, missing_messagesA required field is absent or empty.
400too_many_messages, too_many_tools, too_many_images, too_many_audio, too_many_videoOver one of the size limits.
400image_too_large, audio_too_large, video_too_largeA single file is over 5 MB.
400unsupported_image_url, unsupported_audio_url, unsupported_video_urlMedia was sent as a link. Send base64 instead.
400unsupported_image_type, unsupported_audio_format, unsupported_video_typeThat container or codec is not one we pass through.
400images_not_supported, audio_not_supported, video_not_supportedThat model does not read that kind of input.
400upstream_validationThe model rejected the request — usually the context window.
401missing_api_key, invalid_api_key, key_disabled, key_expiredThe key is absent, unknown, disabled or expired.
402insufficient_credits, key_limit_reached, workspace_budget_reached, guardrail_limit_reachedA spending limit was reached. The message names which.
403model_not_allowed, wrong_key_kindA guardrail blocks that model, or a management key tried to call one.
404model_not_found, preset_not_foundNo such model or preset.
413request_too_largeThe body is over 8 MB.
429rate_limit_exceededThe key's per-minute allowance is spent. Wait Retry-After seconds.
429upstream_rate_limitedThe model is saturated. Back off and retry.
499cancelledYou disconnected before the reply finished.
500internal_errorOur fault. Safe to retry.
502upstream_errorThe model returned something we could not interpret.
503model_unavailable, upstream_unavailableWe list the model but cannot serve it right now.
504upstream_timeoutThe model took too long.

Retrying

Retry on 429, 500, 502, 503 and 504, with exponential backoff and a jitter. Everything in the 400s will fail the same way until you change the request.

A retry is a new, separately billed request

There are no idempotency keys yet, so a retry that succeeds after a timeout may mean you paid for both attempts. Prefer streaming for long generations, where a partial result is visible rather than lost.