Why x-ratelimit-reset-requests time is so small and what is its significance?

In my application I want add checker to avoid rate limits. I understand x-ratelimit-limit-requests and x-ratelimit-remaining-requests parameters. But confused about x-ratelimit-reset-requests. Does it mean the limiter is going to be reset in 12 miliseconds(for following response header)?

x-ratelimit-limit-requests: 5000
x-ratelimit-limit-tokens: 160000
x-ratelimit-limit-tokens_usage_based: 160000
x-ratelimit-remaining-requests: 4999
x-ratelimit-remaining-tokens: 159976
x-ratelimit-remaining-tokens_usage_based: 159976
x-ratelimit-reset-requests: 12ms
x-ratelimit-reset-tokens: 9ms
x-ratelimit-reset-tokens_usage_based: 9ms
1 Like

The time until the rate limit (based on requests) resets to its initial state.


A unique and still undisclosed formula is used. 12ms means that after 12ms there will be no memory of your API call counting against you if you make no others.

However, cumulative calls within a period are a bit more tricky, will make that reported period grow, and the reset has little value to you then.

If you are going to be approaching the limit, for example, for a batch job, a good policy to write is to have a FIFO buffer, where you record the counts, tokens, and timestamps, and don’t expire the calls from that record until the period of its evaluation time is up. Then you total that unexpired pool and see if it is near exceeding your given limit, and hold off on more submissions until the last would exit.