Claude API Pricing: A 10-Minute Token Cost Guide
Claude API pricing becomes easier to estimate when you separate tokens into four buckets: ordinary input, generated output, cache writes and cache reads. This quick-start guide shows how to calculate a request, interpret usage counters and avoid paying repeatedly for reusable context.
1. Identify what your request actually bills
- Input tokens: Text and other supported content Claude processes, including system instructions, conversation history, tool definitions and retrieved documents. Non-text inputs can have their own token accounting.
- Output tokens: Tokens generated by the model. Longer answers cost more, and supported reasoning features may introduce billable tokens beyond the visible answer.
- Cache-write tokens: Input tokens used to create a reusable prompt-cache entry. These can have a different rate from ordinary input.
- Cache-read tokens: Previously cached input reused on a later request, typically at a discounted rate.
Rates depend on the model, provider route and applicable pricing tier. Compare Claude Haiku 4.5 and Claude Sonnet 5.5 using the live rate card for your endpoint rather than assuming every Claude model has the same price.
2. Calculate costs with four token buckets
If prices are quoted per million tokens, use this formula: request cost = (uncached input × input rate + cache writes × write rate + cache reads × read rate + output × output rate) ÷ 1,000,000.
Here is a purely illustrative rate card, not a quote for any model: $3 per million uncached input tokens, $3.75 for cache writes, $0.30 for cache reads and $15 for output.
- Without caching: 100,000 input tokens plus 2,000 output tokens cost $0.30 + $0.03 = $0.33.
- Warm cache: 20,000 uncached input tokens, 80,000 cache-read tokens and 2,000 output tokens cost $0.06 + $0.024 + $0.03 = $0.114.
- Initial cache write: 20,000 uncached input tokens, 80,000 cache-write tokens and 2,000 output tokens cost $0.06 + $0.30 + $0.03 = $0.39.
The first cached request can cost more than an uncached request. Savings come from subsequent reuse before the entry expires. A cheaper input rate alone does not reveal the cheapest workload.
3. Structure prompts for repeatable cache hits
Put stable material first: system instructions, tool schemas, shared documentation and repository context. Put changing material, such as the latest user question, after that reusable prefix.
Prompt caching generally requires an exact matching prefix, subject to provider-specific rules. Changing early instructions, tool ordering or embedded timestamps can prevent reuse. Cache lifetime, minimum eligible prompt length and cache controls vary by model and route; confirm support before depending on them.
Sending the same text twice is not proof of a cache hit. Configure the supported cache mechanism and check the returned usage. Caching reduces repeated processing costs; it does not mean you should omit required context from later requests unless the API explicitly supports that behavior.
4. Read usage without double-counting tokens
On an Anthropic-style response, inspect input_tokens, output_tokens, cache_creation_input_tokens and cache_read_input_tokens when present. Ordinary input and cache counters are separate billing buckets in that usage format.
On an OpenAI-compatible response, cached tokens may instead appear inside prompt-token details as a subset of total prompt tokens. Do not add that subset to the total again. Relay mappings can differ, so reconcile response fields with your provider’s billing dashboard.
5. Connect through 59API and measure real spend
59API offers low-cost, pay-as-you-go access to native, official-quality models without downgrading, including Claude and other major model families. Its API base URL is https://api.59api.com, with compatibility for Claude Code, Codex, Gemini CLI and OpenAI SDK workflows. Follow its integration instructions for the correct endpoint path and authentication.
For a useful comparison, replay representative requests and record model, token buckets, latency and billed amount. Test cold-cache and warm-cache requests separately. Verify route-specific caching support, current prices and any additional charges instead of assuming official direct-API billing rules apply unchanged.
Start small: cap output length, reuse stable context and set spending alerts. If the measured cost and quality fit your application, consider signing up for 59API; its referral rebate is an additional benefit, separate from token-pricing savings.
¿Listo para empezar?
Conecta Claude y GPT en minutos a los precios más bajos, sin recortes. Regístrate para obtener tu clave API.
Registro gratis