API error codes

Every error the API returns, with its HTTP status and code and what to do about it. Errors use the OpenAI format.

Errors

Errors use the OpenAI format: {"error": {"message", "type", "code"}}.

HTTPcode
400invalid_requestThe body is not valid JSON, or a field is missing or wrong. The message says which.
400wrong_endpointThe model is of another kind: chat models use /chat/completions, image models /images/generations, video models /videos.
400size_not_available / format_not_available / too_many_imagesThe image model does not make this size or file format, or was sent more input images than it takes. The message gives what it accepts.
400resolution_not_availableThe video model is not sold at this resolution.
400video_not_readyThe video is not completed yet; keep polling GET /videos/{id}.
400not_a_draft / draft_not_ready / draft_wrong_model / draft_expireddraft_id must be a completed draft of the same model, made within 7 days.
400user_requiredRelay accounts only: every chat request must carry a user field.
401invalid_api_keyMissing, wrong or revoked API key.
402insufficient_balance / key_spend_capTop up your balance, or raise the key’s daily cap.
403account_inactiveThe account is suspended.
403ip_not_allowedThe key has an IP whitelist and the request came from another address.
404model_not_foundUnknown model id. See GET /models.
404video_not_found / draft_not_foundNo such video or draft on your account.
404video_expired / last_frame_expired / image_expired / no_last_frameThe file is no longer kept, or no last frame was asked for. Image links last 1 hour. Video links last a week; a video we could not copy to our storage is served from the model provider for 24 hours only.
404not_foundNo such path. See Endpoints.
405method_not_allowedWrong HTTP method for this path, for example GET on /chat/completions.
413request_too_largeThe request body is too large.
429rate_limit_exceeded / concurrency_limit / model_at_capacitySlow down and retry after the Retry-After header.
429model_rate_limit_exceeded / model_concurrency_limitYour account reached its limit for this one model. Other models still work; retry after the Retry-After header.
429upstream_rate_limitedThe model itself is at its rate limit. Retry in a few seconds; you were not charged.
429too_many_failed_requestsThe key sent too many failing requests in a row and is paused for the time in Retry-After. Fix the error you were getting, then retry.
500internal_errorSomething failed on our side. Retry, and quote the request_id to support if it repeats.
502upstream_errorThe model provider failed. Safe to retry; you were not charged.
503upstream_unavailable / billing_unavailable / config_unavailable / model_not_priced / gateway_drainingTemporary. Retry with backoff.
504upstream_errorThe model did not answer in time. Safe to retry; you were not charged.