Gateway errors
The errors the gateway returns itself, and how provider errors reach you.
A request through the gateway can fail in two places: at the gateway, before or instead of calling the provider, or at the provider. You can tell them apart by the body.
Errors the gateway produces#
These use the error envelope and are never charged:
{
"error": {
"type": "payment_required",
"code": "insufficient_credits",
"message": "the customer's balance is too low for this request",
"param": null
}
}| Status | type | code | What to do |
|---|---|---|---|
400 | invalid_request | customer_required | Send x-hixel-customer: the environment requires it |
400 | invalid_request | invalid_header | Fix the header named in param (x-hixel-customer, x-hixel-member, x-hixel-tags) |
400 | invalid_request | invalid_body | The body is not valid JSON for the format, or repeats a key |
400 | invalid_request | body_too_large | Bodies are limited to 32 MiB |
400 | invalid_request | unsupported_parameter | The model's provider cannot express the parameter in param |
400 | invalid_request | endpoint_not_supported_by_model | The model does not serve this endpoint (for example, embeddings from a chat model) |
400 | invalid_request | guardrail_violation | One of the environment's guardrail rules blocked the input |
401 | unauthenticated | missing_api_key | Send a key or a client token |
401 | unauthenticated | invalid_api_key | The key is unknown or revoked |
401 | unauthenticated | expired_api_key | The key is past its expiry |
402 | payment_required | insufficient_credits | The customer's wallet cannot cover the request: add credit |
402 | payment_required | spend_limit_reached | A spend limit is used up for its window; param names it: see Limits |
403 | permission_denied | key_scope_insufficient | The key has no inference scope |
403 | permission_denied | customer_blocked | You blocked this customer |
403 | permission_denied | customer_mismatch | The key is pinned to another customer |
403 | permission_denied | model_not_allowed | An allowlist (environment, key or customer) excludes the model |
403 | permission_denied | provider_key_required | Only a customer's own provider key can serve this model |
403 | permission_denied | provider_key_missing | No provider key is connected for the model's provider (in param): connect yours |
404 | not_found | model_not_found | No model or alias by that name in the environment |
404 | not_found | route_not_found | No such path on the gateway |
429 | rate_limited | rate_limited | A rate limit is reached: wait for retry-after seconds when given |
429 | rate_limited | provider_rate_limited | The provider is rate-limiting the gateway: retry after retry-after |
503 | unavailable | credential_unavailable | A provider key that should serve the model cannot be used: check the key, or retry later |
503 | unavailable | provider_unavailable | The provider refused the gateway's own account: retry later |
503 | unavailable | upstream_timeout | The provider did not answer in time, after the gateway's retries |
503 | unavailable | upstream_unreachable | The provider could not be reached, after the gateway's retries |
503 | unavailable | limiter_unavailable | The customer's balance could not be checked: retry |
503 | unavailable | config_unavailable | The gateway's configuration for the request could not be read: retry |
500 | internal | internal_error | An unexpected failure on our side: retry with backoff |
Client tokens and
test environments have a few codes of their own. Every
response, error or not, carries x-hixel-request-id.
Two codes are about your organization's standing with Hixel, not about your
customer: 402 tenant_account_depleted and 403 environment_suspended. Do not show them to
your end user as their problem.
Errors from the provider#
When the provider answers with an error (a malformed request it refuses, its content policy, an overload), the gateway returns it with the provider's status. If you called the provider's own format, the body is passed through unchanged. If the gateway translated the request (Chat Completions to a Claude model, for example), the error is rewritten into your format, so your SDK can read it.
The exception is a failure of Hixel's own provider account, on a request it pays for:
the provider refusing the account (401, 403), a billing error, or a 429. Those would read
as if your key were wrong or your quota exhausted, so they become 503
provider_unavailable or 429 provider_rate_limited instead. On your own provider
key or a customer's own key the provider's
error is returned as it is.
A stream that fails after it started ends with an error event in your format, never with a normal end. So does a stream whose provider stops sending for two minutes (an answer that is not streamed: five minutes): the gateway gives up on it, and the request is billed for what the provider produced up to then.
Retrying#
429and503: retry with backoff, afterretry-afterseconds when the response has it.402: do not retry until credit is added or the limit's window resets.400,401,403,404: fix the request; retrying the same one fails the same way.