All posts
Rate limits and how to handle them
Engineering 7 min read· Aug 2, 2026· By Engineering

Rate limits and how to handle them

Backoff, jitter, queueing, and the difference between provider limits and TokenRex limits.

Rate limits protect the upstream provider. TokenRex passes them through unchanged so your existing retry code just works.

The right retry#

python
for attempt in range(5):
    try:
        return client.chat.completions.create(...)
    except RateLimitError:
        time.sleep((2 ** attempt) + random.random())

Global queueing#

For batch workloads, cap concurrent in-flight requests with a semaphore rather than retrying blindly. See batch inference at scale.

Ready to build?

Grab a key, keep your OpenAI SDK, and pay only for what you use.

Start free