Optimize
Cost control
Work out what a request costs, choose cheaper models, cap output, use prompt caching, and limit each key's spending so a bug cannot drain your balance.
On this page
You pay per token at the rates in the models table, from a prepaid balance. Nothing renews or charges on its own, and requests stop when the balance reaches $0. This page covers how to spend less and how to make sure a bug cannot spend more than you intend.
What a request costs
cost = input_tokens × input rate / 1,000,000
+ output_tokens × output rate / 1,000,000
rounded to the nearest $0.000002 (at least $0.000002 on a paid model)
(cached input tokens use the cached rate; reasoning tokens count as output)For example, a request with 3,000 input tokens and 800 output tokens costs:
| Model id | Input / 1M | Output / 1M | This request |
|---|---|---|---|
| claude-sonnet-5-5 | $2.20 | $11 | $0.0154 |
| gpt-5.6-terra | $2.20 | $13.20 | $0.01716 |
| claude-haiku-4-5 | $1.10 | $5.50 | $0.0077 |
Output tokens cost several times more than input tokens on most models, so long answers and long thinking are usually where the money goes. The exact cost of every request is on the usage page, which you can filter by model and key and export as CSV.
Spend less per request
- Pick the smallest model that does the job. Try a fast model first and move up only for the requests where it falls short. Every model shares the same API, so this is a one-line change.
- Cap the output. Set
max_tokenson every request. Without it, a model can write until its own maximum, and you pay for every token. - Turn reasoning down. On reasoning models,
reasoning_effort: "low"often answers as well for routine work, with far fewer output tokens. - Send less history. The whole conversation is billed on every turn. Drop old turns, summarise them, and remove images once they have been discussed.
- Reuse prefixes. Keep long instructions and documents at the start of the prompt so prompt caching bills them at the cached rate.
- Ask for short answers. “Answer in at most three sentences” in the system prompt is the cheapest optimisation there is.
Free and discounted models
No models in this list right now. See all models.
When free models are listed, they cost nothing and work with a zero balance once the account has paid $3 or more. Discounted models are listed on the models page with their end dates.
Limit what a key can spend
Give every app, environment and teammate its own key under API keys, and set on each:
- Spend limit: the most this key can ever spend. When it is used up the key stops working; your balance and your other keys are not affected.
- Expiry date: for temporary access, demos and contractors.
- Model list: only the models this key may call, so a typo or a changed config cannot switch an app to an expensive model.
See Authentication and keys for how each setting behaves.
Keep an eye on spending
- The usage page shows each request with its model, key, tokens and cost, for up to 30 days at a time.
- The billing page shows your balance, what you have spent to date, and a notice when the balance is empty.
- The API response itself carries token counts in
usage, not prices. Multiply by the rates if you want to track cost in your own logs.
Related
- Pricing and billing: how the balance, credit packs and plans work.
- Models: every rate.
- Account security and alerts: a webhook alert when the balance runs low.