[BUG] Auth conflict warning is a regression — local ANTHROPIC_API_KEY should not conflict with global OAuth login
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Since a recent update, setting ANTHROPIC_API_KEY as a local environment variable in a single shell session triggers an auth conflict warning. The suggested remediation — running claude /logout — removes the OAuth token globally from ~/.claude/, breaking all other concurrent sessions that rely on the claude.ai login.
Previously, a locally set ANTHROPIC_API_KEY simply took precedence in that session. No conflict, no warning. Other sessions continued using OAuth normally.
What Should Happen?
- A locally set ANTHROPIC_API_KEY should take precedence in that session without warning
- Other sessions using OAuth should remain unaffected
- No global logout should be required
This is a common use case: running multiple Claude Code sessions simultaneously — e.g. one with OAuth for regular project work, another with ANTHROPIC_API_KEY for a custom endpoint or Azure.
Error Messages/Logs
⚠ Auth conflict: Both a token (claude.ai) and an API key (ANTHROPIC_API_KEY) are set.
This may lead to unexpected behavior.
• Trying to use claude.ai? Unset the ANTHROPIC_API_KEY environment variable,
or claude /logout then say "No" to the API key approval before login.
• Trying to use ANTHROPIC_API_KEY? claude /logout to sign out of claude.ai.
Steps to Reproduce
- Log in to claude.ai via
claude /login - Open a separate shell session
- Set export
ANTHROPIC_API_KEY=sk-...locally in that shell - Run
claude - The auth conflict warning appears
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.68
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