Error codes
This guide includes an overview on error codes you might see from both the API and our official Python library. Each error code mentioned in the overview has a dedicated section with further guidance.
API errors
CODE | OVERVIEW |
---|---|
401 - Invalid Authentication | Cause: Invalid Authentication Solution: Ensure the correct API key and requesting organization are being used. |
401 - Incorrect API key provided | Cause: The requesting API key is not correct. Solution: Ensure the API key used is correct, clear your browser cache, or generate a new one. |
401 - You must be a member of an organization to use the API | Cause: Your account is not part of an organization. Solution: Contact us to get added to a new organization or ask your organization manager to invite you to an organization. |
429 - Rate limit reached for requests | Cause: You are sending requests too quickly. Solution: Pace your requests. Read the Rate limit guide. |
429 - You exceeded your current quota, please check your plan and billing details | Cause: You have hit your maximum monthly spend (hard limit) which you can view in the account billing section. Solution: Apply for a quota increase. |
429 - The engine is currently overloaded, please try again later | Cause: Our servers are experiencing high traffic. Solution: Please retry your requests after a brief wait. |
500 - The server had an error while processing your request | Cause: Issue on our servers. Solution: Retry your request after a brief wait and contact us if the issue persists. Check the status page. |
401 - Invalid Authentication
This error message indicates that your authentication credentials are invalid. This could happen for several reasons, such as:
- You are using a revoked API key.
- You are using a different API key than the one assigned to the requesting organization.
- You are using an API key that does not have the required permissions for the endpoint you are calling.
To resolve this error, please follow these steps:
- Check that you are using the correct API key and organization ID in your request header. You can find your API key and organization ID in your account settings.
- If you are unsure whether your API key is valid, you can generate a new one. Make sure to replace your old API key with the new one in your requests and follow our best practices guide.
401 - Incorrect API key provided
This error message indicates that the API key you are using in your request is not correct. This could happen for several reasons, such as:
- There is a typo or an extra space in your API key.
- You are using an API key that belongs to a different organization.
- You are using an API key that has been deleted or deactivated.
- An old, revoked API key might be cached locally.
To resolve this error, please follow these steps:
- Try clearing your browser's cache and cookies, then try again.
- Check that you are using the correct API key in your request header.
- If you are unsure whether your API key is correct, you can generate a new one. Make sure to replace your old API key in your codebase and follow our best practices guide.
401 - You must be a member of an organization to use the API
This error message indicates that your account is not part of an organization. This could happen for several reasons, such as:
- You have left or been removed from your previous organization.
- Your organization has been deleted.
To resolve this error, please follow these steps:
- If you have left or been removed from your previous organization, you can either request a new organization or get invited to an existing one.
- To request a new organization, reach out to us via help.openai.com
- Existing organization owners can invite you to join their organization via the Members Panel.
429 - Rate limit reached for requests
This error message indicates that you have hit your assigned rate limit for the API. This means that you have submitted too many tokens or requests in a short period of time and have exceeded the number of requests allowed. This could happen for several reasons, such as:
- You are using a loop or a script that makes frequent or concurrent requests.
- You are sharing your API key with other users or applications.
- You are using a free plan that has a low rate limit.
To resolve this error, please follow these steps:
- Pace your requests and avoid making unnecessary or redundant calls.
- If you are using a loop or a script, make sure to implement a backoff mechanism or a retry logic that respects the rate limit and the response headers. You can read more about our rate limiting policy and best practices in our rate limit guide.
- If you are sharing your organization with other users, note that limits are applied per organization and not per user. It is worth checking on the usage of the rest of your team as this will contribute to the limit.
- If you are using a free or low-tier plan, consider upgrading to a pay-as-you-go plan that offers a higher rate limit. You can compare the restrictions of each plan in our rate limit guide.
429 - You exceeded your current quota, please check your plan and billing details
This error message indicates that you have hit your maximum monthly spend for the API. You can view your maximum monthly limit, under ‘hard limit’ in your [account billing settings](/account/billing/limits). This means that you have consumed all the credits allocated to your plan and have reached the limit of your current billing cycle. This could happen for several reasons, such as:
- You are using a high-volume or complex service that consumes a lot of credits or tokens.
- Your limit is set too low for your organization’s usage.
To resolve this error, please follow these steps:
- Check your current quota in your account settings. You can see how many tokens your requests have consumed in the usage section of your account.
- If you are using a free plan, consider upgrading to a pay-as-you-go plan that offers a higher quota.
- If you need a quota increase, you can apply for one and provide relevant details on expected usage. We will review your request and get back to you in ~7-10 business days.
429 - The engine is currently overloaded, please try again later
This error message indicates that our servers are experiencing high traffic and are unable to process your request at the moment. This could happen for several reasons, such as:
- There is a sudden spike or surge in demand for our services.
- There is scheduled or unscheduled maintenance or update on our servers.
- There is an unexpected or unavoidable outage or incident on our servers.
To resolve this error, please follow these steps:
- Retry your request after a brief wait. We recommend using an exponential backoff strategy or a retry logic that respects the response headers and the rate limit. You can read more about our rate limit best practices.
- Check our status page for any updates or announcements regarding our services and servers.
- If you are still getting this error after a reasonable amount of time, please contact us for further assistance. We apologize for any inconvenience and appreciate your patience and understanding.
Python library error types
TYPE | OVERVIEW |
---|---|
APIError | Cause: Issue on our side. Solution: Retry your request after a brief wait and contact us if the issue persists. |
Timeout | Cause: Request timed out. Solution: Retry your request after a brief wait and contact us if the issue persists. |
RateLimitError | Cause: You have hit your assigned rate limit. Solution: Pace your requests. Read more in our Rate limit guide. |
APIConnectionError | Cause: Issue connecting to our services. Solution: Check your network settings, proxy configuration, SSL certificates, or firewall rules. |
InvalidRequestError | Cause: Your request was malformed or missing some required parameters, such as a token or an input. Solution: The error message should advise you on the specific error made. Check the documentation for the specific API method you are calling and make sure you are sending valid and complete parameters. You may also need to check the encoding, format, or size of your request data. |
AuthenticationError | Cause: Your API key or token was invalid, expired, or revoked. Solution: Check your API key or token and make sure it is correct and active. You may need to generate a new one from your account dashboard. |
ServiceUnavailableError | Cause: Issue on our servers. Solution: Retry your request after a brief wait and contact us if the issue persists. Check the status page. |
APIError
An `APIError` indicates that something went wrong on our side when processing your request. This could be due to a temporary error, a bug, or a system outage.
We apologize for any inconvenience and we are working hard to resolve any issues as soon as possible. You can check our system status page for more information.
If you encounter an APIError, please try the following steps:
- Wait a few seconds and retry your request. Sometimes, the issue may be resolved quickly and your request may succeed on the second attempt.
- Check our status page for any ongoing incidents or maintenance that may affect our services. If there is an active incident, please follow the updates and wait until it is resolved before retrying your request.
- If the issue persists, check out our Persistent errors next steps section.
Our support team will investigate the issue and get back to you as soon as possible. Note that our support queue times may be long due to high demand. You can also post in our Community Forum but be sure to omit any sensitive information.
Timeout
A `Timeout` error indicates that your request took too long to complete and our server closed the connection. This could be due to a network issue, a heavy load on our services, or a complex request that requires more processing time.
If you encounter a Timeout error, please try the following steps:
- Wait a few seconds and retry your request. Sometimes, the network congestion or the load on our services may be reduced and your request may succeed on the second attempt.
- Check your network settings and make sure you have a stable and fast internet connection. You may need to switch to a different network, use a wired connection, or reduce the number of devices or applications using your bandwidth.
- If the issue persists, check out our persistent errors next steps section.
RateLimitError
A `RateLimitError` indicates that you have hit your assigned rate limit. This means that you have sent too many tokens or requests in a given period of time, and our services have temporarily blocked you from sending more.
We impose rate limits to ensure fair and efficient use of our resources and to prevent abuse or overload of our services.
If you encounter a RateLimitError, please try the following steps:
- Send fewer tokens or requests or slow down. You may need to reduce the frequency or volume of your requests, batch your tokens, or implement exponential backoff. You can read our Rate limit guide for more details.
- Wait until your rate limit resets (one minute) and retry your request. The error message should give you a sense of your usage rate and permitted usage.
- You can also check your API usage statistics from your account dashboard.
APIConnectionError
An `APIConnectionError` indicates that your request could not reach our servers or establish a secure connection. This could be due to a network issue, a proxy configuration, an SSL certificate, or a firewall rule.
If you encounter an APIConnectionError, please try the following steps:
- Check your network settings and make sure you have a stable and fast internet connection. You may need to switch to a different network, use a wired connection, or reduce the number of devices or applications using your bandwidth.
- Check your proxy configuration and make sure it is compatible with our services. You may need to update your proxy settings, use a different proxy, or bypass the proxy altogether.
- Check your SSL certificates and make sure they are valid and up-to-date. You may need to install or renew your certificates, use a different certificate authority, or disable SSL verification.
- Check your firewall rules and make sure they are not blocking or filtering our services. You may need to modify your firewall settings.
- If appropriate, check that your container has the correct permissions to send and receive traffic.
- If the issue persists, check out our persistent errors next steps section.
InvalidRequestError
An InvalidRequestError indicates that your request was malformed or missing some required parameters, such as a token or an input. This could be due to a typo, a formatting error, or a logic error in your code.
If you encounter an InvalidRequestError, please try the following steps:
- Read the error message carefully and identify the specific error made. The error message should advise you on what parameter was invalid or missing, and what value or format was expected.
- Check the API Reference for the specific API method you were calling and make sure you are sending valid and complete parameters. You may need to review the parameter names, types, values, and formats, and ensure they match the documentation.
- Check the encoding, format, or size of your request data and make sure they are compatible with our services. You may need to encode your data in UTF-8, format your data in JSON, or compress your data if it is too large.
- Test your request using a tool like Postman or curl and make sure it works as expected. You may need to debug your code and fix any errors or inconsistencies in your request logic.
- If the issue persists, check out our persistent errors next steps section.
AuthenticationError
An `AuthenticationError` indicates that your API key or token was invalid, expired, or revoked. This could be due to a typo, a formatting error, or a security breach.
If you encounter an AuthenticationError, please try the following steps:
- Check your API key or token and make sure it is correct and active. You may need to generate a new key from the API Key dashboard, ensure there are no extra spaces or characters, or use a different key or token if you have multiple ones.
- Ensure that you have followed the correct formatting.
ServiceUnavailableError
A `ServiceUnavailableError` indicates that our servers are temporarily unable to handle your request. This could be due to a planned or unplanned maintenance, a system upgrade, or a server failure. These errors can also be returned during periods of high traffic.
We apologize for any inconvenience and we are working hard to restore our services as soon as possible.
If you encounter a ServiceUnavailableError, please try the following steps:
- Wait a few minutes and retry your request. Sometimes, the issue may be resolved quickly and your request may succeed on the next attempt.
- Check our status page for any ongoing incidents or maintenance that may affect our services. If there is an active incident, please follow the updates and wait until it is resolved before retrying your request.
- If the issue persists, check out our persistent errors next steps section.
Persistent errors
If the issue persists, contact our support team via chat and provide them with the following information:
- The model you were using
- The error message and code you received
- The request data and headers you sent
- The timestamp and timezone of your request
- Any other relevant details that may help us diagnose the issue
Our support team will investigate the issue and get back to you as soon as possible. Note that our support queue times may be long due to high demand. You can also post in our Community Forum but be sure to omit any sensitive information.
Handling errors
We advise you to programmatically handle errors returned by the API. To do so, you may want to use a code snippet like below:
try:
#Make your OpenAI API request here
response = openai.Completion.create(prompt="Hello world",
model="text-davinci-003")
except openai.error.APIError as e:
#Handle API error here, e.g. retry or log
print(f"OpenAI API returned an API Error: {e}")
pass
except openai.error.APIConnectionError as e:
#Handle connection error here
print(f"Failed to connect to OpenAI API: {e}")
pass
except openai.error.RateLimitError as e:
#Handle rate limit error (we recommend using exponential backoff)
print(f"OpenAI API request exceeded rate limit: {e}")
pass