[BUG] ANTHROPIC_API_KEY in env does not properly override

Resolved 💬 3 comments Opened Jun 2, 2025 by synic Closed Jun 2, 2025

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [x] Other: Claude Code
  • Claude CLI version: 1.0.8 (Claude Code)
  • Operating System: macOS 15.5
  • Terminal: Wezterm

Bug Description

Setting ANTHROPIC_API_KEY in the terminal before running claude causes claude to prompt you if you want to use the api key. If you say "yes", it will show the override message "Overrides (via env):` at the top in the "Welcome to Claude Code!" card.

The only issue is that, although it says "overrides", the API key is not one in the environment, it's still the one from `/login1, so though it says it's overriding, it's not.

Steps to Reproduce

  1. Login via /login
  2. Set an override key in the terminal (export ANTHROPIC_API_KEY=[new key])
  3. Run claude.
  4. Observe that the override message is showing a different key than the one set in the ANTHROPIC_API_KEY environment variable

Expected Behavior

If there is an environment variable $ANTHROPIC_API_KEY set, and you say "yes" when Claude Code prompts you if you want to use it, it should use the override.

Actual Behavior

It makes some indications that the override was noticed, but it doesn't actually apply the override.

!Image

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