openai
OpenAI API Error Codes
Error types and codes returned by the OpenAI API, covering authentication, rate limiting, model availability, context length, and content policy violations.
14 codes
references platform.openai.com/docs/guides/error-codes
· All codes 14 codes
- authentication_error Authentication Error Authentication failed. The API key is missing, malformed, or lacks permission for the requested operation. Ensure the Authorization header is present and correctly formatted.
- content_policy_violation Content Policy Violation The request or its requested completion was rejected because it violates OpenAI's usage policies. Review the content policy and modify the prompt to remove disallowed content.
- context_length_exceeded Context Length Exceeded The number of tokens in the prompt plus the requested max_tokens exceeds the model's maximum context length. Shorten the prompt, reduce max_tokens, or switch to a model with a larger context window.
- insufficient_quota Insufficient Quota Your account has exhausted its quota or has no billing set up. Add a payment method and purchase credits in the OpenAI billing dashboard.
- invalid_api_key Invalid API Key The API key provided is invalid, expired, or has been revoked. Verify your API key in the OpenAI dashboard and ensure it is being sent in the Authorization header as 'Bearer <key>'.
- invalid_request_error Invalid Request Error The request body is malformed, missing required parameters, or contains invalid values. Check the API reference for the correct request format and parameter types.
- max_tokens_exceeded Max Tokens Exceeded The value of max_tokens exceeds the maximum allowed for the requested model. Set max_tokens to a value within the model's limit.
- model_not_found Model Not Found The requested model does not exist or your account does not have access to it. Check the model name for typos and verify your account has been granted access to the model.
- permission_denied Permission Denied The API key does not have permission to perform the requested operation. Check the key's scope and that your organisation has access to the feature being used.
- rate_limit_exceeded Rate Limit Exceeded You have exceeded the API rate limit for your tier (requests per minute or tokens per minute). Implement exponential backoff, reduce request frequency, or apply for a higher usage tier.
- server_error Server Error An unexpected error occurred on OpenAI's servers. Retry the request using exponential backoff; if the problem persists, check the OpenAI status page.
- service_unavailable Service Unavailable OpenAI's servers are temporarily overloaded or down for maintenance. Retry the request after a short delay using exponential backoff.
- timeout Request Timeout The request took too long to complete and was cancelled. Reduce the complexity of the request, lower max_tokens, or switch to a faster model.
- tokens_quota_exceeded Tokens Quota Exceeded The organisation's per-minute or per-day token quota has been exceeded. Reduce token usage, implement request queuing, or apply for a higher token quota.