DigestAI news desk

Cut through the AI noise.

Marketing & Small Business6 min read

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

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,…

1 source

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.

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.

The story so far

4 episodes →
  1. User discovers Claude Code -p calls bypass flat-rate plan, causing API billingthis story
Full story from note.com · by ソルー@セット本せどり · via Search: ClaudeOpen source ↗

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

note.com · 22 September 2026

Loading the full article…

This text was published by note.com and written by ソルー@セット本せどり. It is reproduced here with attribution so you can read it in full; the rights remain with the publisher. Read it at the source ↗

Topics · follow one to build your own front page

The headline, key points and digest above were generated by Digest AI's editorial model from the linked sources. Automated summaries can contain errors: the sources are the record. Spotted a mistake? Tell us. Published by Martin K., who runs Digest AI and handles corrections.

Comments

via GitHub Discussions

More in Marketing & Small Business

All →

Related stories