Documentation menu

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
  }
}
StatustypecodeWhat to do
400invalid_requestcustomer_requiredSend x-hixel-customer: the environment requires it
400invalid_requestinvalid_headerFix the header named in param (x-hixel-customer, x-hixel-member, x-hixel-tags)
400invalid_requestinvalid_bodyThe body is not valid JSON for the format, or repeats a key
400invalid_requestbody_too_largeBodies are limited to 32 MiB
400invalid_requestunsupported_parameterThe model's provider cannot express the parameter in param
400invalid_requestendpoint_not_supported_by_modelThe model does not serve this endpoint (for example, embeddings from a chat model)
400invalid_requestguardrail_violationOne of the environment's guardrail rules blocked the input
401unauthenticatedmissing_api_keySend a key or a client token
401unauthenticatedinvalid_api_keyThe key is unknown or revoked
401unauthenticatedexpired_api_keyThe key is past its expiry
402payment_requiredinsufficient_creditsThe customer's wallet cannot cover the request: add credit
402payment_requiredspend_limit_reachedA spend limit is used up for its window; param names it: see Limits
403permission_deniedkey_scope_insufficientThe key has no inference scope
403permission_deniedcustomer_blockedYou blocked this customer
403permission_deniedcustomer_mismatchThe key is pinned to another customer
403permission_deniedmodel_not_allowedAn allowlist (environment, key or customer) excludes the model
403permission_deniedprovider_key_requiredOnly a customer's own provider key can serve this model
403permission_deniedprovider_key_missingNo provider key is connected for the model's provider (in param): connect yours
404not_foundmodel_not_foundNo model or alias by that name in the environment
404not_foundroute_not_foundNo such path on the gateway
429rate_limitedrate_limitedA rate limit is reached: wait for retry-after seconds when given
429rate_limitedprovider_rate_limitedThe provider is rate-limiting the gateway: retry after retry-after
503unavailablecredential_unavailableA provider key that should serve the model cannot be used: check the key, or retry later
503unavailableprovider_unavailableThe provider refused the gateway's own account: retry later
503unavailableupstream_timeoutThe provider did not answer in time, after the gateway's retries
503unavailableupstream_unreachableThe provider could not be reached, after the gateway's retries
503unavailablelimiter_unavailableThe customer's balance could not be checked: retry
503unavailableconfig_unavailableThe gateway's configuration for the request could not be read: retry
500internalinternal_errorAn 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#

  • 429 and 503: retry with backoff, after retry-after seconds 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.