> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> Every 4xx and 5xx status we return, with an example body and what to do about it.

**Branch on the HTTP status code, not the body.** The status is what the OpenAI SDKs map to exception classes, and it's stable across every layer of our stack.

Where a human-readable explanation exists it's safe to surface in your UI, but don't assume it's there. It's `error.message` on the envelope (including chat gate rejections, which also keep their structured payload under `error.provider_specific_fields`), top-level `message` on the flat shape, `detail` on the bare shape and on one flat body — and a few carry no explanation at all. Fall back to the status plus the `error` string code.

Which shape you get depends on **which layer turned you away**, so don't assume `error` is an object — or that it's present at all. Endpoints we serve directly (`/v1/images`, `/v1/videos`, `/v1/audio`, and parts of `/v1/flex/*`) answer in either the OpenAI envelope or a flatter shape where `error` is a string code with the context beside it. Chat and completions run through our model router, which always answers in the envelope. And the 502s on `GET /v1/flex/key` and `GET /v1/models` return a bare `detail` string with no `error` key:

```json OpenAI envelope theme={null}
{
  "error": {
    "message": "…",
    "type": "invalid_request_error",
    "param": "size",
    "code": null
  }
}
```

```json Flat shape theme={null}
{
  "error": "model_not_supported",
  "message": "Model 'NoSuchModel-XYZ' is not available on this endpoint.",
  "supported_models": ["FLUX.1-schnell", "FLUX.2-dev", "stable-diffusion-3.5-large"]
}
```

```json Gate rejection (chat) theme={null}
{
  "error": {
    "message": "Model id not recognized. …",
    "type": "not_found_error",
    "param": null,
    "code": "unknown_model",
    "provider_specific_fields": {
      "error": "unknown_model",
      "model": "Llama-3.3-70B-Instruc",
      "message": "Model id not recognized. …",
      "did_you_mean": ["Llama-3.3-70B-Instruct"]
    }
  }
}
```

```json Bare detail theme={null}
{
  "detail": "upstream gateway unavailable"
}
```

When a chat request is turned away by one of our pre-flight gates — unknown model, a model this endpoint doesn't serve, insufficient balance, region not served, business verification required — the envelope carries the gate's sentence in `error.message` and its code in `error.code` (`unknown_model`, `model_not_supported`, `insufficient_balance`, `region_not_served`, `business_verification_required`), with `type` and `param` as proper JSON values. The gate's structured payload (`did_you_mean`, `suggested_model`, `max_usage_cost_usd`, `key_remaining_usd`, `region`, …) stays under `error.provider_specific_fields`, where earlier releases put everything, so code written against that keeps working. A gate with no sentence (the balance gate) repeats its code as `error.message`; render its payload fields instead.

On the model-router endpoints (chat, completions, embeddings, responses and videos), error messages never carry our internals: no exception class names, file paths, engine names or hostnames. When a model backend's own message can't be shown without them, you get a generic message for the status instead. A 5xx, or an error inside a stream, carries its own message only when its `code` is one we document on this page; any other server-side failure gets the generic message. This check fails closed: text that merely looks internal is treated as internal. A message that mentions a name ending in `.local`, `.internal` or a similar private suffix (for example `file.local`), or a private, loopback, link-local or unique-local IP address (for example `10.0.0.5`, `fd00::2` or a bare `::`), is replaced by the generic message too, even when it is harmless.

We're converging these shapes. Until then, treat the status as the contract and every field in the body as optional — read `error` defensively (object, string, or absent), and when it's an object, check `provider_specific_fields` before concluding there's no detail.

## Identifying a request

Every response from the model-router endpoints (chat, completions, embeddings and responses), errors included, carries an `x-litellm-call-id` header. Quote it when you contact support.

It's also the `request_id` for `GET /v1/flex/usage/request/{request_id}`, and it's set on our own 429, 503 and 504 responses too. When the gateway answers one of those itself, the request has no usage record and isn't billed, so the lookup returns `404` for its id. A `504` raised as the request was being sent to a model is recorded as a failed request and does resolve.

