Skip to Content
Konduit docs

Rate limits

What is counted, what a 429 looks like, and how to back off without guessing.

konduit enforces two limits, on two scopes:

LimitCounted per
Requests per minuteyour API key, and your organisation
Tokens per minuteyour API key, and your organisation

Both apply to the same request, so a request passes only if the key's buckets and the organisation's have room. Both windows are one minute.

Per-key limits are a property of the key and are set in the console; the organisation limits are a ceiling across every key it owns. A limit that is not configured is not enforced — it is never read as "zero per minute".

How tokens are counted

The requests bucket is charged when a request is admitted. The tokens bucket is different, and the difference matters:

  1. At admission, konduit checks that the tokens bucket still has credit. It does not know yet what the request will cost.
  2. After the response, konduit charges the bucket with the provider's own token count — the same number it bills from.

So a single very large request is never rejected for its size by the tokens-per-minute limit; it is charged for afterwards and the next requests feel it. konduit never charges the bucket from a locally computed estimate, because the counts it bills from are the provider's and there is no second version of them.

A request whose token counts never arrived — a stream you disconnected from, a provider that ignored konduit's request for usage — charges nothing against the bucket. It is recorded for reconciliation instead.

A transcription is billed in seconds of audio and has no token count, so it charges nothing against the tokens bucket. It still counts against the requests bucket, and is still refused at admission once the tokens bucket is empty.

What a 429 looks like

HTTP/1.1 429 Too Many Requests
Retry-After: 12
Content-Type: application/json
{
  "error": {
    "message": "the requests-per-minute limit for this API key was reached; retry after the delay in the Retry-After header",
    "type": "rate_limit_exceeded",
    "param": null,
    "code": "rate_limit_exceeded"
  }
}

The message names which of the four buckets was hit, because the fix differs: slowing one process down is not the same as buying a bigger plan.

MessageWhich bucket
the requests-per-minute limit for this API key was reached; …key, requests
the tokens-per-minute limit for this API key was reached; …key, tokens
the requests-per-minute limit for this organisation was reached; …organisation, requests
the tokens-per-minute limit for this organisation was reached; …organisation, tokens

`code` equals `type` here, and that is not a mistake

rate_limit_exceeded is what OpenAI sends as the code, and it is the field their SDKs branch on. konduit spells it the same way so that an existing back-off implementation keeps working.

Backing off

Read Retry-After. It is present on every 429 konduit answers, whether the limit was konduit's or a provider's, and it is never below 1. On konduit's own limit it is an integer number of seconds and it is konduit's answer to "when will this bucket have room", so a client that honours it is not guessing. On a provider's limit it is whatever that provider sent — which may also be an HTTP date, since both spellings are valid — falling back to 1 when the provider named nothing.

import time
from openai import OpenAI, RateLimitError

client = OpenAI(base_url="https://api.konduit.eu/v1", api_key=key)

for attempt in range(5):
    try:
        completion = client.chat.completions.create(model=model, messages=messages)
        break
    except RateLimitError as error:
        delay = error.response.headers.get("retry-after")
        time.sleep(int(delay) if delay else 2 ** attempt)

There are no X-RateLimit-* or RateLimit-* headers. konduit does not publish remaining-quota headers, so there is nothing to poll and nothing to misread — the only signal is the 429 and its Retry-After.

Two kinds of 429

This is the distinction the upstream_ convention exists for. Both are 429 with type: rate_limit_exceeded, and only the code tells them apart:

codeWho refusedWhat helps
rate_limit_exceededkonduit — your key's or your organisation's limit.A larger limit. Waiting only helps until the next minute.
upstream_rate_limitedThe provider konduit routed to — it is out of capacity.Waiting. Retry-After carries the provider's own value, or konduit's floor of 1 when the provider named none.

Branch on code, not on the status. Treating konduit's limit as a provider outage means backing off from a queue that will never drain; treating a provider outage as your own limit means asking for a bigger plan that changes nothing.

konduit tries the alternatives first

An upstream_rate_limited reaching you means every eligible deployment refused, not just the first one — konduit falls back to the next candidate before it answers. A retry is still worth having, but an immediate one will not find a healthy provider konduit missed a moment ago.

Staying under the limit

  • One key per workload. Limits are per key, so a batch job and an interactive product sharing one key will starve each other; two keys make the limits mean what you set them to.
  • Bound your concurrency rather than firing everything and retrying. A request that is refused still costs a round trip.
  • Debounce autocomplete. An editor that asks for a completion on every keystroke counts every one of them against these same limits, and a request abandoned for the next keystroke is still paid for. Wait for the typing to pause.
  • Cap max_completion_tokens when you can — see below for why it matters more than it looks.

Reservations, and why max_completion_tokens matters

This is not a rate limit, but it is the other thing that can refuse a request you expected to go through, so it belongs next to them.

Before konduit asks any provider, it reserves credit for what the request could cost. That reservation is the prompt, estimated from the request's size, plus the completion ceiling at the deployment's output price — and it is sized against the most expensive deployment the request might fall back to, because a fallback is exactly the case where the bill moves.

The completion ceiling is where the surprise is:

You sentkonduit reserves for
max_completion_tokens (or max_tokens, the only spelling on text and code completions)that number
neither, on a deployment with a published max_output_tokensthat number
neither, on a deployment without oneits whole context window
an embeddings request, whatever it sentnothing: an embedding has no completion
a transcriptionno tokens at all: the per-request ceiling below, because an upload's size does not say how long its audio runs

Asking for several choices with n multiplies the completion part: each choice is a completion the provider generates and bills, so n: 4 reserves four times the ceiling above. The installation's per-request reservation limit (below) clamps only a request for one choice. A request for several whose whole reservation would exceed it is refused with 400 invalid_request before anything is reserved, because the limit bounds what is reserved, not what is charged. That includes a request that sends no max_tokens to a deployment whose ceiling is its whole context window: set or lower max_tokens, or lower n (or best_of).

No ceiling on a large-context model reserves a lot

A request that names no ceiling against a 128k-context deployment is reserved as if it might generate 128k tokens. The reservation is released or settled down to what the request actually cost the moment it finishes, so you are never charged for it — but while it is open it is credit you cannot spend, and a balance that comfortably covers the real generation can still produce a 402 insufficient_balance.

Sending max_completion_tokens is the fix, and it is a one-line one. An installation may also configure a per-request ceiling that caps every reservation regardless; if yours does, this cannot happen, and if you are seeing it, it does not.

The estimate never becomes a charge. Prompt size is guessed from the request's length in bytes and deliberately over-counts; what you are billed comes only from the provider's own token counts, and the difference goes back to your balance on settle.

On this page