Checklist
Is an API key billing you instead of your Claude plan?
The short answer: in Claude Code, ANTHROPIC_API_KEY ranks above your Pro, Max or Ultra login. If the key is set and you approve it once, every session after that is billed to the key's Console organization at API rates. With claude -p there is no prompt at all: the key is used whenever it is present.
For anyone who pays for a Claude subscription and has ever created an Anthropic API key. Takes about five minutes. Nothing here asks you to paste or share the key itself.
What Anthropic's docs say
If you have an active Claude subscription but also have ANTHROPIC_API_KEY set in your environment, Claude Code uses the API key once you approve it.Claude Code docs, Authentication, page updated 2026-11-20, opened 2026-11-24
In non-interactive mode (-p), the key is always used when present.Same page, section “Authentication precedence”
The same section lists the order Claude Code picks credentials in. Cloud provider variables come first, then ANTHROPIC_AUTH_TOKEN, then ANTHROPIC_API_KEY, then an apiKeyHelper script. Your subscription login from /login is last, seventh of seven. Anything above it wins.
The check, step by step
- 1
Run
/statusinside Claude Code. Anthropic says that when a login and an API key are both configured,/statusmarks the credential that isn't in use. Write down which one is active before you change anything. - 2
Check the shell you start
claudefrom. These commands print only whether the variable is set, never its value.
# macOS / Linux (bash or zsh)
[ -n "$ANTHROPIC_API_KEY" ] && echo "ANTHROPIC_API_KEY is set"
[ -n "$ANTHROPIC_AUTH_TOKEN" ] && echo "ANTHROPIC_AUTH_TOKEN is set"
# Windows PowerShell
if ($env:ANTHROPIC_API_KEY) { "ANTHROPIC_API_KEY is set" }
- 3
Find where it comes from. A variable that comes back in every new terminal is usually exported in a shell profile.
grep -n "ANTHROPIC_API_KEY\|ANTHROPIC_AUTH_TOKEN" \
~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile ~/.profile 2>/dev/null
- 4
Check Claude Code's own settings files. Settings files can carry an
envblock, and the shared project file is meant for “the environment variables the project needs” (Settings docs). A key there, or anapiKeyHelperscript, also outranks your login.
grep -n "ANTHROPIC_API_KEY\|apiKeyHelper" \
~/.claude/settings.json .claude/settings.json .claude/settings.local.json 2>/dev/null
- 5
Check scripts and schedulers. Anything that runs
claude -p(a cron job, a CI step, a shell alias) uses the key whenever it is in that environment, with no prompt. - 6
Look at
/config. The docs say a “Use custom API key” toggle appears there only whileANTHROPIC_API_KEYis set. If you see it, the key is in your environment.
Turn it off
- 1
Run
unset ANTHROPIC_API_KEYin the current shell. Anthropic's docs give this exact command to fall back to your subscription. - 2
Delete the export line you found in step 3, and the key from any settings
envblock found in step 4. Open a new terminal so the old value is gone. - 3
If you still want the key for other tools, keep it out of the shell where you run Claude Code, or switch the “Use custom API key” toggle off in
/config(your choice is remembered, per the docs). - 4
If you once signed in to Claude Code with a Console account,
/loginmay have saved an API key. The docs say/logoutremoves it. Then/loginagain with your claude.ai account. - 5
Run
/statusagain. Your subscription should be the active login.
Were you already charged?
Subscription usage and API usage are billed separately. To see the API side:
- 1
Open the Console Billing page at
platform.claude.com/settings/billing. Anthropic says your organization's credit balance and credit usage are shown there (Help Center). - 2
Read Invoice history. Each credit purchase is listed. If auto-reload was on, every top-up is its own purchase, so a run of same-size charges is a common sign.
- 3
Match dates. Purchased credits cover API access, playground usage and Claude Code (same Help Center page). If credit usage moves on days you only used Claude Code, the key was billing you.
- 4
Do not trust a $0 on the day. In issue #62338 the reporter says the Console usage dashboard showed $0 at the time because of reporting lag. Check again a day later.
If it was, turn auto-reload off first: Billing, “Manage auto-reload”, “Turn off”, then confirm “Turn off” again (Help Center).
Two public cases
| Case | What happened | Amount |
|---|---|---|
| claude-code #62338 opened 2026-05-26, still open | On a Max plan, Claude Code CLI sessions on 24–25 May 2026 were billed to API credits. The reporter says Claude Code twice told them they were on Max, and the Console dashboard showed $0 at the time. Support declined a refund under the Credit Terms. | $447.30 |
| claude-code #86723 opened 2026-08-14, closed as not planned 2026-09-12 | Scheduled Routines on a Max 20x plan were billed to metered API credits while plan headroom remained. The reporter traced it to ANTHROPIC_API_KEY set in the cloud environment, funded by repeated auto-reloads of about $45. | $1,122.83 ($821.39 June, $301.44 1–17 July 2026) |
Both amounts are as stated by the reporters in the linked issues. Note on #86723: Anthropic's authentication page, updated 2026-11-20, now says cloud sessions always use your subscription credentials and that a key set in the cloud environment doesn't override them. The local terminal rule above still applies.
What to keep if you dispute
- /status output from before and after the fix.
- Where the key was set: the file name and line, never the key value.
- Invoice history rows and credit usage for the affected days.
- Your plan receipt for the same period.
- Your local Claude Code logs for those days, so each charge can be matched to a session.
Never paste an API key into a support ticket or a public issue. If a key was exposed, rotate it in the Console.
The free check-up at /app reads your Claude Code logs inside your browser tab and sends nothing anywhere. If money is owed, the appeal template is free and you send it yourself. If you want a hard spend cap set up for you, that is a paid job on Upwork. It never logs in to your account.
FAQ · API key vs subscription in Claude Code
Does ANTHROPIC_API_KEY really override my Max or Ultra subscription?
Yes, once you approve it. Anthropic's authentication page says: if you have an active Claude subscription but also have ANTHROPIC_API_KEY set in your environment, Claude Code uses the API key once you approve it. The key is billed to its Claude Console organization, not to your plan. Source: code.claude.com/docs/en/authentication.
Is claude -p different?
Yes. In non-interactive mode (-p), the key is always used when present, with no approval prompt. A script or cron job that runs claude -p with the key in its environment bills the API every time. Source: Claude Code authentication docs, Authentication precedence.
How do I switch back to my subscription?
Run unset ANTHROPIC_API_KEY, remove the export line from your shell profile and any env block in Claude Code settings files, open a new terminal, then run /status to confirm which method is active. Anthropic's docs give the same steps: unset the variable to fall back to your subscription and check /status.
How do I know if I was already charged?
Open the Billing page in the Claude Console (platform.claude.com/settings/billing). Anthropic says your credit balance and credit usage are shown on that page, and expired credits and purchases appear in Invoice history. If auto-reload is on, each top-up is a separate purchase. Purchased credits cover Claude Code, so Claude Code usage on an API key shows up there.
Will Anthropic refund it?
Not something to count on. In GitHub issue #62338 the reporter says support declined a $447.30 refund, quoting that consumed API credits are non-refundable under the Credit Terms. Anthropic's Help Center also says all credit purchases are non-refundable. You can still ask; keep the evidence listed on this page.
Sources
- Claude Code docs: Authentication: precedence list, approval prompt,
-prule,unsetand/status, cloud sessions. Opened 2026-11-24. - Claude Code docs: Settings files and precedence: settings file locations and the
envblock. Opened 2026-11-24. - Claude Help Center: How do I pay for my Claude API usage?: Billing page, Invoice history, auto-reload, non-refundable credits. Opened 2026-11-24.
- GitHub anthropics/claude-code #62338: $447.30, opened 2026-05-26. Read 2026-11-24.
- GitHub anthropics/claude-code #86723: $1,122.83, opened 2026-08-14. Read 2026-11-24.
Last verified 2026-11-24. Menus and wording can change; if they differ, follow the linked Anthropic page. By Fireborn (6hn68).