Skip to content
Secnd

Errors

Use the HTTP status and the shared JSON error envelope.

API errors use one JSON shape:

{"code": "invalid_key", "message": "A valid API key is required."}

Branch on the HTTP status and stable code, not the prose in message. Intermediaries can still return non-JSON failures; treat those as transport failures rather than successful decisions.

StatusMeaningYour next step
400Malformed JSON, compression, or request rulesFix the body or headers
401Missing, invalid, or revoked bearer keyFix credentials; do not blindly retry
413Body, formatted token count, or option count too largeReduce the request; no automatic truncation
415Unsupported content type or content encodingUse JSON and a supported single encoding
422Wrong fields, duplicate IDs, invalid levels, or unavailable modelFix the schema or model ID
429Key or account rate limit reachedHonor Retry-After and back off
502Invalid or unavailable inference responseRetry within a bounded budget
503Gateway temporarily unavailableRetry within a bounded budget
504Inference timed outRetry within a bounded budget
529Inference overloadedBack off and reduce concurrency

If inference fails, do not manufacture an answer or proceed as if the gate passed. Queue review or return a temporary failure from your own application.

The SDKs retry 429 and server errors with bounded backoff. Apply a separate application timeout and avoid wrapping SDK retries in an unbounded retry loop. Authentication and validation errors need corrected input.