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

# Errors

> What the gateway answers when a request fails.

The gateway answers in OpenAI's error format, so OpenAI clients handle its errors as OpenAI's:

```json theme={null}
{
  "error": {
    "kind": "unknown_model",
    "type": "invalid_request_error",
    "code": "unknown_model",
    "message": "...",
    "param": null
  }
}
```

| Status | `code` | When |
| - | - | - |
| 400 | `unknown_model`, `deactivated_model`, `model_not_served_by_provider`, `unknown_region`, `model_not_available_in_region`, `service_tier_not_offered`, `mapping_error`, `unknown_routing_strategy`, `invalid_routing_strategy_version`, `routing_strategy_archived`, `field_not_allowed_with_routing_strategy`, `reasoning_effort_not_benchmarked`, `no_callable_combination`, `embeddings_unsupported`, `invalid_metadata_header`, `invalid_query_parameter`, `invalid_json` | The request names a model, provider, region or routing strategy that cannot serve it, a field that model does not take, an `x-weflayr-metadata` header that is not a JSON object, a query parameter value the route does not take, or a body that is not JSON (`invalid_json`). |
| 401 | `invalid_credentials` | The key is missing, unknown or expired. |
| 402 | `insufficient_credits`, `spend_limit_reached` | Your organization has no [credits](https://docs.weflayr.com/product/credits.md) left (calls made with your own provider keys need credits too, for the Weflayr fee), or the key reached one of its spend limits: the message says when the limit's window ends. |
| 403 | `gateway_scope_required` | The key does not have the Gateway scope. |
| 413 | `payload_too_large` | The body is too large for the gateway or for the provider. |
| 415 | `unsupported_media_type` | The request has no `Content-Type: application/json` header. |
| 422 | `invalid_json` | The body is JSON but not a valid request: a missing field, a value of the wrong type, or a value the field does not take. |
| 429 | `rate_limited` | The key exceeded its rate limit of requests per minute: retry after the `Retry-After` header's delay, in seconds. A provider's own 429 is passed on as `provider_error`. |
| 502 | `routing_deployments_failed` | Every model of the routing strategy, or every model, provider and region the request lists, failed. The message lists each attempt. When every attempt failed with the same status, the answer has that status instead of 502. |
| 502 | `provider_error`, `provider_transport_error` | The provider failed to answer, or could not be reached. A provider's other 4xx refusal is passed on with its status as `provider_error`, except a 401 or 403, answered as a 502. |
| 503 | `model_catalog_unavailable`, `routing_strategy_unavailable`, `authentication_unavailable`, `credit_balance_unavailable`, `spend_limits_unavailable`, `provider_not_configured` | The gateway could not read its model catalog, a routing strategy, the key, the credit balance or the key's spend limits, or cannot reach the provider. Retry later. |


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