Claude Code cost: what drives API spend per session?
Claude Code itself is the workflow; the model API is the variable cost. Cost per session rises with repository context, response length, tool loops and retries. Use the calculator to estimate 5, 20 or 100 monthly sessions, then validate it against real token logs.
Reviewed by OpenLux Engineering Team · Last verified

What makes a Claude Code session expensive?
The same number of sessions can produce very different bills.
| Driver | Low-cost pattern | High-cost pattern |
|---|---|---|
| Repository context | Narrow files and relevant search results | Large files or repository summaries resent every turn |
| Model | Lower-cost model for routine edits | Flagship model for every small change |
| Output | Minimal explanations and requested patches | Long plans duplicated across tool calls |
| Tools | Focused grep, test and edit loop | Repeated tool calls without new evidence |
| Retries | Clean errors and bounded retries | Repeated model calls caused by bad context or timeouts |
| Session length | Task-scoped sessions | Open sessions that accumulate context for hours |
How much does a Claude Code session cost?
A session costs the sum of model tokens and any retries used during that task. There is no universal per-session price because a one-file edit and a repository-wide refactor send very different context.
For budgeting, start with a reproducible scenario. The calculator preloads a coding-agent profile, but the team scenario should be replaced with token counts from Claude Code or gateway request logs.
Is Claude Opus always more expensive in practice?
Opus carries a higher per-token rate, but quality can reduce repeated attempts on hard tasks. The cheaper decision is the one with lower cost per accepted task, not necessarily the lowest token price.
Use Sonnet and lower-cost models for routine work, reserve Opus for difficult reasoning, and compare acceptance and retry rates on the same task set.
How do you route Claude Code through OpenLux?
The current OpenLux guide uses a local LiteLLM bridge to expose OpenLux models in the Anthropic-style interface Claude Code expects. The model endpoint stays local while upstream requests use the OpenLux key.
This setup is best for teams that already use OpenLux and want one upstream bill. Validate model IDs, tool calling and long-context behavior before moving production work.
How should a team budget monthly Claude Code usage?
Multiply cost per representative session by expected sessions per developer, then add a retry and exploratory-work allowance. Track cost by developer and project, not just as one aggregate bill.
Set a review threshold for unusually expensive sessions and inspect repeated context or tool loops before changing the model.
Which option fits?
Use a lower-cost model when
- Edits are narrow and tests provide clear feedback.
- The task is extraction, search or routine explanation.
- Retries and acceptance stay stable across a representative task set.
Escalate to a stronger model when
- Repeated cheaper attempts keep failing the tests.
- Architecture or cross-file reasoning is the bottleneck.
- One accurate answer is cheaper than an extended tool loop.
Estimate your coding-agent API cost
Adjust the workload to match one developer, then scale by team size. The calculation uses the current OpenLux catalogue rate and a blended token assumption.
Assumptions: one blended per-million-token rate, all input and output tokens counted once, and failed attempts equal to the retry percentage. Your console invoice is authoritative. Compare OpenLux plans.
Same assumptions across text models
These rows apply the same token, session and retry assumptions to each published model rate.
| Model | Monthly per developer | Monthly team cost |
|---|---|---|
| gpt-6-astra | $2.15 | $2.15 |
| gpt-5.6-sol | $1.07 | $1.07 |
| gemini-3.8-flash | $0.3221 | $0.3221 |
| gemini-3-flash-preview | $0.2151 | $0.2151 |
| claude-sonnet-4-5-20250929 | $1.55 | $1.55 |
| claude-opus-5 | $2.58 | $2.58 |
| claude-fable-5-1 | $10.32 | $10.32 |
| gemini-3.1-pro-preview | $0.8598 | $0.8598 |
| deepseek-v4 | $0.3583 | $0.3583 |
| qwen3-max | $0.4582 | $0.4582 |
Related models and live rates
| Model | Vendor | Price | Vs. official |
|---|---|---|---|
| claude-sonnet-4-5-20250929 | Anthropic | $0.2647 / 1M tokens | -91% |
| claude-opus-5 | Anthropic | $0.4412 / 1M tokens | -91% |
| gpt-5.6-sol | OpenAI | $0.1838 / 1M tokens | -96% |
| deepseek-v4 | DeepSeek | $0.0613 / 1M tokens | -90% |
Key takeaways
- Claude Code bill size depends on tokens and retries, not session count alone.
- Compare models by cost per accepted coding task.
- Use a local LiteLLM bridge when connecting Claude Code to an OpenAI-compatible gateway.
Frequently asked questions
Is Claude Code free?
The client workflow and the model API are separate concerns. Any model calls still consume provider or gateway capacity and therefore have a cost.
What is the average Claude Code session cost?
There is no stable universal average. Use your token mix, model and retry rate; a one-file edit and a repository-wide task are not comparable.
Can I use Claude Code with OpenLux?
Yes, through the documented local LiteLLM bridge. Validate tool calling, model IDs and context behavior before relying on it in production.
How can I lower Claude Code cost?
Reduce repeated context, use task-scoped sessions, route routine work to lower-cost models and inspect expensive retry loops.
Sources and methodology
Competitor claims were checked against the linked public pages on the verification date. Pricing and product terms can change; confirm them before purchase.
- Claude Code documentationOfficial product documentation.
- OpenRouter Claude Code cost analysisCompetitor analysis of session-based coding-agent cost.
- OpenLux model catalogue and current ratesRates were read from the live catalogue on 2026-10-31.
- OpenLux Claude Code integrationBridge and configuration guide.
Related comparisons and guides
Budget Claude Code on real sessions
Run a small representative task set, then use its token and retry data in the calculator.