Claude Code 的安装是免费的。你支付的是它所调用的模型的费用。如果你使用 API 密钥在本地运行 Claude Code,与 Claude Opus 5.5 进行 2 到 9 轮对话的短时会话中位数为 0.31 美元,而进行 10 到 49 轮对话的长时会话中位数为 1.39 美元。使用 Claude Sonnet 5.5 进行相同轮数的会话则分别花费 0.16 美元和 0.60 美元。
这些中位数数据来源于截至 2026 年 10 月 18 日的过去 30 天内 OpenRouter 上真实的 Claude Code 会话记录。Claude Code 在 10 月 21 日我们的每日应用排行榜中位列第一,这意味着其背后有着巨大的使用量。下文我们将利用这些数据展示在每个模型上运行一次会话的成本,并介绍如何在 OpenRouter 上运行 Claude Code,以便你为每次会话选择模型、查看实际花费并设置支出上限。
简而言之
Claude Code 是免费的。你支付的是它所调用的模型的费用,可以通过 Claude 订阅或 API 密钥按 token 计费。
使用 API 密钥时,2 到 9 轮对话的会话在 Opus 5.5 上的中位数为 0.31 美元,在 Sonnet 5.5 上为 0.16 美元,在 Haiku 5.5 上则不到一美分。
大部分成本来自 Claude Code 自身的上下文信息,这些信息在第一次请求时写入提示缓存(prompt cache),并在随后的每一轮对话中读取。
将 Sonnet 设为默认模型,将后台任务和子智能体发送给 Haiku,保持会话简短,并为密钥设置信用额度限制。
在 OpenRouter 上运行 Claude Code 时,使用 ori claude --model <model> 命令为每次会话选择模型。你的“活动”页面会显示每次会话的实际花费。
Claude Code 需要花钱吗?
通过订阅,你同意接收 OpenRouter 的新闻通讯:包括模型使用数据、产品更新和研究报告,大约每周一封电子邮件。您可以通过每封电子邮件中的链接随时取消订阅。请参阅我们的隐私政策。
该命令行界面(CLI)本身是免费的。它发出的每个请求都会指向某个模型,你可以通过两种方式支付这些请求的费用。Claude 订阅会在用量限制内覆盖这些费用,而 API 密钥则按 token 收费。本文主要介绍 API 密钥的路径,因为通过这种方式你可以查看并控制每次会话的成本。通过 OpenRouter,同一个密钥既可用于 Claude 模型,也可用于 Claude Code 可以调用的其他模型。
在 OpenRouter 上运行 Claude Code 最快的方式是 Ori Harness。它会在你本地机器上启动已配置好 OpenRouter 设置的 Claude Code,并通过浏览器登录,因此无需粘贴密钥:
curl -fsSL https://openrouter.ai/labs/ori/install.sh | bash
ori claude --model anthropic/claude-sonnet-5.5
只有使用 ori claude 启动的会话才会在 OpenRouter 上运行。普通的 claude 命令仍会继续使用你的订阅服务。
一次 Claude Code 会话的成本是多少?
我们在会话成本数据集中发布了按模型和会话长度划分的 Claude Code 会话的中位成本。以下是我们数据集中的 Claude 模型以及一些流行的替代方案:
| 模型 | 1 轮对话 | 2–9 轮对话 | 10–49 轮对话 |
|---|---|---|---|
| Claude Fable 5.1 | $0.342 | $1.049 | $3.734 |
| Claude Opus 5.5 | $0.136 | $0.305 | $1.390 |
| Claude Sonnet 5.5 | $0.071 | $0.155 | $0.596 |
| Claude Haiku 5.5 | $0.002 | $0.007 | $0.053 |
| Kimi K3 | $0.040 | $0.117 | $0.825 |
| GLM-5.3 | $0.010 | $0.044 | $0.363 |
| DeepSeek V4.1 Flash | $0.003 | $0.009 | $0.047 |
| GPT-6 Luna | $0.002 | $0.005 | $0.024 |
截至 2026 年 10 月 18 日的 30 天内,按模型和对话轮数划分的 Claude Code 会话中位成本。
你选择的模型对成本影响最大。一次 Fable 5.1 的单轮对话成本比一次长时 Haiku 5.5 会话的成本还要高。选定模型后,会话长度成为主要影响因素。一次 10 到 49 轮的 Opus 会话成本大约是单轮会话的十倍,而 Sonnet 5.5 在任何轮数下的成本都约为 Opus 5.5 的一半或更低。
为什么一次单轮会话的成本是 14 美分?
大部分成本来自 Claude Code 自身的上下文,而非你的提示词。我们在 Claude Code 2.1.307 的空文件夹中,通过 OpenRouter 对 Opus 5.5 运行了 claude -p "Reply with exactly: ok"。回复仅包含四个 token,但会话向提示缓存写入了 17,047 个 token。这些 token 是 Claude Code 的系统提示和工具定义。在 Opus 5.5 每百万 token 写入价格为 5 美元的情况下,这部分成本为 0.085 美元。实际项目会添加其自身的指令以及 Claude Code 读取的文件,这就是为什么数据集中单轮的中位数更高,达到 0.136 美元。启动 token 的数量也会因 Claude Code 的版本和设置而异。
一旦这些上下文进入缓存,后续请求将以每百万 token 0.20 美元的价格读取它们,这比写入便宜 25 倍。这就是为什么第一轮之后的每一轮增加的成本少于第一轮的原因。随着上下文的增长,成本会再次攀升,因为 Claude Code 会将它读取的每个新文件写入缓存一次,然后在随后的每一轮中读取它。我们的提示缓存指南涵盖了写入和读取的费用计算方式。
我们自己的会话花费了多少?
数据集展示了其他人会话的成本。为了在受控任务上比较模型,我们向 Claude Code 提供了一个包含三个错误和五个失败测试的小型发票库。我们通过 OpenRouter 在每个模型上运行了三次,每次运行都修复了所有三个错误。
| 模型 | 每会话中位数成本 | 轮数 | 从缓存读取的 token | 写入缓存的 token |
|---|---|---|---|---|
| Opus 5.5 | $0.098 | 5 | 111,000 | 9,800–10,300 |
| Sonnet 5.5 | $0.062 | 5 | 125,000–154,000 | 15,000–43,500 |
| Haiku 5.5 | $0.0052 | 6–8 | 126,000–199,000 | 16,400–45,800 |
这些成本低于数据集中 2 到 9 轮的中位数,原因有两个:我们的任务很小,并且我们连续运行了每个模型的三个会话,因此它们共享了一个热缓存。这也是为什么 Opus 的写入 token 数少于我们单轮测试的原因。对于真实项目的全新会话,上述数据集中位数是更好的参考。模型之间的相对顺序仍然保持不变。Sonnet 的成本约为 Opus 的三分之二,而 Haiku 的成本约为 Sonnet 的十二分之一。
如果你自己检查这些数字,不要依赖 Claude Code 自身的 total_cost_usd。它使用的是 Anthropic 内置的价格表,当它无法识别 OpenRouter 模型名称时,它会进行猜测。在我们的运行中,对于成本约为半美分的 Haiku 会话,它报告的成本为 0.16 到 0.31 美元,并且夸大了 Opus 会话的成本约 50%。你的 Activity 页面显示了你实际支付的金额。为了在 Claude Code 内部获得累计总额,你可以添加我们的成本跟踪状态栏(cost-tracking statusline),它从 OpenRouter 读取每个会话的支出。
Claude Code 每月花费多少?
将你运行的会话数量乘以你典型会话长度的中位数。以下是三个示例,使用数据集的中位数和每月 22 个工作日计算:
| 使用情况 | Opus 5.5 | Sonnet 5.5 |
|---|---|---|
| 轻量:每天 5 个短会话(2–9 轮) | $34 | $17 |
| 常规:每天 20 个短会话 | $134 | $68 |
| 重度:每天 10 个长会话(10–49 轮) | $306 | $131 |
这些是估算值。你自己的会话成本可能会更高或更低,具体取决于你的代码库大小以及 Claude Code 读取了多少内容。
如何降低 Claude Code 的成本?
你控制着驱动账单的两个因素:每个会话使用的模型以及会话的持续时间。
将 Sonnet 设为默认
如果你对所有任务都使用 Opus,将默认值切换为 Sonnet 可将账单减半。在我们的测试中,Sonnet 修复了相同的错误。将 Opus 保留给需要它的会话。
将后台工作和子代理发送给 Haiku
Claude Code 使用快速模型处理小型后台任务,并且可以将任务的一部分交给子代理。Haiku 5.5 以远低于 Sonnet 的成本通过了我们的错误修复测试,因此它非常适合这两种用途。以下设置将 Sonnet 5.5 设为默认值,并将后台任务和子代理路由到 Haiku 5.5:
export ANTHROPIC_BASE_URL = "https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN = " $OPENROUTER_API_KEY "
export ANTHROPIC_API_KEY = ""
export ANTHROPIC_MODEL = "anthropic/claude-sonnet-5.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL = "anthropic/claude-haiku-5.5"
export CLAUDE_CODE_SUBAGENT_MODEL = "anthropic/claude-haiku-5.5"
前三行将 Claude Code 连接到 OpenRouter;后三行设置模型。我们的 Claude Code 集成指南和设置教程涵盖了其余的设置步骤。
保持会话简短
一个包含 10 到 49 轮对话的会话成本约为包含 2 到 9 轮对话会话的四到五倍。当你转向不相关的任务时,请开始一个新的会话或运行 /compact 命令,而不是带着旧的上下文继续。
尝试更便宜的模型处理常规工作
通过 OpenRouter,Claude Code 可以调用来自其他实验室的模型,数据集显示人们确实在这样做。GLM-5.3 和 Kimi K3 的会话在任何长度下都比 Opus 会话便宜,我们关于在 OpenRouter 上以最低成本进行 LLM 推理的指南涵盖了如何找到更便宜的选项。要尝试其中一个,请将其传递给 Ori Harness:
ori claude --model z-ai/glm-5.3
不过,Claude Code 是为 Anthropic 模型构建的,因此在切换之前,请在你自己的任务上测试任何其他模型。Ori Eval 可以为你完成这项工作:你的编码代理会在项目中找到测试材料,在你想要比较的模型上运行它们,并根据评分和成本推荐其中一个。
设置支出上限
你可以为 API 密钥设置信用额度限制,这样失控的会话就会在你设定的数值处停止。在组织中,带有预算限制的护栏可以为每个成员或密钥每天、每周或每月设定上限,OpenRouter 也将其应用于通过 Ori Harness 启动的会话。在企业计划中,工作区预算可以限制整个团队每天、每周、每月或终身的支出。
常见问题
Claude Code 每 token 的成本是多少?
Claude Code 的成本取决于其调用的模型每 token 收取的费用。Claude Opus 5.5 的成本为:每百万输入 token 4 美元,每百万输出 token 20 美元,写入提示缓存的每百万 token 5 美元,从缓存读取的每百万 token 0.20 美元。Claude Sonnet 5.5 的成本是这些费率的一半。Claude Haiku 5.5 的成本为:每百万输入 token 0.10 美元,每百万输出 token 0.50 美元,缓存读取为每百万 token 0.01 美元。Claude Code 会话的大部分 token 都是缓存读取。
使用 Sonnet 还是 Opus 让 Claude Code 更便宜?
Sonnet 更便宜。在我们的会话成本数据中,在任何会话长度下,基于 Claude Sonnet 5.5 的 Claude Code 会话成本约为基于 Claude Opus 5.5 的会话的一半。在我们自己的错误修复测试中,Sonnet 修复了与 Opus 相同的错误。
我可以将 Claude Code 与其他模型一起使用吗?
可以。当你将 Claude Code 指向 OpenRouter 时,它可以调用来自其他实验室的模型。我们的会话成本数据包括基于 GLM、Kimi、DeepSeek、Qwen 和 GPT 模型的 Claude Code 会话。Claude Code 是为 Anthropic 模型构建的,因此在切换到其他模型之前,请先在你的任务上测试该模型。
为什么我的第一个 Claude Code 请求如此昂贵?
第一个请求将 Claude Code 的系统提示、工具定义和项目上下文写入提示缓存。在我们使用 Claude Opus 5.5 在空文件夹中的测试中,这大约是 17,000 个 token,成本约为 0.085 美元,而实际项目会增加更多。后续的请求以低得多的价格(在 Opus 5.5 上低 25 倍)从缓存读取相同的上下文。
后续步骤
Claude Code is free to install. What you pay for is the model it calls. If you run Claude Code on an API key, a short session of 2 to 9 turns with Claude Opus 5.5 costs $0.31 at the median, and a long session of 10 to 49 turns costs $1.39. The same sessions with Claude Sonnet 5.5 cost $0.16 and $0.60.
Those medians come from real Claude Code sessions on OpenRouter in the 30 days to October 18, 2026. Claude Code was the top app in our daily app ranking on October 21, so there’s a lot of usage behind them. Below, we use that data to show what a session costs on each model, then how to run Claude Code on OpenRouter so you can pick the model for each session, see what it cost, and cap your spend.
Tl;dr
Claude Code is free. You pay for the model it calls, either through a Claude subscription or per token on an API key.
On an API key, a 2-to-9-turn session costs $0.31 at the median on Opus 5.5, $0.16 on Sonnet 5.5 and under a cent on Haiku 5.5.
Most of the cost is Claude Code’s own context, written to the prompt cache on the first request and read back on every turn after it.
Make Sonnet your default, send background jobs and sub-agents to Haiku, keep sessions short, and set a credit limit on the key.
Run Claude Code on OpenRouter with ori claude --model
Does Claude Code cost money?
By subscribing you agree to receive the OpenRouter newsletter: model usage data, product updates, and research reports, about one email a week. Unsubscribe anytime via the link in every email. See our Privacy Policy .
The CLI costs nothing. Every request it makes goes to a model, and you pay for those requests in one of two ways. A Claude subscription covers them up to a usage limit, and an API key charges per token. This post covers the API-key route, because that’s where you can see and control what each session costs. Through OpenRouter, the same key works with Claude models and with other models Claude Code can call.
The quickest way to run Claude Code on OpenRouter is Ori Harness . It starts the Claude Code already on your machine with OpenRouter settings in place, and signs you in through your browser, so there is no key to paste:
curl -fsSL https://openrouter.ai/labs/ori/install.sh | bash
ori claude --model anthropic/claude-sonnet-5.5
Only sessions you start with ori claude run on OpenRouter. Plain claude keeps using your subscription.
What does a Claude Code session cost?
We publish the median cost of Claude Code sessions by model and session length in our session-cost dataset . Here are the Claude models in our dataset and a few popular alternatives:
Model 1 turn 2–9 turns 10–49 turns
Claude Fable 5.1 $0.342 $1.049 $3.734
Claude Opus 5.5 $0.136 $0.305 $1.390
Claude Sonnet 5.5 $0.071 $0.155 $0.596
Claude Haiku 5.5 $0.002 $0.007 $0.053
Kimi K3 $0.040 $0.117 $0.825
GLM-5.3 $0.010 $0.044 $0.363
DeepSeek V4.1 Flash $0.003 $0.009 $0.047
GPT-6 Luna $0.002 $0.005 $0.024
Median cost per Claude Code session by model and number of turns, for the 30 days to October 18, 2026.
The model you pick has the biggest effect on cost. A one-turn Fable 5.1 session costs more than a long Haiku 5.5 session. Once you’ve picked a model, session length matters most. A 10-to-49-turn Opus session costs about ten times as much as a one-turn session, and Sonnet 5.5 costs about half as much as Opus 5.5 or less at every length.
Why does a one-turn session cost 14 cents?
Most of the cost is Claude Code’s own context, not your prompt. We ran claude -p "Reply with exactly: ok" against Opus 5.5 through OpenRouter, in an empty folder on Claude Code 2.1.307. The reply was four tokens, but the session wrote 17,047 tokens to the prompt cache. Those tokens are Claude Code’s system prompt and tool definitions. At Opus 5.5’s cache-write price of $5 per million tokens, they cost $0.085. A real project adds its own instructions and the files Claude Code reads, which is why the dataset’s one-turn median is higher, at $0.136. The number of startup tokens also changes between Claude Code versions and settings.
Once that context is in the cache, later requests read it back at $0.20 per million tokens, which is 25 times cheaper than writing it. That’s why each turn after the first adds less than the first one did. Costs climb again as the context grows, because Claude Code writes every new file it reads to the cache once and then reads it back on every turn after that. Our prompt caching guide covers how writes and reads are billed.
What did our own sessions cost?
The dataset shows what other people’s sessions cost. To compare models on a task we controlled, we gave Claude Code a small invoicing library with three bugs and five failing tests. We ran it three times on each model through OpenRouter, and every run fixed all three bugs.
Model Median cost per session Turns Tokens read from cache Tokens written to cache
Opus 5.5 $0.098 5 111,000 9,800–10,300
Sonnet 5.5 $0.062 5 125,000–154,000 15,000–43,500
Haiku 5.5 $0.0052 6–8 126,000–199,000 16,400–45,800
These costs come in under the dataset’s 2-to-9-turn medians for two reasons. Our task was small, and we ran each model’s three sessions back to back, so they shared a warm cache. That’s also why the Opus runs wrote fewer tokens to the cache than our one-turn test did. For a fresh session on a real project, the dataset medians above are the better guide. The models still land in the same order. Sonnet cost about two thirds of what Opus did, and Haiku cost about a twelfth of what Sonnet did.
If you check numbers like these yourself, don’t rely on Claude Code’s own total_cost_usd . It uses Anthropic’s built-in price table, and when it doesn’t recognize an OpenRouter model name, it guesses. In our runs, it reported $0.16 to $0.31 for Haiku sessions that cost about half a cent, and it overstated Opus sessions by about 50%. Your Activity page shows what you actually paid. For a running total inside Claude Code, you can add our cost-tracking statusline , which reads each session’s spend from OpenRouter.
How much does Claude Code cost per month?
Multiply the number of sessions you run by the median for your typical session length. Here are three examples, using the dataset medians and 22 workdays a month:
Usage Opus 5.5 Sonnet 5.5
Light: 5 short sessions (2–9 turns) a workday $34 $17
Regular: 20 short sessions a workday $134 $68
Heavy: 10 long sessions (10–49 turns) a workday $306 $131
These are estimates. Your own sessions will cost more or less depending on the size of your codebase and how much of it Claude Code reads.
How do you lower Claude Code’s cost?
You control the two things that drive the bill, which model each session runs on and how long the session goes on.
Make Sonnet your default
If you use Opus for everything, switching your default to Sonnet roughly halves the bill. In our test, Sonnet fixed the same bugs. Keep Opus for the sessions that need it.
Send background work and sub-agents to Haiku
Claude Code uses a fast model for small background jobs, and it can hand parts of a task to sub-agents. Haiku 5.5 passed our bug-fix test at a fraction of Sonnet’s cost, so it’s a good fit for both. These settings make Sonnet 5.5 your default and route background jobs and sub-agents to Haiku 5.5:
export ANTHROPIC_BASE_URL = "https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN = " $OPENROUTER_API_KEY "
export ANTHROPIC_API_KEY = ""
export ANTHROPIC_MODEL = "anthropic/claude-sonnet-5.5"
export ANTHROPIC_DEFAULT_HAIKU_MODEL = "anthropic/claude-haiku-5.5"
export CLAUDE_CODE_SUBAGENT_MODEL = "anthropic/claude-haiku-5.5"
The first three lines connect Claude Code to OpenRouter; the last three set the models. Our Claude Code integration guide and setup tutorial cover the rest of the setup.
Keep sessions short
A 10-to-49-turn session costs about four to five times as much as a 2-to-9-turn one. When you move on to an unrelated task, start a fresh session or run /compact instead of carrying the old context with you.
Try a cheaper model for routine work
Through OpenRouter, Claude Code can call models from other labs, and the dataset shows people doing it. GLM-5.3 and Kimi K3 sessions cost less than Opus sessions at every length, and our guide to the lowest-cost LLM inference on OpenRouter covers how to find cheaper options. To try one, pass it to Ori Harness:
ori claude --model z-ai/glm-5.3
Claude Code is built for Anthropic models, though, so test any other model on your own tasks before you switch. Ori Eval does this for you: your coding agent finds test material in your project, runs the models you want to compare on it, and recommends one with the scores and costs behind it.
Set a spending cap
You can set a credit limit on an API key, so a runaway session stops at a number you chose. In an organization, a guardrail with a budget limit caps each member or key per day, week or month, and OpenRouter applies it to sessions started with Ori Harness too. On Enterprise plans, workspace budgets cap a whole team’s spend per day, week, month or lifetime.
Frequently asked questions
How much does Claude Code cost per token?
Claude Code costs whatever the model it calls charges per token. Claude Opus 5.5 costs $4 per million input tokens, $20 per million output tokens, $5 per million tokens written to the prompt cache and $0.20 per million tokens read from it. Claude Sonnet 5.5 costs half those rates. Claude Haiku 5.5 costs $0.10 per million input tokens and $0.50 per million output tokens, with cache reads at $0.01 per million. Most of a Claude Code session’s tokens are cache reads.
Is Claude Code cheaper with Sonnet or Opus?
Sonnet is cheaper. In our session-cost data, Claude Code sessions on Claude Sonnet 5.5 cost about half as much as sessions on Claude Opus 5.5 at every session length. In our own bug-fixing test, Sonnet fixed the same bugs as Opus.
Can I use Claude Code with other models?
Yes. When you point Claude Code at OpenRouter, it can call models from other labs. Our session-cost data includes Claude Code sessions on GLM, Kimi, DeepSeek, Qwen and GPT models. Claude Code is built for Anthropic models, so test another model on your own tasks before you switch to it.
Why is my first Claude Code request so expensive?
The first request writes Claude Code’s system prompt, tool definitions and project context to the prompt cache. In our test with Claude Opus 5.5 in an empty folder, that was about 17,000 tokens, which cost about $0.085, and a real project adds more. Later requests read the same context from the cache at a much lower price, 25 times lower on Opus 5.5.
Next steps
| 刊期 | 得分 | 排名 | 结果 |
|---|---|---|---|
| 2026-11-10 | 8.4 | 35 | 未入选 |
| 2026-11-09 | 8.4 | 19 | 未入选 |
| 2026-11-08 | 8.4 | 27 | 未入选 |
| 2026-10-31 | 9.95 | 27 | 入选 |