Skip to main content
Check the HTTP status before reading a normal response. With streaming, also inspect error events after the connection has opened.

HTTP errors

An apparently sufficient displayed balance can still produce 402 if concurrent requests have reserved credit or the requested output allowance is too large. The check reserves enough for the allowed request before generation starts.

Error bodies

Chat Completions and Responses normally use an OpenAI-style error object. For example:
Messages normally uses an Anthropic-style error envelope:
Handle the status even if an infrastructure or route-level error has a different JSON shape. Useful OpenAI-style codes include invalid_api_key, insufficient_credits, credit_pending, key_unavailable, too_many_concurrent, and input_too_large. Messages clients should also inspect the error type and message; the same code field is not always present.

Retry behavior

Honor Retry-After when supplied. For temporary 429, 502, 503, and 504 failures, use capped exponential backoff and avoid starting many retries at once. Repeating an inference request can generate a new answer and incur additional usage; inference requests do not expose an idempotency-key guarantee. credit_pending usually means a new grant or credit update is still being activated. Wait a few seconds and retry. An exhausted balance needs additional credit; repeatedly signing in or creating keys does not refill it.

Streaming errors

Once streaming starts, the HTTP status can remain 200 even if generation later fails:
  • Chat Completions: an SSE data: frame contains error, followed by [DONE].
  • Responses: an error event or a failed/incomplete response can terminate the result.
  • Messages: an event: error frame contains the error envelope.
Keep partial text separate from a completed answer. Keepalive comments and ping events are not errors or output. Closing a stream cancels the upstream request, but work already performed may still be accounted for.

Report a problem

If present, record the x-request-id response header, endpoint, status, and approximate time. Contact hello@derestricted.ai with those details. Do not include an API key. Describe a reproducible request without including private prompt content when possible.