Error Codes
HTTP Status Codes
Section titled “HTTP Status Codes”| Status | Meaning | Action |
|---|---|---|
200 | Success | Request completed successfully |
400 | Bad Request | Check request body and parameters |
401 | Unauthorized | Invalid or missing API key |
403 | Forbidden | API key lacks required permissions |
404 | Not Found | Endpoint or resource doesn’t exist |
429 | Rate Limited | Too many requests, retry after backoff |
500 | Server Error | Retry with exponential backoff |
503 | Service Unavailable | Upstream model is temporarily down |
Error Response Format
Section titled “Error Response Format”{ "error": { "message": "Invalid API key provided", "type": "invalid_request_error", "code": "invalid_api_key" }}Common Errors
Section titled “Common Errors”invalid_api_key
Section titled “invalid_api_key”Your API key is missing, expired, or incorrect. Check Dashboard → API Keys.
insufficient_quota
Section titled “insufficient_quota”Your account has run out of credits. Add more at Dashboard → Billing.
model_not_found
Section titled “model_not_found”The model name in your request doesn’t match any available model. Check the Models Overview for valid names.
rate_limit_exceeded
Section titled “rate_limit_exceeded”You’re sending requests too fast. Implement exponential backoff:
import time
for attempt in range(5): response = make_request() if response.status_code == 429: time.sleep(2 ** attempt) continue breakcontent_policy_violation
Section titled “content_policy_violation”The prompt was rejected by the model’s safety filter. Revise your prompt to comply with usage policies.