-
Notifications
You must be signed in to change notification settings - Fork 870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this library distinguish 429 - Too many requests
from 429 - Too many tokens
? [question]
#168
Comments
I have absolutely the same bug. I just started to explore this package with my new token. I use latest version of I successfully can use deprecated method |
I am having the same issue, I call: const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{role: "system", content: "You are a legal expert. You understand all the court documents of Florida."},
{role: "user", content: aiPrompt}
],
}); And I get |
Same here, any solution? Always return "To many requests"
|
Seems we are all having the same issue But it's cloudflare that is limiting it
|
If you get a 429 error, you need to retry it with an exponential back off. You can use the package import { backOff } from "exponential-backoff";
function getWeather() {
return fetch("weather-endpoint");
}
async function main() {
try {
const response = await backOff(() => getWeather());
// process response
} catch (e) {
// handle error
}
}
main(); OpenAI official answer for 429 errors:
https://help.openai.com/en/articles/5955604-how-can-i-solve-429-too-many-requests-errors |
For what it's worth; I seem to be geting 429 errors on the first request I've ever sent as a new user (besides two that got 401s). My usage screen on OpenAI seems far from exhausted |
@pixelpax please raise that at https://help.openai.com/ – it's not an SDK issue. |
@nilsreichardt FYI, the upcoming v4 of this library has auto-retry with exponential backoff baked-in. |
The API does distinguish, with a {
message: 'Rate limit reached for 10KTPM-200RPM in organization org-xxxx 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.',
type: 'tokens',
param: null,
code: 'rate_limit_exceeded'
} In the v4 of this SDK, you can access that like so: try {
await client.chat.completions.create(params);
} catch (err) {
if (err instanceof OpenAI.RateLimitError) {
if (err.error.type === 'tokens') {…}
if (err.error.type === 'request') {…}
}
} In the future, we hope to add separate error classes, like |
There is also |
|
I'm going to close this issue as we have an example of accessing this information documented here, though I would still like to add independent classes for each error code at some point. |
Describe the bug
Sorry, not a bug - just a question!
The OpenAI docs stipulate that they enforce rate limits in 2 ways: by request, and by
-- source here
I'm wondering if this library distinguishes by the two. I don't think it does, because here is an error log I ahve for the
429
:Upon confirmation from a maintainer that it doesn't, I will open a feature request requesting this differentiation. Thank you!
P.S. I'd request a 3rd option for issue submission, a new
Question
one, in addition to the currentBug
andFeature request
options.To Reproduce
N/A
Code snippets
OS
mac Ventura (13.0.1)
Node version
16.16
Library version
3.0.0
The text was updated successfully, but these errors were encountered: