Graceful backoff on rate limits
Resolved 💬 16 comments Opened Apr 16, 2025 by RamXX Closed Apr 29, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator)
responded on this thread — see the highlighted reply below.
It's normal to hit rate limits, but the current behavior of codex is to basically crash and abort everything in flight:
[Error]: Rate limit reached for gpt-4.1 in organization org-abcxyz on tokens per min (TPM): Limit 450000,
Used 368526, Requested 91276. Please try again in 1.306s.
A better behavior would be to take that output, and retry 1.4 seconds later with exponential backoff. Furthermore, given the limits are well-known, an even better behavior would be to display tokens left (or %) and have the CLI be aware enough to influence the AI behavior. For example, at 95% write a plan for a next session, etc.
16 Comments
Latest version should back-off for 15s and retry. Please upgrade and let me know if you still see this issue.
Built from source with latest pull and still observing rate limit crashes:
There is no sign of 15s backoff in the output.
Could you check from source again, after https://github.com/openai/codex/pull/153. Thx!
I haven't seen the error again since the last time I updated about an hour ago, but I'm not pushing it that hard at the moment... others may chime in. Thanks for the prompt response! (no pun intended 😉 )
I just tested this on the latest
main(post-#153) by installing from source:I’m still seeing immediate CLI exit on token rate limits with no retry behavior. Example:
So either the retry logic isn’t wired up yet, or it’s not catching this case. Happy to help debug further if needed.
Cheers
I still get hit by rate limits as well, crashes and does not know where to resume, so I have to run all instructions again...
[Error]: Rate limit reached for o4-mini in organization org-BRZky604OkacepMUlEb9lq1i on tokens per min (TPM): Limit 200000, Used 148977, Requested 55092. Please try again in 1.22s. Visit https://platform.openai.com/account/rate-limits to learn more.
at e.a [as iterator] (file:///Users/XXX/local/codex/codex-cli/dist/cli.js:375:1514)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async E0.run (file:///Users/XXX/local/codex/codex-cli/dist/cli.js:392:2925) {
status: undefined,
headers: undefined,
request_id: undefined,
error: {
type: 'tokens',
code: 'rate_limit_exceeded',
message: 'Rate limit reached for o4-mini in organization org-BRZky604OkacepMUlEb9lq1i on tokens per min (TPM): Limit 200000, Used 148977, Requested 55092. Please try again in 1.22s. Visit https://platform.openai.com/account/rate-limits to learn more.',
param: null
},
code: 'rate_limit_exceeded',
param: null,
type: 'tokens'
}
Node.js v22.14.0
codex --version
0.1.2504161510
Getting the same error
Codex version: 0.1.2504161551
``` bash
[Error]: Rate limit reached for gpt-4.1 in organization org-5MFShhFqaGV0OkehheyElBcz on tokens per min (TPM): Limit 30000, Used 26407, Requested 15377. Please try again in 23.568s. Visit https://platform.openai.com/account/rate-limits to learn more.
at e.a [as iterator] (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:445:1514)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async R0.run (file:///opt/homebrew/lib/node_modules/@openai/codex/dist/cli.js:462:2639) {
status: undefined,
headers: undefined,
request_id: undefined,
error: {
type: 'tokens',
code: 'rate_limit_exceeded',
message: 'Rate limit reached for gpt-4.1 in organization org-5MFShhFqaGV0OkehheyElBcz on tokens per min (TPM): Limit 30000, Used 26407, Requested 15377. Please try again in 23.568s. Visit https://platform.openai.com/account/rate-limits to learn more.',
param: null
},
code: 'rate_limit_exceeded',
param: null,
type: 'tokens'
}
Node.js v23.11.0
same here!
See also:
This is unacceptable behavior of this system. It should have inherently been built with cooldown.
Now I have no option but to wait 7 days (after my first purchase) to get the access I need (if that's even enough). It's such an annoyance and hindrance to my workflow I decided on, and thought I could use, that I want to call, dispute all charges to OpenAI with my bank as a scamming service, and close out and move to services with same features, but bypass all rate limits and token limits with unlimited packages with their own API keys to OpenAI.
I had been using o4 for days no on Windsurf without any rate limit issues, and it's cheaper by leaps and bounds. Insane.
Ok. It seems that I then need to stop using Codex until OpenAI fixes this.
I reached the daily limit of 200 requests (yes, I just signed up) on 4.1-mini. And this was like my second promt. It worked for 15 minutes and then crashed. 🤦♂️ Totally useless tool as it can only waste my money and do nothing.
This was fixed a while ago, please ensure that you are running the latest version here: https://github.com/openai/codex/blob/main/CHANGELOG.md#012504251709
You should see
Just got that error again.
Signed up 200/month to try gpt5 . 30k tokens per minute ? .... that means the context window isn't 400k like advertised.... it's 30k....
Thank God for claude
Codex as of yesterday still completely crashes and burns when hitting 30k limit, requiring complelty starting new chat.
@tibo-openai
🖐 stream disconnected before completion: Rate limit reached for gpt-5 in organization org-xxxx on tokens per min (TPM): Limit 30000, Used 23332, Requested 15275. Please try again in 17.214s. Visit https://platform.openai.com/account/rate-limits to learn more.
codex-cli 0.21.0