Fixing "This key has reached its spend cap"
This 402 means the key you used has hit the spend cap set on it. Your account may still have money; the cap stops this one key on purpose.
What the error says
HTTP 402
{
"error": {
"message": "This key has reached its spend cap.",
"type": "insufficient_quota",
"code": "key_budget_exceeded",
"param": null
}
}On /v1/messages it is a 402 billing_error with the same message.
How caps are counted
A key can carry a hard total cap, and a monthly cap. Every request places a hold for its worst-case cost before the model runs, and that hold counts against the cap along with what the key has already spent. So a key with a little room left can still refuse a request whose worst case is larger than that room, even if the real reply would have been cheap.
The monthly cap resets at the start of each calendar month in UTC. A total cap does not reset.
Before refusing, the API first tries to fit the request by lowering max_tokens to what the cap allows. This message appears when the hold still could not be placed.
Why you would want a cap
Caps are useful for a key you paste into a shared machine, a hosted front end or a bot. If the key leaks or a script loops, the damage stops at the cap. That is also why the API treats it as a hard stop rather than a warning.
Step by step fix
- Open /dashboard/ and find the key named in your client.
- Check its cap and what it has spent.
- Raise or remove the cap, or create a new key with its own cap for this client.
- If the cap is monthly and you are near the end of the month, you can also wait for the UTC month to roll over.
- Retry. SillyTavern needs no reconnect if the key itself did not change.
Telling it apart from similar errors
If the message is Account balance is too low, the account is empty and raising a cap will not help; see 402 Payment Required. If it reads Spend limit reached. This key has ... USD available, the remaining room is too small for even a minimal reply; see spend limit reached. Short replies with no error mean the cap is close and output was trimmed; see replies cut short.
FAQ
Does a capped key stop mid-reply when it hits the limit?
No. The reply length is bounded up front so the reply cannot cost more than the hold, which means a reply never gets cut off by the cap partway through. A request that cannot fit is refused before it starts.
Do other keys on my account keep working?
Yes. The cap belongs to one key. Other keys are limited only by their own caps and the account balance.