The rate-limit 429 described under [The other 429](#the-other-429-a-flood-limit-at-the-edge) is sent by our edge proxy before a request reaches the gateway, so it carries no request id.

## What we return

The `Where` column matters: `code` is **not** consistent across endpoint families,
so switch on the status and treat `code` as a debugging aid, not a contract.

| Status | `type` | `code` | Where | When |
| - | - | - | - | - |
| 400 | `invalid_request_error` | `null`, or a stable code where one exists | chat | Malformed body, bad field value, prompt over the context window, unfetchable `image_url`, an image sent to a model that doesn't accept images |
| 400 | `invalid_request_error` | `string_too_long` | audio | Text-to-speech `input` over the model's character limit |
| 400 | `invalid_request_error` | `invalid_request_body` | media | Body isn't valid JSON, or the wrong content type |
| 400 | *flat* `invalid_request` | — | video | Async job rejected at submission (e.g. unsupported dimensions) |
| 400 | *flat* `content_policy_violation` | — | video | The prompt was refused by our content safety check. No job is created and nothing is charged; change the prompt rather than retrying it |
| 400 | *flat* `model_not_supported` | — | media | Model isn't valid for the endpoint you called |
| 400 | `invalid_request_error` | `model_not_supported` | chat | A model on `GET /v1/models` that this endpoint doesn't serve, such as a video, image or audio model sent to chat completions. The message names its input and output modalities |
| 400 | *flat* `unsupported_audio` | — | audio | Uploaded audio couldn't be decoded |
| 401 | `invalid_request_error` | `missing_api_key` | media | No `Authorization` header |
| 401 | `invalid_request_error` | `invalid_api_key` | media | Key malformed, unknown, revoked, or expired |
| 401 | `invalid_request_error` | `missing_authorization` | flex | No `Authorization` header |
| 401 | `invalid_request_error` | `malformed_authorization` | flex | Header present but not `Bearer sk-…` |
| 401 | `authentication_error` | `invalid_api_key` | flex | Key unknown, revoked, or expired |
| 401 | `auth` | *none* | `/v1/models` | Missing or invalid key |
| 402 | `insufficient_quota` | `insufficient_quota` | media | Out of credit, monthly spend cap reached, or account on hold |
| 402 | `insufficient_quota` | `insufficient_quota` | chat, `/v1/responses`, `/v1/embeddings`, `/v1/rerank` | Out of credit, a spend cap or spend limit reached, or account on hold |
| 402 | `insufficient_quota` | `insufficient_balance` | chat | Worst-case request cost exceeds the remaining balance — payload under `provider_specific_fields` |
| 403 | `invalid_request_error` | `region_not_served` | media | Your org's data region isn't served by this endpoint |
| 403 | `permission_error` | `region_not_served` | chat | The same region gate on the chat plane — payload under `provider_specific_fields` |
| 403 | `permission_error` | `business_verification_required` | chat, media | Your business organization has not completed business verification for this workspace's region, so it cannot use the inference API yet. Adding a payment method and creating API keys are not affected. Top-ups open once verification is approved. Answered the same on every chat endpoint — payload (`region`) under `provider_specific_fields` on chat |
| 403 | `auth` | *none* | `/v1/models` | Key is blocked |
| 404 | `invalid_request_error` | `model_not_found` | media | Media model not currently available |
| 404 | — | `model_deactivated` | chat | Model not currently available (stopped, scaled to zero, or its cluster is down) |
| 404 | *flat* `pricing_unavailable` | — | media | We couldn't price the request, so we declined to run it |
| 404 | `not_found_error` | `unknown_model` | chat | Model id we don't recognize — payload under `provider_specific_fields` |
| 404 | `invalid_request_error` | `request_not_found` | flex | Unknown request id in a usage lookup |
| 404 | `invalid_request_error` | `endpoint_not_supported` | messages | The Anthropic Messages API (`/v1/messages`) isn't supported — use `/v1/chat/completions` or `/v1/responses` |
| 410 | *flat* `job_already_retrieved` | — | video | This completed clip was already downloaded; video results are one-shot |
| 410 | *flat* `job_expired` | — | video | The one-hour pickup window elapsed, or the job is no longer available |
| 413 | *flat* `payload_too_large` | — | audio | Speech-to-text upload over the size limit |
| 422 | `invalid_request_error` | `invalid_request_body` | media | A field is missing or semantically invalid — `param` names it |
| 422 | *flat* `invalid_request` | — | audio | Endpoint needs `multipart/form-data`; the explanation is in `detail`, not `message` |
| 429 | `rate_limit_error` | `rate_limit_exceeded` | chat, media | Over your key's requests-per-minute ceiling |
| 429 | `rate_limit` | *none* | `/v1/models` | Over the discovery endpoint's own throttle |
| 429 | `capacity_error` | `gateway_capacity_exhausted` | chat | Your account is moving between serving planes, or no engine arm can take the request right now; retry after `Retry-After` |
| 500 | `api_error` on chat, *(varies)* elsewhere | `null` | all | Unexpected failure in our gateway or a model backend |
| 502 | *bare* `detail` | — | `/v1/flex/key`, `/v1/models` | An upstream call inside our gateway was unreachable, rejected, or returned an unusable body |
| 503 | `api_error` | `service_unavailable` | media | Key verification temporarily unavailable |
| 503 | `api_error` | `auth_service_unavailable` | flex | Key verification temporarily unavailable |
| 503 | *nested* `usage_capture_unavailable` | — | chat, media | Usage recording is temporarily unavailable; the request was refused before inference. Retry shortly |
| 503 | `service_unavailable_error` | `balance_unavailable` | chat | Your balance couldn't be checked right now (not a sign you're out of credit); retry after `Retry-After` |
| 503 | *flat* `backend_unavailable` | — | media | A media backend is temporarily unreachable |
| 503 | *flat* `safety_check_unavailable` | — | video | The content safety check couldn't run, so the job was refused rather than generated unchecked. Nothing was charged; retry shortly |
| 503 | *flat* `transcode_overloaded` | — | audio | Audio processing is saturated; retry shortly |
| 503 | *nested* `global_plane_unavailable` | — | portal | An internal control-plane dependency was briefly unreachable; retry shortly |
| 503 | *nested* `stripe_tenant_not_configured` | — | portal | Billing is not fully configured for your account's region; we refuse rather than charge the wrong account |
| 503 | *nested* `spend_rollup_unavailable` | — | portal | A spend figure couldn't be read right now (the usage summary behind it is unavailable); retry shortly, nothing was changed |
| 503 | *nested* `relief_region_unknown` | — | portal | A tax-relief decision for your billing account couldn't be made because one of our own services is mid-upgrade; nothing was charged, retry shortly |
| 504 | `timeout_error` | `request_deadline_exceeded` | chat | The request ran out of time before any of the answer was sent; a request without `stream: true` gets about 3 minutes |
| 504 | `gateway_timeout` | `usage_timeout` | flex | A usage query took too long |

