claude -p with OAuth (no API key) bills as API usage, not Max subscription
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_KEYis 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:
- #37686 —
claude -psuggested to Max subscriber caused $1,800+ in two days - #32286 — Silent API credit billing despite active Max subscription
- #3040 — print mode does not use Max subscription
- #9694 — Stuck in API billing mode with no API key set
- #12352 — Claude Code ignores subscription tier when API key is set
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
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