AI Briefing
KO

Claude Code: Watch Out for API Key Priority

·2026.05.13 03:44

Key point

When running Claude Code, if an API key is present in environment variables, you may be billed for API costs instead of using your subscription plan.

Details

It has been confirmed that when running Claude Code, if the project's .env file contains ANTHROPIC_API_KEY, the tool prioritizes the API key over the user's OAuth subscription (Max plan, etc.) and bills accordingly.

Anthropic has stated that this behavior is "intentional functionality" intended to provide flexibility in authentication methods. Since API credits can be consumed without any separate warning or notification, developers using Claude Code in automated environments (CI/CD, Task Scheduler, etc.) need to be especially careful.

Solution: You should unset the API key from the environment variables right before running Claude Code so that subscription authentication is applied.

  • PowerShell: $env:ANTHROPIC_API_KEY = $null
  • Bash/Zsh: unset ANTHROPIC_API_KEY

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.