Error code - 429 during my first API request

I following all the steps from the Quickstart tutorial. When I ran the python code for my first API request, i got error openai.RateLimitError: Error code: 429.

My usage limit shows, i haven’t made any API request before. I am from India (a country which is supported by openAI for API requests).

please help.

Hi, Did this get resolved? I am facing the same issue.

Hi there - which usage tier are you in and which model did you use for your request?

In case you are not familiar with the concept of usage tiers, have a look here:

https://platform.openai.com/docs/guides/rate-limits/usage-tiers?context=tier-free

If you can share more details, we can point you in the right direction.

Thanks for your response. I am in first tier. I added $10 dollars to my account to start experimenting with the APIs. In the first sample in the documentation, gpt 3.5 model is used. I tried with that and getting this error.
I think I should be eligible for using gpt-4 model also but if I change it to 4 it gives error 404, indicating that I do not have access.
Please guide as I am stuck and cannot proceed.

404 means not found, you probably mistyped the model name. check this page for the models you want to use: https://platform.openai.com/docs/models/overview

you need to copy the model names verbatim. just swapping 3.5 for 4 is generally not going to work.

Hi, I copied as is from the official openai documentation. I am running the code below as is. With 3.5 I am getting error code 429. With GPT-4 I am using model “gpt-4-0125-preview” and getting error 404.

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)

it’s possible that the 429 is the old API key issue - you can try to generate a new one and see if that helps.

404 means that you probably screwed something up in the request. I’d solve the 429 issue first and then come back to this.

It’s always a good idea to take the examples straight and fresh from the docs https://platform.openai.com/docs/api-reference/chat/create?lang=python (you can select the model there too)

and take a closer look at the error response you get. there’s more to it than just a code.

Hi, I created another api key and tried. Getting the same error. sharing more details from execution:

Traceback (most recent call last):
File " /env/openai-test.py", line 4, in
completion = client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_utils/_utils.py", line 275, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/resources/chat/completions.py", line 663, in create
return self._post(
^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 1200, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 889, in request
return self._request(
^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 965, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 1013, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 965, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 1013, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File " /env/lib/python3.12/site-packages/openai/_base_client.py", line 980, in _request
raise self._make_status_error_from_response(err.response) from None
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’}}

what does the right hand side of the usage page look like for you?

https://platform.openai.com/usage

did you set appropriate limits?

https://platform.openai.com/account/limits

I ran a sequence using the make tool and it shows 268 token usage from that run.
I have $120 usage limit for my company. Currently I have $9.83 in my account and used $0.17. This usage is from make tool this and last week.

Sorry, I don’t know how to further help you without taking a look at your account. It’s possible that this is just a transient issue and will go away in a day or two, it’s possible that you may need to talk to help.openai.com, it’s possible that we’re miscommunicating something. Perhaps someone else on this forum has some ideas.

I appreciate all your help. I am able to run script through curl command and external tools like Make. When I create a python script file and trying to execute then it is throwing error. I have also flagged it to OpenAI help but did not receive any response as yet. Will continue to resolve this. Again thanks for your time.

Ah, you know what it could be

Have you restarted the environment/shell after you changed your api key in your environment variables?

I did not re-start the environment but I used the 2nd api key with curl on the same environment and it worked but python script did not work.

Hi Buddy,

I changed the API KEY but forgot to do source ~/.zshrc, now it is working. It was using an old API key that I had set up earlier.

Thanks again

Seeing as I’m facing the same issue as nn5jds8fqf, has there been any new solutions to the aforementioned problem?

A reminder of the problem: I get the following error when trying to make my first API-request:
raise self._make_status_error_from_response(err.response) from None
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’}}

I know I still have tokens left, the $5 you get when opening an account. As I have not yet put additional money, I cannot change any rate limits. The used API-key was made earlier today and has been set as an environment variable. I can confirm it is correct, because when it is changed slightly, the error changes to tell me the key is incorrect.

Thank you in advance for any help.

Hi - OpenAI has discontinued the free tier and you will now need to prepay credits in order to use the API.

See the conversation here for reference:

1 Like

Thank you for the quick response. This was indeed the problem. The fact it says $0 out of $5 on the usage tab is very misleading.

Yeah, the issue is causing quite a bit of confusion at the moment. :frowning:

1 Like