Rate limit.
Recommend adding current limiting function.
This is error.
openai.error.RateLimitError: Rate limit reached for 10KTPM-200RPM in organization org-xxxxxxx on tokens per min. Limit: 10000 / min. Please try again in 6ms. Contact us through our help center at help.openai.com if you continue to have issues.
rate limit refer to https://github.com/geekan/MetaGPT/blob/main/metagpt/provider/openai_api.py
Thank you. We will check it out. By the way, in our test we haven't met this rate limit error, is it because some kinds of batch running in your scenario?
I am hitting the rate limit error too. I was using my GPT_4 API key. I tried the 32K version and got a different error. No batch script, just running from from inside VsCode terminal/windows 11.
"python run.py --task "write a me this example program" --name "Example Name" --model 'GPT_4'
Tracebacks below.
GPT 4 Traceback
[OpenAI_Usage_Info Receive] prompt_tokens: 453 completion_tokens: 74 total_tokens: 527
Traceback (most recent call last): File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\tenacity_init_.py", line 382, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\ChatDev\camel\utils.py", line 145, in wrapper return func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\ChatDev\camel\agents\chat_agent.py", line 191, in step response = self.model_backend.run(messages=openai_messages) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\ChatDev\camel\model_backend.py", line 69, in run response = openai.ChatCompletion.create(*args, **kwargs, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create return super().create(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create response, _, api_key = requestor.request( ^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 298, in request resp, got_stream = self._interpret_response(result, stream) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response self._interpret_response_line( File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 763, in _interpret_response_line raise self.handle_error_response( openai.error.RateLimitError: Rate limit reached for 10KTPM-200RPM in organization org-PcnGPHPM8C05nx9hV0x7Wie6 on tokens per min. Limit: 10000 / min. Please try again in 6ms. Contact us through our help center at help.openai.com if you continue to have issues.
GPT4 32K TRACEBACK
"python run.py --task "write a me this example program" --name "Example Name" --model 'GPT_4_32K'
Traceback (most recent call last):
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\tenacity_init_.py", line 382, in call
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\ChatDev\camel\utils.py", line 145, in wrapper
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\ChatDev\camel\agents\chat_agent.py", line 191, in step
response = self.model_backend.run(messages=openai_messages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\ChatDev\camel\model_backend.py", line 69, in run
response = openai.ChatCompletion.create(*args, **kwargs,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response
self._interpret_response_line(
File "H:\PROGRAMS\chatdev\venv\Lib\site-packages\openai\api_requestor.py", line 763, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: The model gpt-4-32k 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.
refer to this page for rate limits https://platform.openai.com/account/rate-limits
Thank you. We will check it out.
By the way, in our test we haven't met this rate limit error, is it because some kinds of batch running in your scenario?
As they said, this problem occurs when using the GPT4 model.
refer to this page for rate limits https://platform.openai.com/account/rate-limits
Is this a joke? I understand what rate limits are. I am trying to use Open Interpreter with a gpt4 api key and I cannot because there is no functionality that allows for waiting the required amount of time and or working around the limit in some other way.
FORK THE Repo
Change the code to use v2 completion endpoint May fix the issue
I get the same error. Works fine with GPT3.5 but if I try GPT4 it crashes to: openai.error.RateLimitError: Rate limit reached for 10KTPM-200RPM
I get the same error. Works fine with GPT3.5 but if I try GPT4 it crashes to:
openai.error.RateLimitError: Rate limit reached for 10KTPM-200RPM
I followed the example using Tenacity here, and I was able to limit the requests made to the GPT-4 endpoints. I'll need to dial in the variables, but it works out the gate without any modifications. https://platform.openai.com/docs/guides/rate-limits/error-mitigation
also experiencing this issue using GPT4. is there somewhere in the code where i can add a rate limit or adjust how requests are sent to the API so that i can run this and ensure rate limit isn't reached so my project can complete? i prefer to use GPT4 because 1. i have access and 2. it seems to perform better, particularly with coding, from my experience.
also experiencing this issue using GPT4. is there somewhere in the code where i can add a rate limit or adjust how requests are sent to the API so that i can run this and ensure rate limit isn't reached so my project can complete? i prefer to use GPT4 because 1. i have access and 2. it seems to perform better, particularly with coding, from my experience.
Hi @tbels89, If you follow the link in my comment above, you can see an example that uses the Tenacity library. The examples that are there need to be tweaked because it backs off quite aggressively, but it was working well for me.
Hi @tbels89, If you follow the link in my comment above, you can see an example that uses the Tenacity library. The examples that are there need to be tweaked because it backs off quite aggressively, but it was working well for me.
@sjetha i had a look but i'm not sure where in the program to put the tenacity. what file(s) did you modify to get this working? can you show an example of your implementation? i'm still pretty new to this and trying to figure it all out.
Can some one show an example code or tell how to fix it?
Can some one show an example code or tell how to fix it?
You can add sleep code in the request openai API.
@sjetha thanks for the tenacity suggestion. i was able to implement and using gpt4. i reviewed the log and it did have some rate limit hits, but because of the retry, never killed the process and chatdev was able to complete the task (not exactly what i was hoping it would output, but at least not hitting rate limits). for everyone wondering, here's what i did:
file: chatdev-main/camel/model_backend.py
import: from tenacity import retry, wait_exponential
under the OpenAIModel class, just above the run function, i added the following line of code: @retry(wait=wait_exponential(multiplier=0.02, max=20))
Why has this been closed? it never works for me - always errors for GPT 4 - I fought hard to get access :)
Why has this been closed? it never works for me - always errors for GPT 4 - I fought hard to get access :)
quote your api_key in your code
Like @sakher mentioned, add his code and mess with variables. I added:
@retry(wait=wait_exponential(min=1, max=60)) above the OpenAIModel class and my issues were fixed (using 3.5 turbo)
Still facing rate limit error with GPT-4. Any confirmed fix?
For those doing a direct copy and paste of @tbels89 suggested modification, I believe the 'R' in @Retry should be lower case, i.e., @retry(...)
Edit: comments automatically capitalise the letter following '@' so '@ retry(...)' without space