Bug Description
claude -p (print mode) bills as per-token API usage even when authenticated via OAuth with an active Max subscription and no ANTHROPIC_API_KEY in the environment.
This means Max subscribers (who have an organization with an api account as well) who use claude -p in automation are silently charged API rates instead of using their subscription, even when they have explicitly removed any API key from their environment.
Steps to Reproduce
- Have an active Claude Max subscription
- Be logged in via OAuth (
claude auth login)
- Ensure
ANTHROPIC_API_KEY is not set in the environment
- Run:
env -u ANTHROPIC_API_KEY claude -p --output-format json "say hi"
- Observe the result JSON
Expected Behavior
- Usage should be billed against the Max subscription, not as API usage
Actual Behavior
Usage shows up on the platform.claude.com dashboard and not on the user’s max dashboard on Claude.ai
- Billed as API usage despite OAuth authentication from a Max account
Auth State
The OAuth credentials in ~/.claude/.credentials.json correctly show:
subscriptionType: "max"
billingType: "stripe_subscription"
rateLimitTier: "default_claude_max_20x"
But -p mode ignores all of this and routes through API billing anyway.
Impact
This is a significant billing issue for anyone using claude -p in automation (CI/CD pipelines, agent orchestration, scripts). Max subscribers expect their subscription to cover CLI usage, but -p mode silently bills at API rates. I only discovered the billing leak after noticing unexpected API charges with no ANTHROPIC_API_KEY set.
See https://x.com/bcherny/status/2040207998807908432?s=46&t=56r0QbzszcSdz2BaE6Vj8A for clarity that this isn’t the expected behavior
Related issues:
Environment Info
- Platform: Linux x86_64 (6.12.67)
- Claude Code version: 2.1.91
- Node.js: v22.22.0
- Terminal: bash (headless server)
- Subscription: Max (confirmed in credentials)
- ANTHROPIC_API_KEY: explicitly unset via
env -u
Bug Description
claude -p(print mode) bills as per-token API usage even when authenticated via OAuth with an active Max subscription and noANTHROPIC_API_KEYin the environment.This means Max subscribers (who have an organization with an api account as well) who use
claude -pin automation are silently charged API rates instead of using their subscription, even when they have explicitly removed any API key from their environment.Steps to Reproduce
claude auth login)ANTHROPIC_API_KEYis not set in the environmentenv -u ANTHROPIC_API_KEY claude -p --output-format json "say hi"Expected Behavior
Actual Behavior
Usage shows up on the platform.claude.com dashboard and not on the user’s max dashboard on Claude.ai
Auth State
The OAuth credentials in
~/.claude/.credentials.jsoncorrectly show:subscriptionType: "max"billingType: "stripe_subscription"rateLimitTier: "default_claude_max_20x"But
-pmode ignores all of this and routes through API billing anyway.Impact
This is a significant billing issue for anyone using
claude -pin automation (CI/CD pipelines, agent orchestration, scripts). Max subscribers expect their subscription to cover CLI usage, but-pmode silently bills at API rates. I only discovered the billing leak after noticing unexpected API charges with noANTHROPIC_API_KEYset.See https://x.com/bcherny/status/2040207998807908432?s=46&t=56r0QbzszcSdz2BaE6Vj8A for clarity that this isn’t the expected behavior
Related issues:
claude -psuggested to Max subscriber caused $1,800+ in two daysEnvironment Info
env -u