Skip to content
LLMFLUX

API reference

Errors

Use the stable gateway code to decide what to fix or retry.

Error envelope

JSON errors contain error.message, error.type and error.code. The response also includes x-gateway-error-code. Raw provider error text is not exposed in gateway-generated JSON errors.

{
  "error": {
    "message": "API key invalid, expired, or revoked.",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}

Status codes

HTTPCodeTypeAction / cause
401missing_api_keyauthentication_errorSend Authorization: Bearer or x-api-key.
401invalid_api_keyauthentication_errorCheck the key is active; replace a revoked key.
402quota_exhaustedinvalid_request_errorAdd account credit; do not automatically retry.
403permission_deniedpermission_errorComplete required Telegram verification in the dashboard.
404invalid_modelinvalid_request_errorChoose an enabled model or exact alias; upstream 404 also maps here.
400invalid_jsoninvalid_request_errorFix malformed JSON.
400bad_requestinvalid_request_errorUpstream rejected the request; check endpoint-specific fields.
413payload_too_largeinvalid_request_errorReduce the body below the 25 MB parser limit.
429rate_limit_exceededrate_limit_errorPer-user throttle, rolling plan allowance or upstream rate limit.
502upstream_errorapi_errorProvider/network failure; upstream 401/403 are sanitized to this code.
503service_unavailableapi_errorNo usable provider or upstream service unavailable.
504gateway_timeoutapi_errorTimeout reaching a provider (120-second upstream request timeout).
500internal_errorapi_errorUnexpected gateway failure.
404not_foundinvalid_request_errorNo such gateway route.

context_length_exceeded and content_policy_violation are defined error types in the backend catalogue, but the current inference proxy maps generic upstream HTTP 400 to bad_request; it does not inspect provider text to distinguish these cases.

Retry safely

For transient 429 and 5xx, use bounded exponential backoff with jitter. Honor Retry-After when supplied by the per-minute throttle; plan and upstream errors do not guarantee that header. Avoid retrying authentication, insufficient-credit and malformed-input errors unchanged.

Provider failover already happens on network errors, upstream 429 and upstream 5xx before a successful response. Ordinary upstream 4xx do not trigger failover. No idempotency mechanism is implemented for inference: retrying after an uncertain result can create another request and charge.

After a stream starts

HTTP status cannot change after HTTP 200. Handle SSE error events and incomplete output separately from JSON errors.