59API

← 返回教程列表

Claude API Pricing: Input, Output, Cache Tokens

省钱与定价 · EN · 2026-07-22

Claude API pricing in one sentence

Claude billing is token-based: you pay for input tokens you send, output tokens the model generates, and sometimes cache tokens when you reuse a prompt prefix. If you understand those three buckets, Claude costs become predictable.

1) Input tokens: everything you send in

Input tokens include more than the user prompt. They also include system instructions, conversation history, tool schemas, retrieved documents, and any pasted code. For developer workflows, this is usually the hidden cost driver, because long chat histories and large context blocks can add up fast.

A practical rule: trim anything the model does not need for the current turn. Keep system prompts tight, remove stale chat turns, and only send the relevant files or snippets. In code assistants, a 20,000-token prompt can cost far more than the actual answer.

2) Output tokens: what Claude generates

Output tokens are the model's response. A short summary may be 100 tokens; a verbose code review can be thousands. Since output is billed separately and often at a higher rate than input, the easiest way to control spend is to cap the answer length with a sensible max_tokens value and ask for the format you actually need.

For example, if you only need a patch plan, ask for bullets. If you need JSON, tell Claude to return only valid JSON with no commentary. Less fluff means fewer billed tokens.

3) Cache tokens: reuse expensive prompt prefixes

Cache tokens matter when you repeat a large, stable prefix across many requests. That prefix might be a long system prompt, a tool definition block, a product spec, or a documentation bundle. With prompt caching enabled, the first request creates the cache and later requests can reuse it at a lower cost.

In the response payload, you will typically see usage fields such as cache_creation_input_tokens and cache_read_input_tokens. Those numbers tell you whether you are paying to write the cache or benefiting from a cache hit. If your app sends the same instructions over and over, caching can be the difference between expensive and affordable.

A simple cost formula you can reuse

To estimate a request, use this pattern:

Total cost = uncached input tokens × input rate + cached write tokens × cache write rate + cached read tokens × cache read rate + output tokens × output rate

The exact rates depend on the model, so check the current rate card before you launch. But the shape of the bill stays the same. If your prompts are long and repeated, cache optimization usually gives the biggest savings. If your responses are long, output control matters most.

Where 59API helps you spend less

59API is a low-cost AI API relay at https://api.59api.com that gives you pay-as-you-go access to Claude models like Opus, Sonnet, Haiku, and Fable, plus GPT models. It is fully compatible with Claude Code, Codex, and any OpenAI SDK, so you can point your existing client at the relay without rewriting your app.

For busy developers, that means two wins: you keep the same native, official-quality model behavior, and you avoid paying more than you need to for delivery overhead. 59API is designed for cheap usage from the start, and it also offers a referral rebate if you share it with teammates or clients.

Quick-start checklist

If you want Claude access that is cheaper, pay-as-you-go, and easy to drop into an existing SDK, sign up for 59API and test your next request against https://api.59api.com.

价格 · 接入文档

准备好开始了吗?

几分钟接入 Claude 与 GPT,全网超低价,原生不降智。立即注册即可领取 API 密钥。

免费注册