Claude Code: API key or subscription? How to choose and switch

Claude Code bills either per token on an API key or flat on a Pro, Max or team plan. What changes, when each one fits, and how to switch without paying twice.

· 6 min read

Claude Code can be paid for in two ways: with a Claude subscription, where a monthly plan covers your usage up to its limits, or with an API key, where every token is billed. Picking one is a real decision, and there's a second problem hiding behind it: the choice is made by which credential Claude Code finds first, not by what you meant. Plenty of people pay for a plan and still get an API bill, because a key was sitting in their shell.

#What is the difference between an API key and a subscription?

Subscription (Pro, Max, Team, Enterprise)API key (Claude Console)
How you payA flat price per month, per seatPer token, at API rates
How you sign in/login with your claude.ai accountA Console account, ANTHROPIC_API_KEY or an apiKeyHelper script
LimitsA rolling 5-hour window and a weekly limit, shared with Claude chatRate limits of your Console organization, no usage windows
When you go overWait for the reset, or turn on usage credits billed at API ratesYou keep going, and keep paying
Cost controlFixed; nothing to watchSpend limits per workspace in the Console
Also includedClaude on the web, desktop and phoneNothing else
Remote Control, claude.ai connectorsYesNo, they need a claude.ai login

The short version: a plan trades a ceiling for a fixed price, an API key trades a fixed price for no ceiling.

#Which one is Claude Code using right now?

Run /status in a session, or claude auth status in a shell. It shows the login method and the account. If both a login and a key are configured, /status marks the one that isn't in use.

Claude Code takes the first credential it finds, in this order:

  1. Cloud provider credentials, when CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX or CLAUDE_CODE_USE_FOUNDRY is set
  2. ANTHROPIC_AUTH_TOKEN
  3. ANTHROPIC_API_KEY
  4. The output of an apiKeyHelper script
  5. CLAUDE_CODE_OAUTH_TOKEN
  6. Anthropic profile and federation credentials
  7. The subscription login from /login

Your plan comes last. That's the trap: if ANTHROPIC_API_KEY is set anywhere in your environment, Claude Code uses it once you approve it, and bills the API even though you pay for Max. Using several Claude accounts shows how to hunt it down.

#When does an API key make sense?

  • Your company wants a bill per token. Some teams need costs per project or per client. Console workspaces give you that, with a spend limit on each.
  • Usage is light or bursty. A few sessions a month cost less on the API than any plan. Measure first (see below).
  • You can't be stopped by a window. A long migration or an on-call fix at the end of a heavy week shouldn't wait for a reset. On a key, it doesn't.
  • You go through a cloud provider. Amazon Bedrock, Google Cloud and Microsoft Foundry are billed through your cloud account, which can matter for procurement or data residency.
  • Keys must rotate. An apiKeyHelper script can fetch a short-lived key from your vault; Claude Code runs it again every few minutes (the interval is yours to set) and whenever a key is refused.

What doesn't need an API key: scripts and CI on your own plan. claude setup-token makes a one-year token for a Pro, Max, Team or Enterprise account. Put it in CLAUDE_CODE_OAUTH_TOKEN and headless runs count against your plan. It only makes model requests: no Remote Control, no connectors.

#When does a subscription make sense?

  • You use Claude Code every day. Long interactive sessions re-send their context with every request; most of it is read from the prompt cache, but it adds up fast. A flat price absorbs that.
  • You want one number per month. Nobody on the team has to watch a meter.
  • You also use Claude chat. It comes with the plan, and the limits are shared.
  • You run several sessions or agents. That's heavy usage by design. A Max plan or team seats usually beat per-token billing for it; Claude Pro or Max helps pick the tier.

#How do you compare the two with your own numbers?

Guessing goes wrong in both directions. Measure a normal month:

  1. Count your tokens, by type and model. /usage shows the current session; the transcripts in ~/.claude/projects hold everything. Claude Code token usage shows how to add them up.
  2. Price them with Anthropic's current API price list, per model. What your usage would cost at API prices walks through the formula.
  3. Compare that monthly figure with the plan you'd pay for, at its current price on claude.com.

Then adjust for what the numbers don't show. On a plan, did you hit the limit and lose afternoons? Add what that time was worth. On the API, would you have kept going where a plan stopped you? Then your real API cost is higher than the history says. Use a month, not a day: usage is lumpy.

The rule that comes out of it: if your API-price equivalent is above the plan price, the plan wins, and by a wide margin for daily users. If it's below the plan price month after month, you're a light user, and a smaller plan or a key may do.

#What about a team with several seats?

Each person needs their own access, either way. A Pro or Max plan belongs to one person; it isn't a pool for a team.

  • Team or Enterprise plan. Each seat has its own allowance on the same 5-hour and weekly windows, shared with chat. Admins can add usage credits and spend limits, and read a spend report.
  • Console organization. One key per workspace or per person, spend limits per workspace, rate limits shared by the organization. Anthropic's costs page suggests how many tokens per minute to plan per user as the team grows.
  • Both. Seats for the people, a Console key for the bots: CI jobs, review bots, nightly runs. Bills stay readable, and a runaway script can't eat a teammate's window.

#How do you switch from one to the other?

From an API key to your plan:

env | grep -E 'ANTHROPIC_(API_KEY|AUTH_TOKEN)'   # is a key set?
unset ANTHROPIC_API_KEY                           # for this shell

Then remove the line that sets it: your ~/.zshrc or ~/.bashrc, a .envrc loaded by direnv, the env block of a settings.json, or an apiKeyHelper you no longer want. Run /login, choose your claude.ai account, and check /status.

From your plan to an API key: /logout, then /login and choose the Console account, or export ANTHROPIC_API_KEY in the shell that starts Claude Code and approve it on the first run.

Both, side by side: keep two config directories, one per credential, with CLAUDE_CONFIG_DIR. Each has its own login and its own sessions; an alias picks one:

alias claude-plan='CLAUDE_CONFIG_DIR=~/.claude claude'
alias claude-api='CLAUDE_CONFIG_DIR=~/.claude-api ANTHROPIC_API_KEY="$LARKSPUR_CONSOLE_KEY" claude'

Whichever way you go, the check is the same: /status before the first long task.

#In Relais

Relais runs on your Claude plan (Pro, Max or a team seat) and never on an API key. It removes ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN from what it starts, so nothing bills the API by accident, and it warns you if Claude Code still reports an API key or another provider. You can sign in several accounts of your own: new sessions start on the first with room, and a session that hits a limit carries on in the next, mid-task. The Token burn plugin shows what your usage would cost at API prices, per day and per model, which is the number you need for the comparison above. Relais is billed on its own, separately from your Claude plan. See Seats, Token burn and pricing.

Your AI team,
on your Claude plan.

$14.99 a month, everything included. On your Mac or on Linux, on your Claude Pro or Max plan. Cancel any time.