Skip to content
HomeModels
DocsGuides

Error handling

Understand HTTP status codes and handle failed requests.

Check the HTTP status first, then read error.message or message in the response. Error formats may differ by protocol and upstream channel.

StatusMeaningWhat to do
400Invalid requestCheck the model, required fields, and parameter types.
401Authentication failedCheck the API key, expiration, quota, and authentication header.
403Access deniedCheck account status and access permissions.
404Not foundVerify the API host, endpoint path, and model ID.
429Rate limit or quota exceededRead the error, reduce concurrency, or check balance and quota.
500 / 502 / 503Service or upstream unavailableRetry later. If failures persist, contact support with request details.

Use bounded exponential backoff with jitter for temporary network errors, rate limits, and service unavailability. Honor Retry-After when present. Fix invalid parameters or credentials before retrying.

A timeout does not guarantee that the upstream did not execute the request. Retrying image or audio generation may incur additional charges; check usage logs first.

  • Record the request time, model ID, HTTP status, and full error message.
  • Review account balance, key limits, and request logs in the console.
  • Remove API keys and sensitive input before sharing a request example.
  • Streaming requests may fail after HTTP 200. Handle error events inside the stream as well.