Skip to content

Reference

Errors

The error envelopes, status codes and error codes the API returns, and how to fix each.

Errors from the endpoints that reach a model, and from Key, carry x-request-id. Quote it when you contact support. A request that Deference forwarded to a provider appears in Activity under that id, including one the provider failed. A request that Deference refused before forwarding it, with a 400, 401, 402, 404, 413, 429 or 503 of its own, does not appear there. GET /v1/models/{id} answers an unknown model with a 404 that carries no request id.

OpenAI envelope

Chat completions, Responses, Embeddings, Images, Models and Key return this shape.

{
  "error": {
    "message": "This account has no credit left. Add credit in the dashboard to continue.",
    "type": "insufficient_credit",
    "code": "insufficient_credit",
    "param": null
  }
}

Anthropic envelope

Messages returns this shape, which Claude Code parses.

{
  "type": "error",
  "error": {
    "type": "billing_error",
    "message": "This account has no credit left. Add credit in the dashboard to continue."
  },
  "request_id": "req_01K7Z4F2XQ"
}

Status and type

StatusOpenAI typeAnthropic type
400invalid_request_errorinvalid_request_error
401authentication_errorauthentication_error
402insufficient_creditbilling_error
403permission_errorpermission_error
404invalid_request_errornot_found_error
413invalid_request_errorrequest_too_large
429rate_limit_errorrate_limit_error
502, 504api_errorapi_error
503api_erroroverloaded_error

Codes

Codes are in error.code in the OpenAI envelope. The Anthropic envelope carries the type only.

StatusCodeCauseFix
400invalid_jsonThe body is not valid JSONSend a JSON object
400missing_modelThe request has no modelAdd a model id
400invalid_parameterImages: n is not a whole number from 1 to 10Send a valid n
400unsupported_parameterThe body sets models, route or provider, a plugins entry that adds a fee, X search or audio input, or sends a file to a model without file input and no free parserName one model and drop those fields. For files, add the cloudflare-ai parser or pick a model with file input
400unsupported_modelThe model bills per search or per song, such as perplexity/sonar-deep-research and the Lyria modelsUse another model
401missing_api_keyNo key was sentSend Authorization: Bearer sk-df-... or x-api-key
401invalid_api_keyThe key is not recognizedCopy the key again, or create a new one
401api_key_disabledThe key is disabledEnable it in API keys, or use another key
401api_key_expiredThe key passed its expiryCreate a new key
402insufficient_creditThe account has no available credit, or less than the request's hold. A file, image or video given as a URL is held at the model's whole context windowAdd credit, lower max_tokens, or send fewer URL inputs
402key_limit_reachedThe key hit its credit limit, or has less left than the request's holdRaise the limit, lower max_tokens or use another key
402free_credit_not_eligibleThe account has only free credit, and this model or request does not qualifyUse an open-weight text model, set a lower max_tokens, or add credit
404model_not_foundThe model id is not in the catalogList models and pick a current id
413request_too_largeThe body is over 32 MB, or 64 MB on ImagesSend a smaller body
429rate_limitedToo many requests in a minuteWait for retry-after seconds
429too_many_concurrent_requests8 requests are already running on the keyRetry when one finishes
502upstream_errorThe model provider returned an errorRetry the request
503service_unavailableInference is temporarily unavailableRetry shortly
504upstream_timeoutThe provider did not answer in time: 15 minutes for a call that is not streamed, 120 seconds for Images. The call may still have run, so the credit held for it is chargedRetry, or stream the request

free_credit_not_eligible explains itself: its message lists what free credit pays for and suggests max_tokens. See Free credit.

Provider errors

Errors that describe your request pass through from the provider: 400, 403, 404, 408, 413, 422 and 429. Anthropic-format bodies are returned unchanged. A provider 401 or 402, which concerns Deference's own upstream account, returns 503. Any other provider failure returns 502. Both carry your request id and never reveal the upstream account.

Failures after a stream starts

A stream that fails midway still returns HTTP 200, and the error arrives as an event in the stream. Activity marks that request failed. A failed request is charged only for what the provider reports. See Streaming events.

Retry

Retry 429, 502, 503 and 504 with backoff, and honor retry-after when present. It is a whole number of seconds. Do not retry 400, 401, 402, 404 or 413 until you fix the cause. See Rate limits.