Claude Code fails silently when ANTHROPIC_API_KEY is set in cloud environments

✍️ OpenClawRadar📅 Published: May 1, 2026🔗 Source
Claude Code fails silently when ANTHROPIC_API_KEY is set in cloud environments
Ad

Claude Code (CC) has a known issue: if you set the ANTHROPIC_API_KEY environment variable in a cloud environment, Claude Code will fail to execute any commands. The variable overrides CLI billing and routes all calls through the Anthropic API, leading to unexpected charges and a dead tool. This was reported on Hacker News with a reference to the GitHub issue #54497.

Ad

Key details from the discussion

  • Environment variable triggers failure: Setting ANTHROPIC_API_KEY in cloud environments (e.g., CI/CD, containers) causes Claude Code to stop working. The tool attempts to use the API key for billing, effectively disabling its free tier or local billing mechanism.
  • Extra usage charges: One user reported seeing a lot of "Extra usage" in their Anthropic billing — likely because every Claude Code call was being proxied through the API key, incurring per-request costs.
  • Misguided documentation: Another commenter noted that Anthropic's own documentation previously (and incorrectly) advised adding ANTHROPIC_API_KEY for Claude Code Web usage. This led to accidental charges. Anthropic later updated the docs but refused to refund the incurred costs.
  • Workaround: Do not set ANTHROPIC_API_KEY in cloud environments where Claude Code runs. Use alternative authentication methods (e.g., CLI‑based credentials or separate billing tokens) if needed.

Who this affects

Developers using Claude Code in CI/CD pipelines, containerized environments, or any cloud‑based infrastructure where environment variables are injected globally.

📖 Read the full source: HN AI Agents

Ad

👀 See Also