The short answer to "what does Claude Code cost" is that it depends on how you pay for it, and then on how long each session's context gets. Anthropic's own figure for enterprise deployments is about $13 per developer per active day, $150 to $250 per developer per month, with 90% of users staying under $30 per active day1. Codex follows the same pattern on OpenAI's side: included usage on a ChatGPT plan, or API-key usage billed at API rates2.
This guide covers the two ways teams pay, why an agent session costs what it does, how to measure spend per developer, repository and project, and where caps and default models belong.
The two ways teams pay for coding agents
Every coding agent bill falls into one of two shapes.
| Subscription seats | API keys billed per token | |
|---|---|---|
| Who bills you | Anthropic (Claude Team, Enterprise) or OpenAI (ChatGPT plans) | Your provider account: Anthropic Console, Bedrock, Vertex, Foundry, OpenAI API |
| What you pay for | A seat with a usage allowance | Every input, output, cache and thinking token |
| Limits | Rolling usage windows per seat | Rate limits and spend limits you set |
| Per-person reporting | The vendor's admin analytics | Whatever you measure: provider workspaces, OpenTelemetry, a gateway |
| Fits | Interactive work by people | CI jobs, automation, heavy users you want to cap individually |
On Claude for Teams and Enterprise, each member's Claude Code usage draws from a per-seat allowance that resets on a rolling five-hour window and a weekly window, shared with Claude chat1. On the Claude Console and on cloud providers, usage is billed per token to the organization, and if an organization mixes sign-in methods, each developer is metered by the one they authenticated with1.
OpenAI describes the same split for Codex. Signing in with a ChatGPT plan uses the plan's included usage, and OpenAI says the number of messages "depends on the model used, size and complexity of your tasks"2. API-key usage "follows API pricing", is recommended for automation in shared environments such as CI, and has no cloud-based features such as GitHub code review2.
Why does an agent session cost what it does?
A chat message is one request. An agent turn is many: each time the agent reads a file, runs a test or calls a tool, it sends another request carrying the results. Anthropic puts it directly: Claude Code "sends your full conversation with every request", so a one-line question in a session that has been open all day still draws usage for the whole conversation1. Five mechanics decide the size of that bill.
Context resend and caching
Because history is resent, input tokens dominate. Prompt caching makes the resent prefix much less expensive: on Anthropic's API a cache hit is billed at 0.1x the base input rate, and at 0.05x on Claude Opus 5.5 and Claude Sonnet 5.5, while a five-minute cache write costs 1.25x4. The catch is the cache lifetime. On an API key or cloud provider it is five minutes by default, so the first message after a coffee break misses the cache and reprocesses the full context1. The arithmetic is in our prompt caching break-even guide.
Model choice
Anthropic's own advice is that Sonnet handles most coding tasks and costs less than Opus, with Opus reserved for complex architectural decisions or multi-step reasoning; simple subagent tasks can run on Haiku1. OpenAI tells Codex users the same thing in its own words: if usage is higher than expected, consider whether a smaller model or tighter task scope would still produce a useful result2. Published list rates for the main coding models are compared in Coding models compared.
Thinking effort
Thinking tokens are billed as output tokens, and Anthropic notes the default budget can be tens of thousands of tokens per request depending on the model1. Lowering the effort level for routine work is one of the few levers that cuts output cost rather than input cost.
Parallel subagents and agent teams
Every subagent sends its own requests on top of the main conversation's1. Anthropic states that agent teams use approximately 7x more tokens than standard sessions when teammates run in plan mode, because each teammate maintains its own context window1. Parallelism buys wall-clock time with tokens.
Context you did not ask for
MCP servers, large instruction files and idle background work all add input. OpenAI notes that every MCP server adds more context to Codex messages2; Anthropic recommends keeping CLAUDE.md under 200 lines and moving workflow-specific instructions into skills that load on demand1. Scheduled tasks and goal check-ins fire while a session sits idle, sending the full context each time1.
How to measure spend per developer, repository and project
What you can see depends on how people sign in. Anthropic's table is the clearest map: Team and Enterprise plans have a spend report in org analytics; the Claude Console has a usage page, a Claude Code dashboard and an analytics API; on Bedrock, Vertex or Foundry, per-user numbers come from OpenTelemetry or an LLM gateway1. Claude Code's own /usage figure is computed locally at list price unless an administrator sets contracted rates in managed settings, and Anthropic calls it an estimate, not the invoice1.
For per-token billing, three rules produce useful numbers without anyone filling in a spreadsheet:
- One credential per developer, one per automated agent. Anthropic's gateway rollout steps say the same: issue each developer a gateway credential so usage is attributed and offboarding revokes one credential3. A shared key turns every question about spend into an argument.
- A tag per repository or workflow. Claude Code sends extra headers from
ANTHROPIC_CUSTOM_HEADERS; Codex adds static headers fromhttp_headersinconfig.toml5. Commit the setting with the repository, and every request carries its origin. - A project per budget owner. Group keys into projects that match how money is actually approved: a team, a product line, a client engagement. Cost attribution covers the tagging model in more depth.
Then report on three numbers per developer: spend per active day, the share of input served from cache, and the share of spend on the most expensive model. The first finds outliers, the second finds sessions that are never cleared, and the third finds an Opus default nobody chose on purpose.
Set caps, alerts and default models
A cap that fires after the invoice is a report. A cap that refuses the next request is a control. The difference matters more for agents than for chat, because an agent in a loop can spend a day's budget in minutes; bounding agent loops covers step and time limits on the agent side.
- Per-developer caps. On seats, the allowance is the default ceiling, and extra usage past it can be limited per organization, group or member1. On API keys, Anthropic workspaces take spend limits and a workspace rate limit, which Anthropic suggests using to cap Claude Code's share and protect other production workloads1.
- Rate limits sized to the team. Anthropic publishes per-user tokens-per-minute recommendations that fall as teams grow, from 200k to 300k per user for 1 to 5 users down to 10k to 15k for 500 or more, because fewer users run Claude Code at the same moment in large organizations1.
- Alerts before the cap. Alert at 50% and 80% of a monthly limit so the owner can raise it on purpose. Spend controls explains how hard caps and soft alerts fit together.
- Default models by policy. Set the default model and effort in managed settings, and allow the expensive model only where someone asked for it. Anthropic notes that unexpectedly high API spend usually traces back to long sessions that were never cleared or to Opus left as the default1.
The API-key route through a gateway
Both agents can point at a different base URL. Claude Code reads ANTHROPIC_BASE_URL and sends any gateway that exposes a supported API format its requests3. Codex takes a custom provider in config.toml with base_url, env_key and wire_api, where responses is the only supported value5. Anthropic lists what a gateway gives an organization: provider keys stay server-side, usage is attributed by developer or team, budgets and rate limits are enforced in one place, and every request can be logged3. It also names the tradeoff: the gateway becomes infrastructure your organization operates, and it must forward what each new Claude Code release sends3.
Anthropic also states that it does not support routing Claude Code to non-Claude models through any gateway3. Use a gateway for credentials, attribution, caps and failover between Claude providers, not to swap the model under the agent.
INFRO serves both shapes: POST /v1/messages in Anthropic's Messages format and POST /v1/responses in OpenAI's Responses format, on your organization's own provider accounts. Give each developer an INFRO gateway key with a spend limit; requests that limit cannot cover are refused with 402 before the provider is called, and the request log shows estimated provider cost per key, project and workflow tag. On an Anthropic connection, or Claude on Vertex AI, the body Claude Code sends reaches the provider as written, including cache_control breakpoints and thinking blocks, so caching behaves as it does direct. Your provider bills you for the tokens; INFRO's subscription is separate and adds nothing to them. The configuration is from the Claude Code and Codex docs page:
# Claude Code: shell, or the env block of managed settings
export ANTHROPIC_BASE_URL="https://api.infro.io"
export ANTHROPIC_AUTH_TOKEN="sk_infro_..."
export ANTHROPIC_CUSTOM_HEADERS="X-INFRO-Workflow: claude-code"# Codex: ~/.codex/config.toml
model_provider = "infro"
[model_providers.infro]
name = "INFRO"
base_url = "https://api.infro.io/v1"
env_key = "INFRO_API_KEY"
wire_api = "responses"
http_headers = { "X-INFRO-Workflow" = "codex" }For failover, give Claude Code's route Claude targets on more than one provider, such as Anthropic and Claude on Vertex AI; those are served as written. Model allowlists on the key keep a developer's default from drifting to a model nobody approved.
A rollout plan that keeps the numbers honest
- Pick five to ten developers who use the agent daily. Issue each a personal key with a modest monthly limit and a repository header.
- Run two weeks. Record spend per active day, cache share and model mix per person.
- Compare the pilot with Anthropic's published averages1. Investigate anyone well above them before you set team-wide limits: it is usually one long session or one default model.
- Set the team's limits from the pilot, with alerts below each cap, and decide per person whether seats or API keys fit.
- Review monthly. Models, cache rates and agent features change quickly, and so does the bill.
