I'm seeing surprising behavior with the rate limiter.
I have a script (https://github.com/NickHeiner/jscodemod/blob/nth/ai-batch-no-esm/scripts/openai.bash) that repeatedly calls the API with a 1 second sleep. After 8 calls over 12 seconds, I get an error.
Request 1 at Tue Jan 10 10:48:58 EST 2023
...
Request 8 at Tue Jan 10 10:49:10 EST 2023
{
“error”: {
“message”: “Rate limit reached for default-code-davinci-002 in organization org-uwqDMdROFGWuoV0xmUUaQI8j on requests per min. Limit: 20.000000 / min. Current: 30.000000 / min. Contact support@openai.com if you continue to have issues.“,
“type”: “requests”,
“param”: null,
“code”: null
}
}
The message is a bit surprising to me, because I haven't exceeded 20 calls in a single minute.
Of course, if I were to continue at a rate of "8 calls per 12 seconds" for a full minute, I would make 40 calls. So maybe that's what the API is reacting to? So maybe to abide by the rate limit, I need to stay below a steady-state rate which would result in hitting the rate limit if carried out for a minute?
Update: I tried modifying the "wait time between calls" from 1 to 3 seconds. This results in me getting the same rate limit error as above after 13 calls over 43 seconds. This undermines my theory above, because that's a rate of 18 calls/minute, which seems like is should be fine.
Update 2: I also saw an error with a delay of 4 seconds, resulting in 7 calls over 28 seconds, for a per-minute rate of 15.
I see this behavior with the token count rate limit as well.