Error format
Errors come in the shape of the format you called.message says what went wrong and, where you can fix it, where to go.
A request that ends in an error is free. See Billing.
Status codes
Rate limits
Each account has two limits, shared by all of its keys:- Requests per minute.
- Requests at once: how many requests can run at the same time.
429 with a Retry-After header, and costs nothing.
The limits rise with your account’s tier, and your tier rises with what your account has paid in total. Staking doesn’t change your tier. The Models page lists each tier’s limits and what unlocks it.
There is no limit on tokens per minute.
Counting tokens with POST /v1/messages/count_tokens has its own per-minute limit, equal to your requests per minute, so counts never use up requests.
Output limits
A request can use at most the chosen model’s context size, input and output together. If you setmax_tokens (max_output_tokens in Responses) above what is left after the input, the request is answered 400 with the largest value allowed.