Skip to main content

Claude Code API Billing vs Subscription: API Key, Credits, or Pro/Max?

A
11 min readClaude Code

Decide whether Claude Code should use subscription login, an API key, or paid usage credits, and learn why /status matters before you change plans.

Claude Code API Billing vs Subscription: API Key, Credits, or Pro/Max?

Normal Claude Code use on a Claude Pro or Max plan still does not require an API key. If ANTHROPIC_API_KEY is set, Claude Code can prioritize that key and move the session onto API billing; if you enable paid usage credits after included plan limits, later use can continue at standard API rates. The first question is not which route is cheapest, but which route is active.

Before you change plans or buy credits, run /status. Use subscription login for interactive coding covered by your Claude plan, use an API key for SDKs, CI, headless automation, or deliberate pay-as-you-go API work, and treat paid usage credits as an explicit overflow or API-route choice rather than hidden subscription allocation.

Your situationRoute to useWhat bills itFirst check
You are coding interactively in Claude Code with Pro or MaxSubscription loginIncluded Claude plan usage, subject to plan limits/status should show a subscription/account login route
You set ANTHROPIC_API_KEY or run Claude Code in automationAPI key routeClaude API usage billed from ConsoleCheck the environment variable and Console Usage
You enabled paid usage credits after plan limitsUsage-credit continuationAdditional usage billed at standard API rates, separate from the plan chargeCheck Settings > Usage and Console Billing
You see unexpected API spendDiagnose before buying another planThe API key may be overriding subscription behaviorecho $ANTHROPIC_API_KEY, then /status

Start With The Active Route

Three Claude Code billing routes: subscription login, API key, and API credits

The right answer depends on what Claude Code is actually using at runtime. Anthropic's current Claude Code support docs separate subscription credentials, environment API keys, and paid usage-credit continuation after included plan limits. Those routes can coexist on the same machine, but they do not share the same billing owner.

For a normal developer working in the terminal, the clean default is subscription login. That keeps Claude Code tied to your Claude account and the plan limits described for Pro or Max. It is the path to choose when the job is interactive coding, code review, refactoring, or repo exploration and you do not need a backend service account.

The API key route is different. If you set ANTHROPIC_API_KEY, Anthropic's support page says Claude Code prioritizes that key over authenticated subscriptions, and the API account associated with the key owns billing. That is useful when you intentionally need programmatic access, a CI job, a headless agent, a service account style setup, or a workflow that should be controlled from Claude Console rather than a personal subscription session.

Usage credits are a third contract. Claude's paid-plan help says Pro, Max 5x, and Max 20x users can enable credits to continue after included limits, with subsequent usage billed at standard API rates and shown separately from included plan usage. They are not a hidden bucket inside Claude Pro or Max, and Claude Code transitions to API-credit usage should require explicit user confirmation.

Check The Route Before You Read Any Meter

The fastest safe sequence is short:

bash
claude /status echo "$ANTHROPIC_API_KEY"

Start with /status because it tells you which account and route Claude Code is currently using. If the status points to your subscription login, interpret plan limits and usage through the subscription lens. If the status points to an API route, the Console account and its usage ledger become the billing source of truth.

Then check the environment. A shell variable can be easy to forget because it may come from .zshrc, .bashrc, .env, a terminal profile, a CI secret, a devcontainer, or a launcher script. If echo "$ANTHROPIC_API_KEY" prints a value, do not paste it anywhere and do not share screenshots. The important fact is simply that a key is present.

Use these commands when you want to switch back to subscription behavior in the current shell:

bash
unset ANTHROPIC_API_KEY claude logout claude login claude /status

That sequence does not delete keys from Claude Console. It only removes the current shell override, resets the local Claude Code session, and lets you verify that the next session is using the intended login path. If the key keeps coming back, search your shell startup files and project environment files rather than buying another subscription tier.

Why API Billing Appears On A Subscribed Account

A Claude subscription and Claude API billing are separate products. Claude Pro or Max can let you use Claude Code through Claude credentials, but that does not mean the plan includes general API calls. Anthropic's Pro/Max Claude Code support article now also separates included plan allocation, optional usage credits, and Claude Console auto-reload settings.

The confusing part is that Claude Code can sit at the intersection. The same local tool can be used interactively with a subscription login, or it can be pointed at an API key for API-account usage. When those paths are mixed on the same machine, the route in effect matters more than the plan you assume you are using.

Here is the practical cause map:

