You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is a Node library issue and not an underlying OpenAI API issue
This is an issue with the Node library
Describe the bug
I have encountered an issue when handling rate limits. Specifically, when a 429 error occurs, an exception is thrown, and the exception object does not include rate limit headers such as x-ratelimit-reset-requests. This makes it challenging to implement proper retry logic based on the server’s suggested wait times.
This is on the responses.create function, and happens both with and without withResponse()
The exception object does contain some headers, but not the ratelimit headers, e.g.:
Is there a recommended approach to access these headers when a 429 error is thrown? Alternatively, is there a way to prevent the SDK from throwing an exception so that I can inspect the full response, including headers?
Right now my best effort way is to parse the error message that looks like
"Rate limit reached for gpt-4.1 in organization org-anrH4B5v1lvciEaBycvI6qJ4 on tokens per min (TPM): Limit 30000, Used 18271, Requested 16921. Please try again in 10.384s. Visit https://platform.openai.com/account/rate-limits to learn more"
which is obviously really bad practice.
Any guidance on how to handle this scenario effectively would be appreciated.
To Reproduce
create a response using client.responses.create(req), in a for loop so that we can mimic exhausting the rate limit.
see than an exception e is thrown, print JSON.stringify(e)
See there's no way to access rl headers such as x-ratelimit-reset-requests
Code snippets
OS
macOS (but not limited to..)
Node version
Node v22
Library version
openai v4.95.1
The text was updated successfully, but these errors were encountered:
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
I have encountered an issue when handling rate limits. Specifically, when a 429 error occurs, an exception is thrown, and the exception object does not include rate limit headers such as
x-ratelimit-reset-requests
. This makes it challenging to implement proper retry logic based on the server’s suggested wait times.This is on the
responses.create
function, and happens both with and withoutwithResponse()
The exception object does contain some headers, but not the ratelimit headers, e.g.:
Is there a recommended approach to access these headers when a 429 error is thrown? Alternatively, is there a way to prevent the SDK from throwing an exception so that I can inspect the full response, including headers?
Right now my best effort way is to parse the error message that looks like
which is obviously really bad practice.
Any guidance on how to handle this scenario effectively would be appreciated.
To Reproduce
e
is thrown, printJSON.stringify(e)
x-ratelimit-reset-requests
Code snippets
OS
macOS (but not limited to..)
Node version
Node v22
Library version
openai v4.95.1
The text was updated successfully, but these errors were encountered: