To get your keys you need to log in with you credentials to the URL https://platform.openai.com/api-keys
There can be various reasons why the Openai API key doesn’t work
- API KEY found Publicly: You should not share your API key with anyone or reveal it in your browser or code. OpenAI takes security seriously and may disable any leaked API keys to safeguard your account if found in public domain.
- Check API Key: Double-check that you have entered the correct API key. This generally happens when you copy and paste and some extra space or junk characters come over. try first pasting the key to a text editor like Notepad and again copy it over to the required form or application.
- Changed Keys: Sometimes you change the API key but miss out on updating the keys in the existing applications. this can cause failure.
- Subscription Status: This is pretty straightforward but sometimes you may have not paid the bill and your subscription to the OpenAI API is disabled. If your subscription has lapsed or there are issues with your payment for example from the bank end this can happen.
- Organization – Check the organization you are added to has access to the API key.
- Usage Limits: If you are under trial edition you have $5 budget. Check if you exhausted your API usage limits. Also, OpenAI sets certain usage limits based on your subscription plan, and your API access may be suspended if you violate the plan conditions.
- Quota Exceeded: Confirm that you have not exceeded your request quota. Each API key has a limit on the number of requests it can make within a specific timeframe. If you exceed this limit, your API key may be temporarily disabled.
- Rate Limiting: In case you are doing some automation or exposing an application that call the open ai API from the internet check that the traffic is not making requests too quickly. If you send too many requests in a short period, you may hit rate limits, and your API key could be temporarily disabled.
- Check for Service Outages: Sometimes, there may be issues on the OpenAI server side. Check OpenAI’s status page or their support channels to see if there are any ongoing outages or maintenance that might be affecting the API.
- Contact OpenAI Support: If none of the above steps resolve the issue, it’s recommended to contact OpenAI support directly. They can provide specific assistance and investigate any issues with your API key.
Check the Error codes for open ai API here