CauseWhat happenedWhat to do
ANTHROPIC_API_KEY is setClaude Code can prioritize the API key over subscription authUnset it and verify /status
A CI or automation job runs Claude CodeThe job cannot rely on a human subscription sessionUse an API key deliberately and budget it in Console
Usage credits were enabled after plan limitsYou chose to continue beyond included plan usage at standard API ratesMonitor Settings > Usage and Console Billing
/usage or /cost shows a dollar estimateThe command is showing API-style token/cost contextDo not treat it as the final bill for subscription sessions
Subscription limits are still hitPlan usage and API billing are separate questionsRead plan-limit troubleshooting, not API-key setup

The main mistake is trying to solve every surprise charge by upgrading Claude Pro to Max, or trying to solve every plan-limit message by buying usage credits. Those are different knobs. If /status says subscription, look at subscription limits and Settings > Usage. If /status says API, look at environment variables and Console usage.

For broader plan-limit behavior, use the sibling guide on Claude Code usage limit issues. Keep the billing-route diagnosis separate from plan-limit troubleshooting so you do not change the wrong contract.

Which Meter Should You Trust?

Claude Code meter map for status, usage, cost, and Console Usage

Claude Code has several useful meters, but they do not all answer the same question.

/status is the route check. Use it first because it tells you whether the session is tied to a subscription/account login path or an API route. If you skip this step, every other number is easier to misread.

/usage is useful for subscribers who want to understand plan usage bars and activity patterns inside Claude Code. If your installed version or team habit still refers to /stats, treat it as a usage-pattern surface, not as a Console invoice.

/cost, or the dollar figure shown in usage output, is mainly useful for API-style cost estimation. Claude Code's cost docs caution that local dollar figures are estimates and that Console Usage is authoritative for API billing. For Pro or Max subscription sessions, do not read the estimate as your subscription bill.

Claude Settings > Usage is the subscriber place to distinguish included plan usage from usage-credit consumption. Claude Console Billing and Usage are authoritative for API-route spend, project ownership, auto-reload, and API credits. If a team asks "which project paid for this?", the answer should come from Console, not from a screenshot of a local Claude Code session.

For a team runbook, capture the /status route plus the Settings or Console ledger, because those two facts prove both the active route and the billing owner.

When An API Key Is The Right Route

An API key is correct when the work is actually API work. That includes SDK calls, server-side agents, scheduled jobs, CI tasks, non-interactive Claude Code runs, shared team automation, evaluation harnesses, and any workflow where a Console project, spend limit, and usage ledger are more appropriate than a personal subscription login.

The API route is also the right choice when you need to make usage auditable. A subscription login may be convenient for a single human developer, but it is a weak fit for a production job that needs project-level tracking, budget controls, and repeatable deployment.

Use an API key deliberately when these are true:

  • the run should continue without a human browser login
  • the owner should be a Console project rather than a personal plan
  • spend should show up in Console Usage
  • the workflow is SDK, backend, CI, agent, or batch oriented
  • you are comfortable paying standard Claude API rates for the model used

Do not use an API key as a workaround for a plan-limit message until you understand the route change. It can be a valid escape hatch, but it changes the billing contract. A reader who only wants fewer interruptions in interactive Claude Code should compare plans first, using a page like Claude Code Pro vs Max.

How Usage Credits And Prices Fit In

Paid usage credits let Claude Pro, Max 5x, and Max 20x users continue after included plan limits, but that continuation is billed separately at standard API rates and should be visible apart from included usage. Claude Console credits and auto-reload still matter for API-route work, so a local Claude Code session is not where you should diagnose the payment instrument.

As of May 25, 2026, Anthropic's public pricing page lists current model prices by input and output tokens. For example, the page lists Claude Sonnet 4.6 at $3 per million input tokens and $15 per million output tokens, while Claude Opus 4.7 is listed at $5 per million input tokens and $25 per million output tokens. Treat those as date-bound examples, not as a permanent article spine, because model names, regional multipliers, fast mode, and rates can change.

The decision is not "API is cheaper" or "subscription is cheaper" in isolation. The decision is workload shape:

WorkloadBetter defaultWhy
A human developer working in a repo for a few hoursSubscription loginPredictable plan route and fewer billing surprises
Heavy interactive Claude Code usage with recurring limit frictionCompare Pro vs Max firstThe problem is likely plan capacity, not API key setup
CI job that must run without a human loginAPI key routeConsole project ownership and auditable usage
Backend app or SDK integrationAPI key routeThe app is making API calls, not using Claude Code as a personal tool
Exploring whether Claude API has free creditsSeparate API free-tier questionUse the Claude API key free tier guide
Reaching included Pro/Max limits and choosing to continueUsage-credit continuationConfirm the prompt, cap, and Settings > Usage ledger first

