I have a paid account at tier 1 level. It has a balance of $9 currently. I am not able to execute python code that is using OpenAI APIs. I am getting the following error when I use 3.5 model.
openai.RateLimitError: Error code: 429 - {‘error’: {‘message’: ‘You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.’, ‘type’: ‘insufficient_quota’, ‘param’: None, ‘code’: ‘insufficient_quota’}}
Code that I am trying to run:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model=“gpt-3.5-turbo”,
messages=[
{“role”: “system”, “content”: “You are a poetic assistant, skilled in explaining complex programming concepts with creative flair.”},
{“role”: “user”, “content”: “Compose a poem that explains the concept of recursion in programming.”}
]
)
print(completion.choices[0].message)
If I curl an API it works. If I use my OpenAI account with an external tool like Make it works. Please help as I am not able to proceed with my learnings.
I should also be able to use GPT 4 model also but when I use that it gives the following error:
openai.NotFoundError: Error code: 404 - {‘error’: {‘message’: ‘The model gpt-4 does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘model_not_found’}}
It sounds like you have an API that has no balance and has never been unlocked for GPT-4 by having paid money.
This can happen if you pick the wrong organization in your platform.openai.com account.
On that page, click your name lower left, and see that there may be an organization you named previously, and one added by OpenAI called “personal”.
Ensure the one that has funds is the one selected. Then go immediately to API Keys and generate a new key. Ensure that key is used in the environment variable of the OS, the settings of the virtual environment you are using, and can be reproduced by test code.
The correct organization should also have access to GPT-4 models in the API playground.
Hi, Thanks for responding.
I have only one organisation configured. It is named Personal and has a id in the settings.
I have $9.83 in this account.
I created a new API key. I have 2 API keys now. I tried both. Same error.
I have access to all models in the playground.
When I am executing python code at the terminal somehow it is not able to get the status of my account. The code is using a valid API key else I would have got a different error I suppose.
The OpenAI client will use the API key that has been set as an environment variable in the operating system as its primary method. The name of the env variable is OPENAI_API_KEY.
You can open the “IDLE” Python IDE that comes with a normal Python install, to get a console, then:
from openai import OpenAI
client = OpenAI()
print(client.api_key)
(you also can save this as a .py file to check how other files are executed)
This will reveal the API key that is going to be used by the environment.
If you cannot immediately discover where the API key has previously been set in the OS (maybe by following some tutorial earlier), you can temporarily set the key in your code:
client = OpenAI(api_key = ‘sk-1234’)
Which is not a best-practice. Hopefully it is a mix-up, easily discovered, that can be explained by the things I’ve written so far, and not a deeper problem with the account.