Error Response Format
When an error occurs, the API returns a JSON object with anerror field:
Error Codes
Common Errors
400 — Invalid Model
Returned when you specify a model that isn’t supported:400 — Missing Model Field
model field in your request body.
401 — Invalid API Key
sk_. Generate a new key from your dashboard if needed.
402 — Insufficient Balance
- Wait for your next subscription credit refill (scheduled every 5 hours)
- Purchase lifetime credits from your dashboard
- Upgrade your plan for higher credit limits
429 — Rate Limit Exceeded
500 — Internal Server Error
Error Handling Best Practices
Implement retry logic with exponential backoff
Implement retry logic with exponential backoff
For
429 and 500 errors, retry with increasing delays:Handle insufficient balance gracefully
Handle insufficient balance gracefully
Check for
402 errors and notify users to add credits:Validate models before sending requests
Validate models before sending requests
Use the
/v1/models endpoint to check if a model is supported before making a chat completion request.