Error Codes
When an API request fails, the response includes an HTTP status code and a JSON body with error details.
Error Response Format
All errors follow this structure:
{
"error": {
"message": "A human-readable description of the error.",
"type": "error_type",
"code": 401
}
}400 Bad Request
The request is malformed or contains invalid parameters.
Common triggers:
Missing required fields (
modelormessages)Invalid
modelvalue (model does not exist)messagesarray is emptytemperatureoutside the valid range (0-2)max_tokensis negative or exceeds the model context limitMalformed JSON in the request body
Example:
How to fix:
Verify the request body is valid JSON
Check that all required fields are present
Ensure parameter values are within documented ranges
Use the Models API to confirm valid model IDs
401 Unauthorized
The API key is missing, invalid, or has been revoked.
Common triggers:
No
Authorizationheader in the requestIncorrect header format (must be
Bearer YOUR_API_KEY)API key has been deleted or deactivated
Example:
How to fix:
Verify your API key starts with
dos_sk_Check the
Authorizationheader format:Authorization: Bearer dos_sk_...Generate a new key from the dashboard if your current key may be compromised
Ensure there are no trailing spaces or newlines in the key
402 Payment Required
Your account does not have sufficient credits to process the request.
Example:
How to fix:
Check your current balance on the dashboard
Add credits to your account
If you believe this is an error, contact [email protected]
429 Too Many Requests
You have exceeded the rate limit for your account.
Example:
How to fix:
Implement exponential backoff (wait, then retry with increasing delays)
Check the
Retry-Afterheader for how long to waitReduce the frequency of your requests
See Rate Limits for detailed limits and best practices
Contact us for higher limits if your use case requires them
500 Internal Server Error
An unexpected error occurred on our servers.
Example:
How to fix:
Retry the request after a short delay (1-5 seconds)
If the error persists, try a different model
Check status.dos.ai for any ongoing incidents
Contact [email protected] with the request details if the problem continues
503 Service Unavailable
The requested model is temporarily unavailable, typically because it is being loaded, updated, or restarted.
Example:
How to fix:
Wait 30-60 seconds and retry. Model loading typically completes within a few minutes.
Try a different model if you need an immediate response
Check status.dos.ai for maintenance announcements
Best Practices for Error Handling
Implement Retry Logic
For transient errors (429, 500, 503), implement automatic retries with exponential backoff:
Log Error Details
Always log the full error response for debugging. The message field often contains specific information about what went wrong.
Validate Before Sending
Validate your request parameters client-side before making API calls to avoid unnecessary 400 errors. Check that:
The model ID is valid
Messages array is not empty
Numeric parameters are within range
JSON is well-formed
Last updated