Guide · Coding-agent cost

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.

Claude CodeSession budgetClaude API

Reviewed by OpenLux Engineering Team · Last verified

Create an API key Read the docs

Abstract orange glass gateway illustration for Claude Code Cost
One API, one key, one bill — verify the workload before choosing.
Comparison

What makes a Claude Code session expensive?

The same number of sessions can produce very different bills.

DriverLow-cost patternHigh-cost pattern
Repository contextNarrow files and relevant search resultsLarge files or repository summaries resent every turn
ModelLower-cost model for routine editsFlagship model for every small change
OutputMinimal explanations and requested patchesLong plans duplicated across tool calls
ToolsFocused grep, test and edit loopRepeated tool calls without new evidence
RetriesClean errors and bounded retriesRepeated model calls caused by bad context or timeouts
Session lengthTask-scoped sessionsOpen 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.
Interactive estimate

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.

Published rate$0.1838 / 1M tokens
Cost per successful session$0.0081
Monthly cost per developer$1.07
Estimated team API cost$1.07 / month
Annualised at the same volume$12.89 / year

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.

ModelMonthly per developerMonthly 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

ModelVendorPriceVs. official
claude-sonnet-4-5-20250929Anthropic$0.2647 / 1M tokens-91%
claude-opus-5Anthropic$0.4412 / 1M tokens-91%
gpt-5.6-solOpenAI$0.1838 / 1M tokens-96%
deepseek-v4DeepSeek$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.

Budget Claude Code on real sessions

Run a small representative task set, then use its token and retry data in the calculator.

Create an API key See pricing

Claude Code Cost: Per-Session & Monthly Estimates | OpenLux