Persistent Warning When Using API Key Directly
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.62 (Claude Code)
- Operating System: macOS Sequoia 15.5
- Terminal: Wezterm
Bug Description
╭──────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: redacted │
│ │
│ ────────────────────────────────────────────────────── │
│ │
│ Overrides (via env): │
│ │
│ • API Key: redacted │
╰──────────────────────────────────────────────────────────╯
⚠ Auth conflict: Using ANTHROPIC_API_KEY instead of Anthropic Console key. Either unset ANTHROPIC_API_KEY, or run `claude /logout`.
To address the warning, I run claude /logout as requested, then restart claude, but I am forced to log back in, which creates a new API key, and I still see the warning after choosing to use the API key I have set in the environment.
Steps to Reproduce
export ANTHROPIC_API_KEY=redacted
- alternatively, set via
./claude/settings.json:
``json``
{
"model": "opus",
"env": {
"ANTHROPIC_API_KEY": "redacted"
}
}
claude- Choose dark mode.
- Choose "Anthropic Console account" login method
- Sign in via browser (oauth).
- "Detected custom API key in your environment...Do you want to use this API key?" Yes.
- "Welcome to Claude Code" banner
- no other text is visible
- I can't see anything I input.
Ctrl-Cdoes seem to work, and I get the "Press Ctrl-C to exit" message.
- Press Ctrl-C 2x to exit.
claude- Choose dark mode again.
- Press enter to acknowledge security notes.
- Get same "⚠ Auth conflict: Using ANTHROPIC_API_KEY instead of Anthropic Console key. Either unset ANTHROPIC_API_KEY, or run
claude /logout." warning message.
Expected Behavior
export ANTHROPIC_API_KEY=redacted
- alternatively, set via
./claude/settings.json:
``json``
{
"model": "opus",
"env": {
"ANTHROPIC_API_KEY": "your_key_here"
}
}
claude- Choose dark mode.
- Choose the "Use an API key directly" login method
- New login method.
- Press enter to acknowledge security notes.
- Carry on with Claude code, observe api key override message.
Additional Context
I'm not sure if reproduction steps 7 and 8 are related to my primary concern, which is the persistent warning about an auth conflict due to have the envar set and Claude code clearly expecting to use the key generated on login. However, I listed those steps in an effort to be complete and comprehensive in the case it _is_ useful information.
Ideally, I'd like to be able to set the API key in memory, so that I can use external password managers to load secrets into the environment, and let claude use those.
Related Issues
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