Errors
OpenModels uses OpenAI-compatible JSON errors through the Alephant gateway. Use the HTTP status code for broad handling and use error.code when the response includes a stable machine-readable code.
Error response format
OpenModels account, billing, and usage errors can include request_id and retryable fields:
Some gateway or upstream errors use the standard OpenAI-compatible shape and may not include request_id or retryable:
Fields:
For routed model requests, if you send an x-request-id header, the gateway can echo it in error.request_id. Otherwise, the gateway may generate a km_... request id. Early authentication, account, or upstream errors may not include a request id, so keep your own request id in client logs.
Error codes
Handle these responses today:
OpenModels-specific Key Market codes may appear in gateway responses. When present, handle them as follows:
Retry guidance
Use error.retryable as the primary retry signal when it is present. If error.retryable is missing, fall back to the HTTP status code and your own idempotency rules.
Do not automatically retry these errors until the user or system changes something:
invalid_api_keykey_market_key_invalidkey_market_insufficient_balancekey_market_spend_limit_exceededkey_market_model_not_availablekey_market_image_price_not_availablekey_market_upstream_not_supported
These errors may be transient. Retry them with backoff when error.retryable is true, or when your HTTP status and idempotency rules allow it:
key_market_no_upstream_availablekey_market_usage_unavailablekey_market_upstream_errorkey_market_upstream_timeout
HTTP 429, 502, 503, and 504 responses without a Key Market code may also be transient. For retries, use exponential backoff and a small maximum retry count. For production workloads, log your client request id, error.request_id when present, error.code, model ID, endpoint, and whether the request was streaming.
Common fixes
Example handling
Support
When reporting an error, include:
- Your client request id
error.request_id, if presenterror.code, if present- HTTP status
- Model ID
- Endpoint
- Whether the request was streaming
- Timestamp