Skip to main content

Error Response Format

When an error occurs, the API returns a JSON object with an error field:

Error Codes

Common Errors

400 — Invalid Model

Returned when you specify a model that isn’t supported:
Fix: Check the supported models list and use a valid model ID.

400 — Missing Model Field

Fix: Include the model field in your request body.

401 — Invalid API Key

Fix: Check that your API key is correct and starts with sk_. Generate a new key from your dashboard if needed.

402 — Insufficient Balance

Fix: Your subscription and lifetime credits are both exhausted. Either:

429 — Rate Limit Exceeded

Fix: You’ve exceeded your plan’s requests-per-minute limit. Implement exponential backoff or upgrade your plan for higher limits:

500 — Internal Server Error

Fix: This is a server-side issue. Retry the request with exponential backoff. If the problem persists, check the status page or contact support.

Error Handling Best Practices

For 429 and 500 errors, retry with increasing delays:
Check for 402 errors and notify users to add credits:
Use the /v1/models endpoint to check if a model is supported before making a chat completion request.