Claude API Pricing: Input, Output and Cache Tokens
Claude API pricing starts with token direction
Claude API costs are usually measured in tokens, not requests. A token is a small unit of text: in English, it is often roughly three to four characters or part of a word. The important pricing detail is where that token travels. Input tokens are sent to Claude in your prompt, output tokens are generated in Claude's reply, and cache tokens are reused prompt content that can reduce repeated-context costs.
For a simple example, imagine a coding assistant request that sends a 10,000-token repository summary and receives a 1,000-token answer. Your bill combines the price for 10,000 input tokens and 1,000 output tokens for the selected model. Output is commonly priced higher than input because generating each new token requires more inference work.
Input tokens: everything you send
Input tokens include more than the sentence typed by a user. They can include system instructions, chat history, tool definitions, source code, retrieved documents, JSON schemas, and pasted files. In an agent workflow, these supporting materials may be much larger than the visible question.
- A short question with 20 previous messages can create a large input bill.
- Sending an entire codebase on every request is expensive and usually unnecessary.
- Use retrieval, file selection, summaries, and token limits to send only relevant context.
- Choose the model tier for the task: a fast, economical model is often enough for classification, extraction, or routine edits.
Claude model families have different rates. Opus is generally intended for the hardest reasoning tasks, Sonnet balances quality and cost for broad development work, and Haiku is suited to high-volume, latency-sensitive tasks. Check the current rate card for the specific model identifier before estimating a production budget.
Output tokens: the answer Claude creates
Output tokens are the text returned by Claude, including generated code, explanations, structured JSON, and tool-call arguments. A request can have a small prompt but still be costly when it asks for long reports, full-file rewrites, or verbose chain-of-thought-style explanations. Set a practical maximum output-token limit and ask for the format you actually need.
For example, requesting a patch with only changed functions is typically cheaper than requesting a complete rewritten project. For data extraction, require compact JSON fields instead of a narrative followed by JSON. These choices reduce cost and can also make downstream parsing more reliable.
Cache tokens: reuse stable context
Prompt caching is useful when a large portion of the prompt stays the same across requests. Common reusable content includes product documentation, coding standards, long system prompts, API specifications, and repository architecture notes. Rather than paying the full normal input rate repeatedly, a cache-aware workflow can write stable context once and read it on later requests at the applicable cache rates.
Caching works best when the reusable prefix is identical and placed before changing user-specific content. Put stable instructions and reference material first, then append the changing question, user data, or current file diff. Small edits to the cached section can prevent a cache hit, so keep this shared context versioned and deliberate.
- Separate stable instructions from per-request data.
- Keep cacheable content in a consistent order.
- Track input, output, cache-write, and cache-read usage separately.
- Measure real traffic before committing to a model or context strategy.
Estimate Claude API cost before launching
A useful estimate is: input tokens multiplied by the input rate, plus output tokens multiplied by the output rate, plus any cache write or cache read tokens multiplied by their corresponding rates. Run representative requests through your application, record average and high-percentile token usage, then multiply by projected daily volume. Include retries and tool loops, since autonomous coding workflows can make several model calls for one visible task.
59API gives developers a practical way to control these costs with cheap, pay-as-you-go access to native official-quality Claude models, including Opus, Sonnet, Haiku, and Fable, alongside GPT models. Its API base URL is https://api.59api.com, and it is compatible with Claude Code, Codex, and OpenAI SDK-based integrations. This lets teams test model and token strategies without being locked into a high minimum spend or changing their existing client tooling.
Start by logging token usage per feature, cap outputs where appropriate, cache stable context, and route routine jobs to a lower-cost model. Developers looking for an economical relay can sign up for 59API to use pay-as-you-go pricing and access its referral rebate program.
¿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