Playbooks · Coding tasks
Use your own Anthropic API key with an agent: what it costs, and the billing trap to check first
Written October 31, 2026 · Edited November 12, 2026
For a builder deciding between a Claude subscription allowance and their own Anthropic API key: the key route bills per token against prepaid credits in a Console organization, with no monthly allowance to fall back on. Check which route a run is on before the first long job, and set the limit before it starts.
Two meters, and the credential decides
A Claude subscription and an Anthropic API key are two different meters. A subscription — Pro at $20 a month billed monthly, Max at $100, Ultra at $200 — buys usage limits: Pro and Max carry a five-hour session window and a weekly limit, and Ultra carries a weekly limit — verified Ultra accounts have no five-hour session limit. The limits are shared across Claude on web, desktop, and mobile and Claude Code, all drawing from one pool. Anthropic's pricing page states the shared pool plainly, and that Claude Code is included in paid plans. An API key buys tokens: every request bills per million input and output tokens against prepaid credits held by a Console organization, and there is no allowance inside that meter. The same Claude Code install can land on either meter depending on how it is signed in, so the first question about any run is never which model it used, but which meter it billed.
Anthropic's own pricing page also lists the switch between the two: for heavy coding sessions, you can switch to pay-as-you-go API credits through a Console account. That sentence is the whole key route in one line. It is also where the trap sits, because a subscription and a key can both be present on one machine, and a run bills to whichever credential the tool actually used. Confirm the route from the usage record after a small run, before trusting a long one.
What the key route costs
Per-token prices below are Anthropic's standard API rates for the current models, per million tokens, in US dollars, as stated on Anthropic's model pages. Output costs more than input on every model, so a run that writes long answers costs several times what its prompt suggests.
- Claude Sonnet 5.5 — $2 input, $10 output per million tokens. The everyday coding model, and the one most key-route runs should start on.
- Claude Opus 5.5 — $4 input, $20 output per million tokens. The stronger model, at double the Sonnet rates.
- Claude Haiku 5.5 — $0.10 input, $0.50 output per million tokens for prompts up to 100,000 tokens; $0.50 input, $2.50 output for longer prompts. The cheap route for high-volume, short-prompt work — and the model whose price jumps fivefold past the prompt-length line.
- Claude Fable 5.2 — $8 input, $40 output per million tokens, as stated on Anthropic's Fable page. The current Fable and the most expensive standard rate a key-route run is likely to pick — and the one it should never reach by accident. Anthropic's pricing docs still list Fable 5.1 at $10 input, $50 output, and fast mode for Fable 5.2 at $16 input, $80 output.
Anthropic also states savings of up to 90% with prompt caching and 50% with batch processing on the Sonnet page. Those are ceilings for repeated prompts and deferred work, not the rate a live agent session pays. A rough sense of scale, from the Sonnet rates alone: one million input tokens and half a million output tokens cost $2 plus $5, or $7. A session that reads a large codebase and writes long replies several times an hour reaches tens of dollars in a day without anything going wrong. That is the normal price of the key route, not a malfunction.
The trap: monthly API credits do not pay for Claude Code
Max and Ultra plans include a monthly API credit to build on the Claude Platform: $100 a month on Max, $200 on Ultra, as Anthropic's pricing page states. It is easy to read that as $100 of Claude Code usage. It is not. The credit pays for building on the API — your own applications and agents, the Agent SDK, and the Console playground. Interactive Claude Code sessions draw from the subscription's usage limits, not from the credit, and the credit does not raise those limits. A Max subscriber who cancels an API budget expecting the credit to cover terminal sessions will find the sessions still hitting plan limits, while the credit sits unused on API work they may never do.
The same split applies in the other direction. Unused credit expires at the end of each billing cycle rather than building up, so a credit is worth claiming only for API work you already plan to do. If the work is interactive coding sessions, the subscription allowance is the meter that matters, and the credit changes nothing about it. Before counting the credit as savings, name the API work it would pay for. If there is none, it is not savings.
Before the first long run
- Set the limit first. In the Console organization that owns the key, set a spend limit below what you are willing to lose, in a separate workspace for the experiment, with its own key. The exact steps are in Stop an agent running up a bill — do them before the run, not after the first surprising bill. A limit set after a runaway job has already started is a report, not a control.
- Run something small, then read the usage record. One short task on Sonnet 5.5, then open the Console usage record and confirm the tokens and the cost appear under the organization and workspace you intended. If the run does not appear, it billed somewhere else — stop and find out where before running anything longer.
- Start on the cheapest model that can do the job. Haiku 5.5 for short, high-volume prompts; Sonnet 5.5 for everyday coding. Move to Opus only for work that Sonnet visibly mishandles, and never let a default model choice put Fable on an unattended loop.
- Price the loop, not the call. An agent loop makes many calls. Estimate calls per task from the small run, multiply by the per-token rates above, and compare the result with the subscription allowance you would otherwise use. The key route wins for unattended, scheduled, or bulk work that would stall on the plan's session and weekly limits; the subscription wins for a person driving the tool through the day. That comparison, done with your own numbers, is the decision — not the headline price of either meter.
What can go wrong
- Running on the wrong meter. A key left active on a machine bills the Console organization even when the person at the keyboard believes they are on their plan. The usage record is the only reliable answer to which meter a run used.
- Long prompts on Haiku. Past 100,000 tokens, Haiku 5.5 bills at five times its short-prompt rate. A loop that grows its context past that line quietly quintuples its input price.
- Counting the API credit twice. The credit pays for API work and expires each cycle. Counting it against Claude Code sessions, or carrying it forward as a balance, overstates what is available in both directions.
- No limit on an unattended loop. A scheduled or looping job with a key and no spend limit is the one shape of run that can produce a bill nobody expected. The limit is the job, not an extra.
Related playbooks
- Check where your coding agents store API keys on your own machine
- Z.ai / MiniMax Anthropic API endpoints
- Anthropic's no-distillation rule lands November 12
- Check whether your Claude Code hooks are adding tokens to every prompt or cutting them
Sources
- https://claude.com/pricing
- https://www.anthropic.com/claude/sonnet
- https://www.anthropic.com/claude/opus
- https://www.anthropic.com/claude/haiku
- https://www.anthropic.com/claude/fable
Back to: Coding playbooks hub · Also: Token cost calculator · Agent cost estimator · What an agent costs, in plain figures · Stay inside the subscription allowance · Stop an agent running up a bill