Claude Subscription vs API for Coding: How to Choose
Claude subscription vs API comes down to how steady your usage is. See how each is billed, how the cache TTL differs, what drives Claude Code cost and how to track it.

Claude subscription vs API for coding comes down to how steady your usage is. A subscription gives you a fixed monthly price and an allowance that resets in windows, which suits people who code most days. The API bills per token, which suits irregular, automated or tightly measured use, and Claude Code works with both.
How is each one billed?
Anthropic's pricing pages, read on 4 October 2026, describe two separate products.
| Subscription (Pro, Max) | API (Claude Console key) | |
|---|---|---|
| Price | Pro is $20 per month billed monthly, or $17 per month billed annually ($200 up front). Max starts at $100 per month for 5x Pro's per-session usage, and Anthropic's Max help page lists the 20x tier at $200. | Per million tokens, by model |
| What limits you | Session and weekly usage limits, shared with Claude chat | Your spend and your organisation's rate limits |
| Past the limit | Optional usage credits, billed at standard API rates | Nothing to run out of, so the bill keeps growing |
| Claude Code | Included in Pro and Max. The Free plan does not include it. | Included, billed on tokens |
| Terms | Consumer Terms (Free, Pro, Max) | Commercial Terms (Team, Enterprise, API) |
The API pricing page lists list prices per million tokens. These are the models Claude Code maps to its tiers today.
| Model | Input | 5-minute cache write | 1-hour cache write | Cache read | Output |
|---|---|---|---|---|---|
| Haiku 4.5 | $1 | $1.25 | $2 | $0.10 | $5 |
| Sonnet 5.5 | $2 | $2.50 | $4 | $0.20 | $10 |
| Opus 5.5 | $4 | $5 | $8 | $0.20 | $20 |
| Fable 5.1 | $10 | $12.50 | $20 | $0.25 | $50 |
Models and prices change, so check the page before you budget. One trap deserves a warning. If ANTHROPIC_API_KEY is set in your environment, Claude Code uses that key after you approve it, and Anthropic's help article says this produces API charges instead of using your subscription. Run /status to see which credential is active, and unset ANTHROPIC_API_KEY to return to the subscription.
Which usage patterns favour each option?
| Pattern | Better fit | Why |
|---|---|---|
| Coding most days in long sessions | Subscription | A flat price, with limits that reset on a schedule |
| A few sessions a month | API | You pay only for the tokens you use |
| One busy week, then nothing | API | No monthly fee in the quiet weeks |
| CI jobs, scripts, products built on Claude | API key | Anthropic says developers building products should use API key authentication |
| Several providers behind a gateway | API keys | A gateway needs credentials it can forward |
| A team | Team or Enterprise plan, or the Console | Admin controls and spend limits |
A rough break-even helps. Anthropic's cost documentation reports an average of about $13 per developer per active day and $150 to $250 per developer per month across enterprise deployments, with 90% of users below $30 per active day. At that average, eight active days cost about $104, which is already above Max's starting price. Treat the arithmetic as rough for two reasons. An enterprise average is not your number, and plan allowances are not published in dollars or tokens, so you cannot convert one to the other exactly. Run /usage for a few weeks and decide with your own data.
How do long sessions and context size drive cost?
Claude Code re-sends the whole conversation on every turn, and each batch of tool results triggers another request. Anthropic's cost docs say that a one-line question in a session open all day still draws usage for the whole conversation. Prompt caching makes the re-read cheaper by billing it at the cached token rate. This example is our own arithmetic from the list prices above, for a 200,000-token context and input tokens only. Output is billed on top.
| Event | Sonnet 5.5 | Opus 5.5 |
|---|---|---|
| Warm turn (cache read) | $0.04 | $0.04 |
| Cold return, 5-minute cache write | $0.50 | $1.00 |
| Cold return, 1-hour cache write | $0.80 | $1.60 |
| For reference, uncached input | $0.40 | $0.80 |
The habits that follow from this come straight from Anthropic's docs:
- Run
/clearbetween unrelated tasks, because stale context is paid for on every later message. - Run
/compactat natural breaks. After a long idle gap it reprocesses the full history uncached, so it costs the most then. - Pick the model and effort level at the start. Each model has its own cache, so switching mid-task makes the next request read everything without cache hits.
- Disable MCP servers you are not using.
What is the prompt-cache TTL difference?
The cache expires after a period of silence. According to Anthropic's prompt caching page for Claude Code, the main conversation gets a one-hour TTL on a Claude subscription within your plan's included usage, and a five-minute TTL on an API key, on usage credits or on a cloud provider. Subagents, compaction and most other side requests get five minutes even on a subscription unless you choose otherwise.
The multipliers on the pricing page are 1.25x the input price for a 5-minute write, 2x for a 1-hour write and 0.1x for a read (0.05x on Opus 5.5 and 0.025x on Fable 5.1). A five-minute cache pays for itself after one read, a one-hour cache after two. On an API key you can ask for the longer TTL, which needs Claude Code v2.1.242 or later:
export CLAUDE_CODE_PROMPT_CACHE_TTL=1h
The same choice exists as promptCacheTtl in settings. To confirm what you got, run claude -p "hello" --output-format json and read usage.cache_creation, where one-hour writes appear as ephemeral_1h_input_tokens. The longer TTL helps when you leave sessions idle and come back. It costs more on short bursts that never idle past five minutes.
Our Claude Cache Warm plugin keeps idle sessions warm. Its README gives this example at list prices: an 800K-token context on Opus 5 with a one-hour cache costs about $0.40 for a keep-alive ping and about $8.00 for a cold return after 90 minutes. Each ping is a real model turn, so on a subscription it counts against your limits. For the basics, see prompt caching explained.
Can cheaper tiers use cheaper models?
Yes, in two ways. Inside Claude's own lineup, Sonnet 5.5 lists at half the per-token price of Opus 5.5 for both input and output. Anthropic's docs suggest Sonnet for most coding tasks, Opus for complex reasoning and model: haiku in a subagent's configuration for simple subagent work. The opusplan setting plans with Opus and executes with Sonnet, but each plan-mode toggle is a model switch that starts a fresh cache.
The second way is a gateway that maps tiers to models from other providers. Two cautions apply. While a gateway credential is active, requests carry that credential instead of your subscription login, so that traffic is billed per token to the credential's owner and your plan limits do not apply to it. And Anthropic does not support routing Claude Code to non-Claude models. We describe the setup in Claude Code with other models, and the routing logic behind it in how we cut LLM costs by 99%.
How do you monitor what Claude Code costs?
/usage. The Session block shows token usage and a dollar estimate computed locally at list price, which Anthropic intends for API users. Subscribers see plan usage bars and a breakdown by skills, subagents, plugins and MCP servers, with flags for behaviours such as long context and cache misses. APrompt cache (main)line shows your hit ratio and whether the cache is warm.- The Claude Console. Its usage page and workspace spend limits are the authoritative record for API billing.
/usage-credits. On a subscription it opens the page where you check credit spend and set a monthly limit.- Claude Session Guard. This plugin keeps an append-only mirror of your transcripts, because Claude Code deletes transcripts older than
cleanupPeriodDays, 30 days by default. It builds a SQLite store of token-usage events, de-duplicated per line and per message, with hourly, daily, weekly and monthly CSV rollups per model. A model without a price row shows $0, which means unpriced. - Claude Cache Warm's dashboard. It mines your own transcripts for hit ratio and cold rebuilds.
- A gateway's request log. If you route through My Claude Code, every request is logged with its cost.
Can you use a subscription inside third-party tools?
Check Anthropic's terms first, because this part is easy to get wrong. Anthropic's legal and compliance page says OAuth authentication is intended exclusively for purchasers of subscription plans and designed to support ordinary use of Claude Code and other native Anthropic applications. Developers building products or services, including with the Agent SDK, should use API key authentication. It also says Anthropic does not permit third-party developers to offer Claude.ai login in their own applications, or to route requests through Free, Pro or Max plan credentials on behalf of their users, and that developers may not collect, store or intermediate Claude.ai credentials. The advertised limits for Pro and Max assume ordinary, individual usage of Claude Code and the Agent SDK, and Anthropic may enforce these rules without prior notice.
Our rule is simple. Use your own subscription inside Anthropic's own apps, use an API key for third-party tools, gateways and automation, and never share or resell an account. The My Claude Code README marks its Claude subscription login option with a caution, and its documentation recommends a Console API key instead. A blog post is not legal advice, so read the terms that apply to your account.
Where Danube Labs fits
Danube Labs is a founder-led software, AI and automation studio in Bucharest. We built Claude Cache Warm and Claude Session Guard, two free MIT-licensed plugins, to make the cost drivers above visible. If you want the same measure-first approach applied to an AI feature in your own product, book a free intro call.
Frequently asked questions
- Is Claude Pro enough for Claude Code?
- Pro includes Claude Code at $20 per month billed monthly, or $17 per month billed annually. Its usage limits are shared with Claude chat, so how far it goes depends on how long your sessions run and how large your context grows. Run /usage for a few weeks. If you hit limits often, compare Max or pay-per-token API billing.
- Is Claude Max worth it for Claude Code?
- Max starts at $100 per month and offers 5x or 20x Pro's per-session usage. It pays off if you code most days and keep hitting Pro limits. If you code a few days a month, per-token API billing may cost less. Anthropic does not publish plan allowances in dollars, so measure your own usage with /usage first.
- How much does Claude Code cost?
- Claude Code bills by token on the API, or draws on a plan allowance on a subscription. Anthropic reports an average of about $13 per developer per active day and $150 to $250 per developer per month across enterprise deployments, with 90% of users under $30 per active day. Your cost depends on model, codebase size and session length. Check it with /usage.
- What is the prompt cache TTL on a subscription versus the API?
- According to Claude Code's docs, the main conversation gets a one-hour TTL on a subscription within plan usage, and five minutes on an API key, usage credits or a cloud provider. On an API key you can request one hour with promptCacheTtl or CLAUDE_CODE_PROMPT_CACHE_TTL=1h on Claude Code v2.1.242 or later.
- Can I use my Claude subscription in third-party tools?
- Check Anthropic's terms first. Anthropic says OAuth is intended for ordinary use of Claude Code and its native applications, and that it does not permit third-party developers to route requests through Free, Pro or Max plan credentials on behalf of their users. For third-party tools, gateways and automation, use an API key from the Claude Console.
- Does setting ANTHROPIC_API_KEY switch Claude Code to API billing?
- Yes. If ANTHROPIC_API_KEY is set, Claude Code asks you to approve the key and then uses it instead of your subscription login, so usage is billed per token. Run unset ANTHROPIC_API_KEY to fall back to the subscription, and use /status to see which credential is active.


