Token and request limits
A Meadow API key can carry two limits: max_requests and max_tokens. Both are lifetime totals for that key unless you set limit_reset. When a key reaches a limit, raise that limit with PATCH /v1/keys/{key_id} or create a new one.
Next step: if you set max_tokens on a key, add an output token limit to every request that key makes. Without one the request is rejected.
A key can also carry a limit in US dollars, limit. See Spend limits.
Meadow also applies a maximum request size to every key. It sets no fixed number of requests in flight per key or per account: see A busy server and retry-after.
Set a limit
Limits are set when a key is created, with an admin key. Authentication covers key creation in full.
Things to know before you rely on a limit:
- Limits cover the key’s whole life unless you set
limit_resettodaily,weeklyormonthly. Then both counters go back to zero at midnight UTC, on Monday at midnight UTC, or on the first of the month at midnight UTC. GET /v1/keyreturns the calling key withrequests_used,tokens_used,requests_remainingandtokens_remaining. Any key can call it. See Authentication.PATCH /v1/keys/{key_id}changes a limit or the reset period on a live key. The counters stay. See Authentication.- A key created by a limited key must state the same limit, at or below its parent’s. Its use counts against itself and against every key above it. The rejection does not say which key in the chain ran out. See Authentication.
- A rejection for a spent limit is a 403, not a 429. On the model routes
error.typeis the provider’s:invalid_request_errorin OpenAI’s envelope,permission_erroron/v1/messages. Do not retry it.error.codeiskey_request_limit_exceededorkey_token_limit_exceeded, so the code can tell a spent key from a missing scope. When the limit is on the key you called with, its message also says how much is used:api key max_tokens limit reached: 1434 of 200 tokens used on this key; .... A rejected reservation lists tokens used of the limit, tokens held by calls in flight, and what the request reserves. When the limit that stopped the call belongs to a key above yours, the message carries no numbers and no key ID. Branch onerror.code, not on the text.
The request limit
max_requests counts calls that a provider served. The call after the last one allowed is rejected:
After PATCH /v1/keys/{key_id} with {"max_requests": 3} the same call was served again.
Calls that fail are not counted. On a key with max_requests: 1, a request Meadow rejected (400), a request the provider rejected (400), and a route where every provider failed (502) left the limit untouched, and the next good call was served. The exception is an abandoned call, below.
The token limit
max_tokens on a key limits the total input and output tokens across its calls.
The reservation rule
Meadow cannot know what a call will use until the provider answers. So before it forwards a request on a token-limited key, it reserves an estimate:
The request is rejected with a 403 when tokens already used, plus reservations of calls still in flight, plus this reservation, would pass the limit. When the provider answers, Meadow charges the usage the provider reported and drops the reservation.
This key has max_tokens: 1000. The request is 124 bytes (42 tokens by the estimate) and asks for up to 1000 output tokens:
The same request with "max_tokens": 100 reserves 141, fits, and is charged the 14 tokens the provider reported.
So a key can be rejected while its used tokens are still well under the limit. Do: keep output token limits close to what you need. A cap of 4096 on every call makes each call hold 4096 tokens of the budget while it runs.
Tools that set the cap for you can ask for far more than you expect. Claude Code reserved about 145,000 tokens per call until its cap was lowered. See Claude Code on a key with a token limit.
Why the output token limit is required
Meadow forwards your body unchanged. A request with no output token limit lets the provider generate up to the model’s own maximum, and Meadow would have nothing to reserve. So on a key with max_tokens, its own or a parent’s, every request must carry a cap the format honors:
Without one:
That body was captured before a missing cap got its own code (see the 2026-11-24 section of the changelog). The same call now returns "param":"max_completion_tokens" and "code":"parameter_missing", with the same message. Read from the server’s code. Not run again on the hosted beta.
The cap must be a positive whole number. These are the refusals, all 400:
A cap sent as null counts as absent.
What is charged
On streamed Chat Completions calls Meadow asks the provider for the token count on every stream. You get a usage chunk only if you sent stream_options: {"include_usage": true}.
An open stream keeps its reservation until it ends. Streaming shows a dropped stream being charged its full reservation of 848 tokens when 280 had been generated.
The limit can be passed
The reservation is an estimate, and the charge is what the provider reports. When the provider counts more than the estimate, the key ends above its limit, and only the next request is rejected.
This happened in testing. A key had max_tokens: 200. One call to grok-4.7 with "max_tokens": 64 reserved about 100 tokens and was served. xAI reported 1,347 tokens: it counts about 1,250 prompt tokens of its own on every call, and its reasoning tokens are not held by the cap. The key was charged 1,347, almost seven times its limit. The next call was rejected:
The same happens when a request points at content the body does not contain: previous_response_id, or files and images by URL or ID.
This is by design: the budget is checked against an estimate before the call, the call that passes it is served in full, and every later call is rejected. There is no minimum budget: neither OpenRouter nor OpenAI has such a rule, so Meadow adds none. A key whose limit is smaller than one real call serves that one call.
Do: treat max_tokens as a brake that stops a key soon after its budget. It is no exact ceiling. Leave headroom, and try a model once to see what its provider reports for a small request. The overshoot is at most what the calls in flight at that moment use.
What an abandoned call costs
A call is abandoned when a provider received the request and Meadow got no usable answer: a timeout or a lost connection after the request was sent, a 200 with the wrong content type, an invalid or oversized body, an empty stream, or you closing the connection.
The provider may bill you for such a call. Meadow cannot know, so on a limited key it charges one request and the reservation. If another provider then serves the call, the charge is the reservation or the reported usage, whichever is larger. The x-meadow-abandoned-attempts response header names the providers involved.
Three more rules for limited keys:
- All attempts together must produce the full answer, or the first stream event, within 8 minutes. After that the call gets a 502, and it is charged if a provider had the request. Stream long answers. This rule also holds on a key with a dollar
limit. - A stream that never settles is charged its reservation after 2 hours.
- A call the provider answered is always returned to you. If Meadow cannot write its charge at that moment, it retries for up to 2 minutes and charges the reported usage once. If no retry lands, the key is charged the reservation when its 10 minute lease ends.
Abandoned calls caused by a provider were not seen in testing. This section is read from the server’s code, apart from the dropped stream.
The in-flight limit and retry-after
Meadow sets no fixed number of requests in flight, per key or per account. Your provider’s limits apply to your provider key, and a provider’s 429 reaches you as described in Routing and fallbacks. This is on the hosted beta since 2026-11-28. Before, the beta stopped one key at 16 model requests in flight on each server.
Meadow rejects a request for load only to keep one account from filling a server:
- While a server has a free slot, every request is admitted, whatever your account already holds on it. One account alone can use the whole server.
- On a full server a request waits up to 3 seconds for a slot.
- A freed slot goes first to the waiting account with the fewest requests open, so a large account cannot keep a small one out.
- If no slot comes free in time, the request gets a 429 with
error.codeaccount_in_flight_limit_exceeded.
That is the body on a route outside the model API. A model route writes the same code and message in the provider’s envelope, with the type rate_limit_error.
That response is read from the server’s code and its tests. It was not captured on the hosted beta. Every kind of request counts on all the account’s keys together: model calls, streams until they end, long polls, uploads. The first request of an account that has nothing open on a server is admitted ahead of the others. The hosted service runs several servers, each counts on its own, and it adds servers as load grows.
Every 429 carries retry-after in whole seconds. For this cause the value is 1, and it is a floor: Meadow does not know when a slot will free up. Errors lists the value for each cause of a 429. This 429 also carries x-should-retry: true, as do the 429s for a full body budget and a busy limit check: no provider was called.
Do: wait at least the header’s value, add jitter, and back off further on repeats. A 429 is not charged to a key’s limits. The OpenAI and Anthropic SDKs retry a 429 on their own. See Use your existing tools.
Request size
These apply to every key and are checked before any provider is called.
On a key with no token limit, a request with no output token limit is estimated with 4,096 output tokens for this check only.
A blocking answer larger than 32 MiB is dropped and treated as an abandoned call. Stream very large answers.
More in Known limits.
API reference
Operations on this page: createKey, createChatCompletion, createResponse, createMessage.
A busy limit check
A model call on a key with max_requests, max_tokens or a dollar limit, its own or a parent’s, is checked against those limits one call at a time per limited key. When many calls share one limited key, the checks queue. A check that waits more than 3 seconds for one limited key, or more than 4 seconds in all, returns 429 with error.code key_limit_check_busy and retry-after. No provider was called and nothing was charged, so retry. In a load test on 2026-11-24, calls under one limited key ran well up to about 120 a second. For more than that, give each worker its own key and put the limit on keys that carry less traffic.