If you only need the latest pricing rows, go directly to Anthropic's pricing page. If you need the broader plan and usage tradeoff, use the Claude Code pricing guide. The narrower route question is which account is billing Claude Code right now.

How To Switch Back To Subscription Use

Claude Code checklist for unexpected API billing and environment variable recovery

If you expected subscription use but see API billing, do not start by deleting keys in Console. First prove whether the local environment is steering Claude Code to API mode.

Use this checklist:

  1. Run /status inside Claude Code and record whether the active route looks like subscription login or API usage.
  2. In the same terminal, run echo "$ANTHROPIC_API_KEY" and check whether any value is set.
  3. If a key is set and you want subscription behavior, run unset ANTHROPIC_API_KEY.
  4. Run claude logout, then claude login, and authenticate with the Claude account that has Pro or Max.
  5. Run /status again before starting real work.
  6. If the key returns after opening a new terminal, remove it from shell startup files, project env files, launch agents, CI secrets, or container configuration.

This is a small workflow, but it prevents a common double-pay pattern: the reader keeps a subscription for interactive work, sets an API key for one test, forgets the variable, and later assumes Claude Code is still using the plan.

If your team intentionally wants both routes, write it down. A simple convention is enough: subscription login for local interactive coding, API key for automation, and Console Usage for API spend review.

What Not To Mix Up

Do not say "Claude Code is free" just because you can log in with a paid plan. The plan has limits, and API usage has separate billing.

Do not say "Pro includes API calls." Pro or Max can cover Claude Code usage through Claude credentials, but general API access is a Console billing contract.

Do not treat /cost or a local dollar estimate as the final word for subscription billing. It is useful context, especially for API-style work, but /status, /usage, Settings > Usage, and Console Usage each answer different questions.

Do not paste a real API key into tickets, chat, screenshots, or troubleshooting prompts. If a support path needs proof, show whether the variable exists and which route /status reports, not the secret value.

Do not use community answers as billing authority. Forums are useful for seeing which confusion is common, but the current billing contract should come from Claude and Anthropic docs.

Sources And Verification Path

These route and billing facts are based on the current official Claude and Anthropic documentation checked on May 25, 2026:

  • Claude Help on managing ANTHROPIC_API_KEY and other API-key environment variables in Claude Code.
  • Claude Help on using Claude Code with Pro or Max plan credentials.
  • Claude Help on usage credits for paid Claude plans, including Claude Code terminal usage.
  • Claude Code docs for cost tracking and the difference between /status, /usage, local cost estimates, and Console Usage.
  • Anthropic pricing docs for date-bound API price examples.

For your own account, use the same order: /status first, environment variable second, Settings > Usage or Console Usage third. That order gives you a route answer before you make a plan or payment decision.

FAQ

Do I need an API key to use Claude Code?

Not for normal interactive use with Claude Pro or Max. Claude Code can connect through your Claude credentials. You need an API key when the workflow should run through the Claude API route, such as SDK work, CI, automation, or a Console-owned project.

Why is Claude Code billing my API account when I have Pro or Max?

The most likely reason is that Claude Code is using the API route. Check /status, then check whether ANTHROPIC_API_KEY is set in the shell or runtime that launched Claude Code. If that variable is present, the API account can become the billing owner.

Are Claude usage credits the same as subscription usage?

No. Usage credits let paid-plan users continue after included limits and are charged separately at standard API rates. Subscription usage still belongs to the Claude plan route and has its own included allocation and reset behavior.

Should I use API billing instead of upgrading to Claude Max?

Only if your work is really API-shaped. For local interactive coding, compare Pro and Max first. For CI, SDKs, backend agents, or auditable team automation, API billing is often the cleaner contract.

Is /cost or /usage showing my Pro or Max bill?

No. Treat a local dollar figure as an API-style token cost estimate. Use /status to identify the active route, /usage and Settings > Usage to understand subscription usage or usage-credit consumption, and Console Usage for API billing.

How do I stop Claude Code from using my API key?

Unset ANTHROPIC_API_KEY, log out of Claude Code, log in with your Claude account, and run /status again. If the key returns in a new terminal, remove it from shell startup files, project env files, CI secrets, or container configuration.

Share:

laozhang.ai

One API, All AI Models

AI Image

Gemini 3 Pro Image

$0.05/img
80% OFF
AI Video

Sora 2 · Veo 3.1

$0.15/video
Async API
AI Chat

GPT · Claude · Gemini

200+ models
Official Price
Served 100K+ developers
|@laozhang_cn|Get $0.1