Skip to content
Luisa Lima
Go back

TIL: ANTHROPIC_API_KEY silently overrides your Claude Code subscription

If ANTHROPIC_API_KEY is set in your environment, Claude Code routes calls through that key instead of your OAuth subscription, even when you’re logged in. This is documented and intentional, but the failure mode is quiet. Since there’s no warning, you just start burning API credits while thinking you’re on the subscription plan.

I hit this while building an app with Claude Code. My app’s load_dotenv() pulled ANTHROPIC_API_KEY from .env into the process environment. Once that var existed, every Claude Code call in that shell billed against the API key.

Two fixes depending on the situation:


Share this post:

Previous Post
My Agent Operating Policy
Next Post
I no longer plan, I get grilled instead