Error Codes
API error codes and troubleshooting guide
Error Code Reference
When an API request fails, the response includes an HTTP status code and an error object with details about what went wrong. The following table lists all possible error codes:
| HTTP Status | Error Code | Description | Solution |
|---|---|---|---|
| 400 | invalid_request | The request body is malformed or missing required fields | Check request parameters and format |
| 401 | authentication_failed | Invalid or missing API Key | Verify your API Key is correct |
| 403 | permission_denied | Your account does not have access to this resource | Check your account permissions and subscription |
| 404 | not_found | The requested resource does not exist | Verify the endpoint URL and model name |
| 429 | rate_limit_exceeded | Too many requests, rate limit exceeded | Reduce request frequency or wait before retrying |
| 500 | internal_error | Server internal error | Retry after a short delay; contact support if persistent |
| 503 | service_unavailable | Service temporarily unavailable due to high load | Retry with exponential backoff |
Error Response Format
Error responses follow this structure:
{
"error": {
"code": "authentication_failed",
"message": "Invalid API Key provided.",
"type": "error"
}
}Best Practices for Error Handling
Implement Retry Logic
Not all errors should be retried. Use the following guidelines:
- Retryable errors (429, 500, 503): These are transient errors that may resolve on their own. Implement automatic retry with exponential backoff.
- Non-retryable errors (400, 401, 403, 404): These indicate issues with your request or credentials. Fix the underlying problem before retrying.
Exponential Backoff Strategy
When retrying failed requests, use exponential backoff to avoid overwhelming the server:
import time
import random
def make_request_with_retry(func, max_retries=5):
for attempt in range(max_retries):
try:
return func()
except Exception as e:
if attempt == max_retries - 1:
raise e
# Exponential backoff with jitter
delay = min(2 ** attempt + random.random(), 60)
print(f"Request failed, retrying in {delay:.1f}s... (attempt {attempt + 1}/{max_retries})")
time.sleep(delay)Handle Rate Limits Gracefully
If you receive a 429 rate_limit_exceeded error:
- Respect the retry-after header: If the response includes a
Retry-Afterheader, wait at least that long before retrying. - Reduce concurrency: Lower the number of parallel requests to stay within rate limits.
- Implement request queuing: Queue requests and process them at a controlled rate.
Log Errors for Debugging
Always log error responses including the full error object, request ID (if available), and timestamp. This information is essential when contacting support for persistent issues.
Validate Requests Before Sending
Reduce 400 invalid_request errors by validating your request data before sending:
- Ensure all required fields are present.
- Verify the model name matches one of the available models (
mimo-v2-pro,mimo-v2-omni,mimo-v2-tts,mimo-v2-flash). - Check that parameter values are within acceptable ranges.
- Confirm the API Key is set and not empty.
MiMo API Docs