Error Handling
Learn how to interpret API errors and build robust handling logic.
Error response structure
{
"status": "error",
"code": "invalid_request",
"message": "Missing required field: prompt",
"details": {
"field": "prompt"
}
}Common error codes
- 400 —
invalid_request: invalid payload or missing fields - 401 —
unauthorized: invalid or missing API key - 403 —
forbidden: insufficient permissions or blocked access - 429 —
rate_limit_exceeded: request volume exceeded - 500 —
server_error: unexpected system failure
Handling retries
Retry only idempotent requests and use a delay that increases with each attempt. Do not retry on client-side validation errors.
Logging and troubleshooting
Log the error code, message, request payload, and timestamps to make support requests easier to resolve.