`Where` reads as: **chat** = `/v1/chat/completions`, `/v1/completions`; **media** =
`/v1/images`, `/v1/videos`, `/v1/audio`, with **audio** and **video** called out where
a code belongs to only one of them; **flex** = `/v1/flex/*`; **messages** = `/v1/messages`, which we don't serve; **portal** = the
dashboard's `/api/*` management routes, rather than the Inference API.

A `code` of `null` matches OpenAI, which reserves non-null codes for a narrow set. The 500 row is the exception: we don't author those bodies, so treat its `type` and `code` as unstable.

> [!NOTE]
>
> The chat 402 and 403 rows share their envelope builder with the chat 404, which is verified live; provoking them needs an org that is out of credit or pinned to an unserved region.

## 400 — Bad request

Malformed body, or a field value we can't serve. `param` names the offending field when we can identify one.

```json theme={null}
{
  "error": {
    "message": "'size' must be a WxH string with each dimension in [64, 2048] (e.g. '1024x1024').",
    "type": "invalid_request_error",
    "param": "size",
    "code": null
  }
}
```

A 400 is deterministic — retrying the same request fails the same way. Change it or fail the call.

### Prompt longer than the context window

Refused before any tokens are generated, so you aren't billed. Every such refusal is a 400 with `code: "context_length_exceeded"`, so you can branch on the code rather than on the wording. `param` names the field that carries the prompt: `"messages"` on chat completions, `"input"` on `/v1/responses` and `/v1/embeddings`, and `"prompt"` on `/v1/completions`:

```json theme={null}
{
  "error": {
    "message": "This model's maximum context length is 131072 tokens. Reduce the length of the messages or the requested output tokens.",
    "type": "invalid_request_error",
    "param": "messages",
    "code": "context_length_exceeded"
  }
}
```

The refusal can come from two places, and both use this shape. When the model's serving engine refuses the prompt, the message usually names the model's maximum context length, as above; on the few engines that do not report it, the message names no token counts. When a model is served on more than one kind of hardware, the gateway can refuse an oversized request itself, before it reaches an engine; that message names no token counts, because the gateway sizes the request with an estimate rather than the engine's tokenizer.

Treat both the same way: shorten the prompt or lower the output cap, which is `max_tokens` or `max_completion_tokens` on chat completions and `max_output_tokens` on `/v1/responses`. A non-streamed request that sets no output cap is sized with its default of 2048 output tokens (none on reasoning models), so setting a smaller cap explicitly can also bring it under the limit. A streamed request is refused the same way, with the same 400 before any event is sent.

