# User discovers Claude Code -p calls bypass flat-rate plan, causing API billing

Digest AI · Marketing & Small Business · published 2026-09-22T00:11:00Z

Canonical: https://digestai.news/story/user-discovers-claude-code-p-calls-bypass-flat-rate-plan-causing-api-b

## Summary

A developer using Anthropic's Claude Code on the Max flat‑rate plan noticed a sudden spike in token usage over two days. The overnight batch that recreates old blog articles runs six times daily, each consuming about 750,000 input tokens and 90,000 output tokens. When the batch was executed in non‑interactive "-p" mode, the management console showed token spikes of roughly 7.2 million on 9/19, 4.8 million on 9/21, and 4.6 million on 9/22, while days without recreations dropped to about 300,000 tokens.

Investigation revealed that the tool’s *.env* file contained an ANTHROPICAPIKEY (and ANTHROPICAUTHTOKEN). In "-p" mode Claude Code gives priority to any present API key, routing the request through the API rather than the flat‑rate quota. An experiment with an invalid key caused a 401 error, confirming the behavior. Removing the two environment variables from the call stopped the API‑based billing, and a follow‑up run succeeded using the flat‑rate quota.

The fix is a simple two‑line code change that strips the API keys from the environment before invoking Claude Code. Users running similar automation should audit their *.env* files to avoid unexpected charges.

## Key points

- Claude Code -p mode uses any ANTHROPICAPIKEY in the environment, sending usage to API billing instead of the flat‑rate plan.
- Token usage spiked to about 7.2 million tokens on 9/19 and ~4.8 million tokens on 9/21‑22 due to article‑recreation runs.
- Removing ANTHROPICAPIKEY and ANTHROPICAUTHTOKEN from the environment stopped API billing and restored flat‑rate usage.

## Why it matters

Hidden API keys can silently shift billing from a flat‑rate plan to per‑token charges, leading to costly overruns for developers and marketers.

## Sources

1. [The AI overnight processing I thought was on a flat-rate plan was actually all being billed via API: -p in Claude Code and environment variable API keys](https://note.com/solu/n/n60a1b9166272?hl=en) (note.com, 2026-09-22)

Part of the developing story: [Claude Code Quality and Billing Controversy](https://digestai.news/thread/anthropic-sets-higher-quality-standards-for-claude-generated-production-code) (4 stories)

## Cite

Digest AI, "User discovers Claude Code -p calls bypass flat-rate plan, causing API billing", 22 September 2026, https://digestai.news/story/user-discovers-claude-code-p-calls-bypass-flat-rate-plan-causing-api-b

---

Written by Digest AI's editorial model from the linked sources; the sources are the record. Headlines, digests and key points are written by Digest AI and may be quoted with a link to the story page. Linked articles belong to their publishers. Terms: https://digestai.news/terms#reuse
JSON: https://digestai.news/story/user-discovers-claude-code-p-calls-bypass-flat-rate-plan-causing-api-b.json