Read the limit from `context_length` on `GET /v1/models` ([model discovery](https://docs.flex.ai/inference-api/guides/model-discovery.md)) rather than hard-coding it — a model's window changes when we move it to different hardware.

> [!NOTE]
>
> The window covers the prompt **and** the completion. A `max_tokens` on top of a prompt that nearly fills the window can still be refused.

### Unfetchable or undecodable `image_url`

A URL we can't fetch, or bytes we can't decode, is your fault rather than an outage — so it's a 400, not a 500:

```json theme={null}
{
  "error": {
    "message": "The provided image_url could not be fetched or decoded: 404, message='Not Found'",
    "type": "invalid_request_error",
    "code": null
  }
}
```

Check the URL is publicly reachable, returns image bytes, and uses an `http(s)` or `data` scheme. Genuine gateway failures on an image request still return 500, so treat this 400 as "fix the URL".

### Unfetchable or undecodable `video_url`

The same rule as for images: a video URL that times out, bytes we can't decode as a video, or a video over the size limit is your fault rather than an outage, so it's a 400, not a 500. The message names `video_url`:

```json theme={null}
{
  "error": {
    "message": "The provided video_url could not be fetched or decoded: Could not open video stream",
    "type": "invalid_request_error",
    "code": null
  }
}
```

A host that can't be reached at all (a DNS or connection failure) can answer a plain 400 `Invalid request.` instead, exactly as it does for an unreachable `image_url`. A request with more videos than the model's engine allows is the engine's own 400, not a gateway message.

A `video_url` with a scheme other than `http`, `https` or `data` is refused at the gateway, before the request runs, with a 400 whose `param` is `messages[i].content[j].video_url`. See the [video input guide](https://docs.flex.ai/inference-api/guides/video-input) for the sources and limits.

### Image sent to a model that doesn't accept images

Only some models can read an image. Send an `image_url` part (or `input_image` on `/v1/responses`) to a model whose `input_modalities` on `GET /v1/models` doesn't list `image`, and the gateway refuses the request before it reaches the model, so you aren't billed:

```json theme={null}
{
  "error": {
    "message": "Model 'DeepSeek-V4-Flash-0731' does not accept image input. Use a model whose 'input_modalities' on GET /v1/models lists 'image'.",
    "type": "invalid_request_error",
    "param": "messages",
    "code": null
  }
}
```

`param` names the field that carries the conversation: `"messages"` on chat completions, `"input"` on `/v1/responses` (an image inside a `function_call_output` counts too). The answer is deterministic and the model is the thing to change, so don't retry: pick a model from the [model discovery](https://docs.flex.ai/inference-api/guides/model-discovery.md) list whose `input_modalities` includes `image`.

### Video sent to a model that doesn't accept video

Only some models can watch a video. Send a `video_url` part to a model whose `input_modalities` on `GET /v1/models` doesn't list `video` (a model that reads images is not enough), and the gateway refuses the request before it reaches the model, so you aren't billed:

```json theme={null}
{
  "error": {
    "message": "Model 'gemma-4-31b-it' does not accept video input. Use a model whose 'input_modalities' on GET /v1/models lists 'video'.",
    "type": "invalid_request_error",
    "param": "messages",
    "code": null
  }
}
```

It is the same refusal as for images, with `video` in place of `image`, and the same advice: the answer is deterministic and the model is the thing to change, so don't retry. Pick a model from the [model discovery](https://docs.flex.ai/inference-api/guides/model-discovery.md) list whose `input_modalities` includes `video`.

### Forced `tool_choice` the model didn't honor

Pin `tool_choice` to `required` or a named function and get no tool call back, and we fail the request rather than return a toolless answer your agent loop would mistake for a result:

```json theme={null}
{
  "error": {
    "message": "The model 'gpt-oss-120b' returned no tool call, but tool_choice requested required. …",
    "type": "invalid_request_error",
    "param": "tool_choice",
    "code": "tool_choice_not_honored"
  }
}
```

Retry with `tool_choice="auto"`, or use a model that supports forced tool selection. It's a 400 rather than a 5xx so a retrying agent changes the request instead of looping. See [tool use](https://docs.flex.ai/inference-api/guides/tool-use.md).

The same rule holds when you stream. A stream has already started with a 200 by the time the model's answer is known, so the rejection arrives as the stream's last event instead of a status: the reasoning deltas you have already received stand, the prose the model produced instead of a call is withheld (up to a few thousand characters; a model that keeps writing past that is streamed from there on, and the verdict still ends the stream), and the stream ends with one `error` event carrying the same `type`, `param` and `code` as above, followed by `data: [DONE]`. When `stream_options.include_usage` is set, the usage chunk arrives ahead of the `error` event: the tokens the model generated are billed, as the answer was produced before it could be judged. On `/v1/responses` it is the flat `error` event (`"type": "error"` with `code`, `message` and `param` beside it, and a `sequence_number` continuing the stream's). A named function is honoured only by calls to that function; a reply that calls a different tool, instead of or as well as the one you named, is rejected with the same code and a message naming the function you asked for. Treat that event exactly as you would the 400: change the request rather than retry it as-is. Here is how it looks on chat completions:

```text theme={null}
data: {"id":"chatcmpl-…","choices":[{"delta":{"reasoning_content":"…"}}],…}

data: {"id":"chatcmpl-…","choices":[],"usage":{"prompt_tokens":52,"completion_tokens":31,"total_tokens":83}}

data: {"error":{"message":"The model 'Muse-Glimmer-30B' returned no tool call, but tool_choice requested required. …","type":"invalid_request_error","param":"tool_choice","code":"tool_choice_not_honored"}}

data: [DONE]
```

Non-streamed only, the same `code` also covers a forced reply that stopped at the output token limit before its tool call was complete (`finish_reason: "length"` on chat completions; `status: "incomplete"` with `incomplete_details.reason: "max_output_tokens"` on `/v1/responses`): the calls it carries are not one complete turn, so the reply is rejected rather than handed to your agent. Raise `max_tokens` (`max_output_tokens` on `/v1/responses`), or use `tool_choice="auto"`. The exception is `"required"` on the models the gateway bounds to one call (`GLM-5.2`, `MiniMax-M2.7`, `NVIDIA-Nemotron-3.5-Lightning-30B-A3B`; see the [tool use guide](https://docs.flex.ai/inference-api/guides/tool-use.md)): there, a reply with several calls at the limit means the model kept repeating its call, and a larger budget would only let it run longer. That reply is rejected as an unsafe required-tool response instead, and the message does not mention the limit: use `tool_choice="auto"` or a named tool choice. On those models this check applies to streams too. A stream releases tool-call deltas as they arrive and cannot take them back, so a streamed reply cut off at the limit ends with its `finish_reason` and no `error` event; check `finish_reason` yourself before dispatching the calls.

## 401 — Unauthorized

Check the `Authorization: Bearer sk-…` header. If the key looks right it may be revoked or expired — issue a new one from the [dashboard](https://platform.flex.ai/dashboard/keys).

```json theme={null}
{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
```

> [!WARNING]
>
> **Don't branch on `type` or `code` for a 401.** Three endpoint families report the
> same rejection differently today — the media plane uses `missing_api_key` /
> `invalid_api_key`, `/v1/flex/*` uses `missing_authorization` /
> `malformed_authorization` and switches `type` to `authentication_error` for a bad
> key, and `/v1/models` returns `type: "auth"` with **no `code` field at all**.
> Branch on the 401 status. We're unifying these onto one shape, so anything you
> match on the body today is liable to change.

The OpenAI SDKs are unaffected — they map 401 to their authentication-error class by
status code, not by body — so this only matters if you're calling the API over raw
HTTP. Note the `/v1/models` case in particular: reading `error.code` there gets you
`None`, not a string.

Some 401s also carry a `doc_url` pointing at the dashboard page that fixes them.

## 402 — Payment required

Four causes share this status. On the media endpoints, `message` tells them apart — credit exhausted, monthly spend cap reached, account on hold, or not provisioned for billing.

```json theme={null}
{
  "error": {
    "message": "You exceeded your budget. Please add credits to continue.",
    "type": "insufficient_quota",
    "code": "insufficient_quota"
  }
}
```

On chat, completions, `/v1/responses`, embeddings and `/v1/rerank`, the first three causes share one message, because the budget these routes enforce is whichever runs out first of your balance, your organization's monthly spend cap, and any spend limit an admin set on you or your key, and the error cannot say which:

```json theme={null}
{
  "error": {
    "message": "You exceeded your budget. Add credits, or ask an admin to raise your spend limit or the organization's monthly spend cap. If your account is on hold, contact support.",
    "type": "insufficient_quota",
    "code": "insufficient_quota"
  }
}
```

Some chat requests refused for budget may still return a [`429`](#429--too-many-requests) whose `error.type` is `budget_exceeded`; handle it the same way as this 402.

Chat and completions have one more: before generating, we check the request's worst-case cost against your remaining balance. That one is a gate rejection: `error.code` is `insufficient_balance`, and the actionable content is under `error.provider_specific_fields`, as `max_usage_cost_usd` (what the request could cost) and `key_remaining_usd` (what's left). Render those rather than looking for a sentence.

When your organization's monthly spend cap is what refused the request (not your balance), the same 402 also carries `provider_specific_fields.reason: "spend_cap_reached"` and says so in `message`. Adding credit won't help then: an org admin has to raise the cap, or wait for it to reset on the 1st of the month. `error.code` stays `insufficient_balance`, so existing handling keeps working. If your balance is also too low for the request, `reason` is the same and `message` says so too ("…and its balance is also too low for this request. Ask an organization admin to raise the cap, and add funds on the Billing page."), so you're told up front that raising the cap alone won't be enough.

```json theme={null}
{
  "error": {
    "message": "Your organization's monthly spend cap has been reached. Ask an organization admin to raise it on the Billing page.",
    "type": "insufficient_quota",
    "param": null,
    "code": "insufficient_balance",
    "provider_specific_fields": {
      "error": "insufficient_balance",
      "max_usage_cost_usd": "0.0084",
      "key_remaining_usd": "0.0073",
      "model": "<model>",
      "reason": "spend_cap_reached",
      "message": "Your organization's monthly spend cap has been reached. Ask an organization admin to raise it on the Billing page."
    }
  }
}
```

Top up on the [billing page](https://platform.flex.ai/billing), or ask an org admin to raise the cap. The same key resumes working — nothing needs reissuing. See [billing & quotas](https://docs.flex.ai/inference-api/reference/billing.md).

## 403 — Forbidden

Three causes, told apart by `code`.

### Region not served

Your org is pinned to a data region this endpoint doesn't serve, so we decline rather than move your data out of it. On the media endpoints that's a plain envelope:

```json theme={null}
{
  "error": {
    "message": "This organization's data region is not served by this endpoint.",
    "type": "invalid_request_error",
    "code": "region_not_served"
  }
}
```

On chat and completions the same gate answers with `error.code` `region_not_served`, and its payload (including `region`) under `error.provider_specific_fields`.

This is not the error you get for calling the wrong host. The two regions keep separate key stores, so a key presented to the endpoint it does not belong to fails authentication first and comes back [`401`](#401--unauthorized) — see [Regions & Data Residency](https://docs.flex.ai/inference-api/reference/regions.md). This `403` means the workspace and the stack serving it disagree, which should not arise in normal use: report it to [support@flex.ai](mailto:support@flex.ai) rather than retrying against the other host.

A region is permanent once set, and that is enforced in the database — it cannot be changed from the dashboard, and we cannot change it for you either. If a workspace ended up in the wrong region, support will help you set a new one up in the right region instead.

### Business verification required

Every business organization has to verify its business once for each region it uses. Until the region's verification is approved, requests from that region's workspaces are declined with this error. It is **not** a billing error: your balance is untouched, and **adding a payment method and creating API keys keep working**, so you can set most things up while you wait. Top-ups are refused with `409 business_verification_required` until the region's verification is approved, so nothing is charged for credit you cannot use yet. Once it is approved, top up and start straight away.

**Grace period.** A business organization that already existed when business verification was enforced keeps serving requests (and can top up) for a grace period, 30 days by default, counted from the deadline email we send its owners and admins. After the deadline this error applies as above. A business organization created after verification is enforced has no grace period and must verify before using the API. See [Billing → Business](https://docs.flex.ai/inference-api/reference/billing.md#business).

On chat, completions, embeddings and responses the sentence is in `error.message`, the code is `error.code`, and the payload (including `region`) is under `error.provider_specific_fields`:

```json theme={null}
{
  "error": {
    "message": "This organization must complete business verification for the US region before it can use the inference API. An Organization owner or admin can start it in the FlexAI dashboard under Organization settings, Verification. Adding a payment method and creating API keys are not affected. Top-ups open once verification is approved.",
    "type": "permission_error",
    "param": null,
    "code": "business_verification_required",
    "provider_specific_fields": {
      "error": "business_verification_required",
      "message": "This organization must complete business verification for the US region before it can use the inference API. An Organization owner or admin can start it in the FlexAI dashboard under Organization settings, Verification. Adding a payment method and creating API keys are not affected. Top-ups open once verification is approved.",
      "region": "us"
    }
  }
}
```

On the media endpoints it is the plain envelope, with the same `type`, `code` and sentence and no `provider_specific_fields`.

An organization owner or admin starts the verification on the [Organization verification page](https://platform.flex.ai/dashboard/organization/verification) of the dashboard, for a workspace in either region; [Billing → Business](https://docs.flex.ai/inference-api/reference/billing.md#business) has the steps. Retrying the request does nothing until a Flex admin approves the verification; once they do, requests start succeeding again within a few minutes, with no new key needed.

### Blocked key

On `/v1/models`, a key an administrator has blocked returns 403 with `type: "auth"` and no `code`. Contact [support@flex.ai](mailto:support@flex.ai) — a blocked key can't be unblocked from the dashboard.

## 404 — Not found

The Anthropic Messages API isn't part of the Inference API. A request to `/v1/messages`, or any path under it, returns 404 before authentication, so you get the same answer with or without a key:

```json theme={null}
{
  "error": {
    "message": "The Anthropic Messages API is not supported; use /v1/chat/completions or /v1/responses.",
    "type": "invalid_request_error",
    "param": null,
    "code": "endpoint_not_supported"
  }
}
```

On chat and completions, an unrecognized model id is a gate rejection, so the `did_you_mean` list arrives nested under `error.provider_specific_fields`:

```json theme={null}
{
  "error": {
    "message": "Model id not recognized. See /v1/models for the full list.",
    "type": "not_found_error",
    "param": null,
    "code": "unknown_model",
    "provider_specific_fields": {
      "error": "unknown_model",
      "model": "Llama-3.3-70B-Instruc",
      "message": "Model id not recognized. See /v1/models for the full list.",
      "did_you_mean": ["Llama-3.3-70B-Instruct"]
    }
  }
}
```

When a checkpoint we no longer serve has a declared replacement, that inner object also carries `suggested_model` — a deterministic pointer, not a spelling guess.

A media model that exists but isn't currently available uses the envelope with `code: "model_not_found"`. For models, use the canonical id from `GET /v1/models` — we require the bare model name, not a provider-prefixed path.

### Model in the catalog but not currently running

A model can be in our catalog and still not be running right now — we may have
stopped it deliberately, it may have scaled down to zero after a quiet period, or
the cluster hosting it may be having a problem. Requests for it come back 404
with `code: "model_deactivated"`:

```json theme={null}
{
  "error": {
    "code": "model_deactivated",
    "message": "The model 'Qwen3-Coder-Next' is not available. See GET /v1/models for the models you can call right now."
  }
}
```

It's a 404 rather than a 503 because we don't spin a stopped model up to serve
the request that found it stopped. Retrying the same call won't get you a
different answer on any timescale you'd want to wait for, so treat this as "pick
a different model", not "back off and try again".

`GET /v1/models` is the list to pick from. It's built from the same signal this
check uses, so the two tell the same story — though they're each cached for a few
seconds, so right after a model stops or starts you may briefly see one before the
other catches up. If you get this error for a model the listing still shows, wait
a few seconds and re-read the listing.

### Model we can't price

Rare, and a bug on our side rather than yours: `pricing_unavailable` means we
couldn't resolve a price for a media request, so we declined to run it rather
than serve work we can't bill. You were not charged.

```json theme={null}
{
  "error": "pricing_unavailable",
  "message": "The model 'some-model' is not available. The request was not run and you were not charged. Use a different model from GET /v1/models, or contact support@flex.ai."
}
```

It's a 404 for the same reason as the case above: it takes a configuration fix on
our side, so no amount of retrying clears it. Use a different model and tell us at
[support@flex.ai](mailto:support@flex.ai) — we'd like to know.

> [!NOTE]
>
> Both of these moved on 2026-09-20: `model_deactivated` from 503 to 404, and
> `pricing_unavailable` from 500 to 404. If you special-cased either as a
> retryable 5xx, that branch is now dead — the `error` codes are unchanged, so
> matching on those still works.

## 410 — Gone

Video results have a one-hour, one-download pickup window:

```json theme={null}
{
  "error": "job_already_retrieved",
  "message": "This video was already retrieved. Each completed clip can be downloaded once."
}
```

```json theme={null}
{
  "error": "job_expired",
  "message": "The video is no longer available. Clips expire one hour after completion."
}
```

Download a completed video promptly and persist it on your side if you need it later. A job belonging to another key uses the same unavailable response as an expired job, so one key cannot probe for another key's work.

## 413 — Payload too large

A speech-to-text upload over the limit. `max_size_mb` always reports the limit, so read it from there rather than hard-coding a number:

```json theme={null}
{
  "error": "payload_too_large",
  "message": "Audio file exceeds 25 MB limit.",
  "max_size_mb": 25
}
```

We check twice — once against `Content-Length` before reading the upload, and once after, in case the header understated it. The second check omits `message`, so this is one of the bodies where you need the `error` code and `max_size_mb` rather than a sentence.

Split or downsample the audio. See [audio](https://docs.flex.ai/inference-api/guides/audio.md).

## 422 — Unprocessable content

The body parsed but a field is wrong. `param` names it, and `code` is
`invalid_request_body`:

```json theme={null}
{
  "error": {
    "message": "Missing required parameter: 'model'.",
    "type": "invalid_request_error",
    "param": "model",
    "code": "invalid_request_body"
  }
}
```

Speech-to-text has its own 422 for the wrong content type, and it's the one body on the
whole API that puts its explanation in `detail` rather than `message`:

```json theme={null}
{
  "error": "invalid_request",
  "detail": "This endpoint requires multipart/form-data. Send the audio file as form field 'file' and the model name as form field 'model'."
}
```

A 400 on the same endpoints means the body didn't parse at all — wrong content type or
malformed JSON — whereas a 422 means it parsed and a field failed validation.

## 429 — Too many requests

Over the per-key requests-per-minute ceiling. Running out of credit or reaching a spend cap is a [`402`](#402--payment-required), which retrying will not clear.

Some chat requests refused for budget may still return a 429 whose `error.type` is `budget_exceeded`. Treat it like the 402: don't retry, add credits or have the cap raised.

| Header | Meaning |
| - | - |
| `Retry-After` | Whole seconds to wait before retrying. |
| `x-ratelimit-limit-requests` | RPM ceiling for this key. |
| `x-ratelimit-remaining-requests` | Remaining in the window — always `0` on a 429. |
| `x-ratelimit-reset-requests` | Time until the window resets, as a duration string such as `34s`. |

> [!WARNING]
>
> `x-ratelimit-reset-requests` is a **duration**, not a Unix timestamp. Parse it as seconds-with-a-trailing-`s`, or use `Retry-After`, which carries the same number as a bare integer.

```json theme={null}
{
  "error": {
    "message": "Rate limit exceeded: Limit 100 RPM, Used 100. Please try again in 34s.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
```

Back off until `Retry-After`. If you hit the ceiling consistently, request a tier upgrade from [support@flex.ai](mailto:support@flex.ai). See [concurrency & rate limits](https://docs.flex.ai/inference-api/guides/concurrency.md).

You don't have to wait for a 429 to see your headroom. A successful non-streaming response from a key with an RPM limit carries two more headers, with a different prefix from the ones above: `x-ratelimit-api_key-limit-requests` (the key's RPM ceiling) and `x-ratelimit-api_key-remaining-requests` (what's left in the current window, after this request). Streaming responses don't carry them.

A 429 with `code: "gateway_capacity_exhausted"` (`type: "capacity_error"`) is a different thing: not your key's ceiling, but no capacity to take the request at that moment. It also carries `Retry-After`; retry after it.

`GET /v1/models` throttles separately, on its own per-IP and global counters rather than
your key's RPM, and reports it as `type: "rate_limit"` with no `code`. Cache the catalog
instead of polling it — it changes rarely.

### The other 429: a flood limit at the edge

The shape above is the **per-key** limit, and it is the one you will meet in normal use.
There is a second, much higher ceiling applied per **source IP address** at our edge
proxy, before a request reaches the API at all. It exists to absorb floods and is set far
above any legitimate client's traffic — you should never see it.

Because the proxy enforces it rather than the API, **its 429 carries different headers**,
and the names are close enough to the ones above to be mistaken for them:

| | Per-key 429 (above) | Edge 429 |
| - | - | - |
| `Retry-After` | Yes | **Absent** |
| Limit | `x-ratelimit-limit-requests` | `x-ratelimit-limit` |
| Remaining | `x-ratelimit-remaining-requests` | `x-ratelimit-remaining` |
| Reset | `x-ratelimit-reset-requests`, a duration such as `34s` | `x-ratelimit-reset`, a **bare integer** of seconds |
| Body | JSON `error` object | `text/plain`, the literal string `local_rate_limited` |

An edge 429 looks like this in full:

```http theme={null}
HTTP/2 429
content-type: text/plain
x-ratelimit-limit: 100000
x-ratelimit-remaining: 0
x-ratelimit-reset: 16

local_rate_limited
```

> [!WARNING]
>
> Match rate-limit headers **exactly**, not by prefix. `x-ratelimit-reset` and
> `x-ratelimit-reset-requests` are different headers with different value formats — one a
> bare integer, the other a duration string — so a loose match will parse one as the other.
> And because the edge 429 has no `Retry-After`, treat that header's absence as "back off
> using `x-ratelimit-reset`, or your own exponential backoff" — never as "retry now".

If you are seeing edge 429s, retrying harder will not help and backing off will: either you
are sending genuinely extreme volume from one address, or many of your clients share a
single egress IP (an office NAT or VPN gateway) and are counted as one caller. Get in touch
at [support@flex.ai](mailto:support@flex.ai) rather than tuning your retry loop.

## 499 — Client closed request

You never receive this status: it's what your request log records when the connection closed before we finished the response, because your client disconnected, gave up on its own timeout, or cancelled the call. Nothing was wrong with the request, so there's nothing to fix in it.

When a streamed response is cut, generation stops at the disconnect. You're charged for the prompt and for the output already streamed to you, never for output you didn't receive. Abandoning a non-streamed call does not currently stop its generation, and the call is billed as completed, so if you cancel calls on purpose, use streaming: it's the way to stop a long generation early.

## 500 — Internal server error

An unexpected failure in our gateway or a model backend. We don't shape these bodies, so read `message` and treat `type`/`code` as unstable.

A failed request that produced no output is not billed, even though its prompt was read. If the model had already produced output before the failure, the output we recorded for the request is billed along with the prompt.

Retry with backoff. We don't support idempotency keys, so only retry requests you're willing to have execute twice. Persistent 500s mean an incident — check [status.flex.ai](https://status.flex.ai).

## 502 — Bad gateway

Only `GET /v1/flex/key` and `GET /v1/models`. A component inside our gateway that
these two endpoints depend on was unreachable, rejected our own credentials, or answered
with a body we couldn't use. We fail closed on all three rather than serve a result
we can't stand behind — an unverified key, or a credit figure we're not sure of.

This is the one status that returns a bare `detail` string with no `error` key, so
a client that reaches for `error.message` gets `undefined` here:

```json theme={null}
{
  "detail": "upstream gateway unavailable"
}
```

The `detail` values are `upstream gateway unavailable`, `upstream key verification
unavailable`, and `upstream gateway returned an unusable response`. They're diagnostic, not a
contract — don't branch on them.

Retry with backoff. Both endpoints that return a 502 are read-only lookups, so
retrying is always safe. Persistent 502s mean an incident — check
[status.flex.ai](https://status.flex.ai).

## 503 — Service unavailable

`code` says which dependency: `backend_unavailable` for a media backend we can't
reach, `safety_check_unavailable` when the content safety check on a video
prompt couldn't run (we refuse rather than generate a video we haven't
checked), `transcode_overloaded` when audio processing is saturated,
`service_unavailable` / `auth_service_unavailable` when key verification itself
is down (we fail closed rather than serve an unverified request),
`balance_unavailable` on chat when your balance couldn't be checked (we refuse
rather than run an unbilled request; it says nothing about your credit), and
`global_plane_unavailable` when one of our own internal control-plane services
was momentarily unreachable — typically a restart during a deploy, lasting
seconds.

`stripe_tenant_not_configured` means billing for your account's region is not
fully set up on our side. We refuse the operation rather than complete it against
the wrong payment processor account, so nothing is charged. It needs an
operator's attention rather than a retry — contact support if you see it.

`spend_rollup_unavailable` means a key's or member's spend over its window could not be
read. We fail rather than show a zeroed figure that could be mistaken for unused
allowance; retry shortly, and contact support if it persists.

`relief_region_unknown` means a top-up needed to decide whether a tax number on your
billing account relieves tax, and one of our own services did not yet say which
region the account belongs to. We refuse rather than charge tax that may not be due,
so nothing is charged; it clears when that service finishes upgrading, so retry shortly.

These arrive nested, under `detail`, rather than flat:

```json theme={null}
{
  "detail": { "code": "global_plane_unavailable" }
}
```

```json theme={null}
{
  "error": "backend_unavailable",
  "message": "Image generation failed: upstream unreachable."
}
```

Retry with backoff. Every 503 here is a dependency we expect back.

## 504 — Gateway timeout

Two different timeouts answer with a 504: a chat request that ran out of time, and a usage query on `/v1/flex/*`.

### Request deadline exceeded

On chat, a request that runs out of time before any of its answer has been sent gets
`type: "timeout_error"` with `code: "request_deadline_exceeded"`. A request without
`stream: true` returns nothing until the whole answer is generated, so it has to finish
within a fixed time budget: about 3 minutes, or the shorter `timeout` you set on the
request. When it doesn't, the message names that budget and the way out:

```json theme={null}
{
  "error": {
    "message": "Request deadline exceeded. A non-streaming request must finish within 180 seconds; retry with stream: true, or lower max_tokens.",
    "type": "timeout_error",
    "param": null,
    "code": "request_deadline_exceeded"
  }
}
```

Don't send the same request again unchanged: it runs out of time the same way. This
response carries the header `x-should-retry: false`, so the OpenAI SDKs return it to you
straight away instead of retrying it on their own. If your client retries 5xx responses
itself, skip the retry for this message. Send it with `stream: true` instead (see
[Streaming](https://docs.flex.ai/inference-api/guides/streaming.md)), which keeps the connection alive token by
token, or lower `max_tokens` / `max_completion_tokens`.

On `/v1/responses` the same message names `max_output_tokens`, the field that caps output
there.

A streamed request, an embeddings request (which can't stream), or one that ran out of
time before the gateway could take it on (still uploading, or the gateway too busy to
start it) gets the same code with `"Request deadline exceeded."` as the whole message.
Retry those with backoff.

### Usage query timed out

Only `/v1/flex/*`. A usage query ran longer than the gateway allows, reported as
`type: "gateway_timeout"` with `code: "usage_timeout"`.

```json theme={null}
{
  "error": {
    "message": "Usage query timed out.",
    "type": "gateway_timeout",
    "code": "usage_timeout"
  }
}
```

Narrow the time range and retry. This is a read-only query, so retrying is always safe.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.