[BUG] "Use custom API key: true" ignored — Claude Code still authenticates via Google Vertex AI (Windows 11)
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?
Environment:
- Claude Code version: 2.1.45
- OS: Windows 11
- API provider shown in Status: Google Vertex AI
Bug Description:
When using Claude Code under an organization‑managed account configured for Google Vertex AI, toggling “Use custom API key” to true in Settings → Config does not switch the API provider to Anthropic API.
Even when:
- ANTHROPIC_API_KEY is set as a Windows User environment variable
- “Use custom API key” is explicitly set to true
Claude Code continues to authenticate exclusively via Google Vertex AI, as shown in Settings → Status.
Expected behavior:
Setting "Use custom API key: true" should override the Vertex AI
provider and use ANTHROPIC_API_KEY for authentication.
Actual behavior:
Provider remains Google Vertex AI regardless of the Config setting.
Workaround:
Temporarily removing ANTHROPIC_VERTEX_PROJECT_ID from the session
environment (Remove-Item Env:ANTHROPIC_VERTEX_PROJECT_ID in
PowerShell) forces Claude Code to use ANTHROPIC_API_KEY correctly.
Root cause hypothesis:
ANTHROPIC_VERTEX_PROJECT_ID environment variable takes priority
over the "Use custom API key" Config setting. The Config toggle
appears to have no effect when Vertex env vars are present.
Suggested fix:
When "Use custom API key" is explicitly set to true, it should
take precedence over all provider environment variables, including
ANTHROPIC_VERTEX_PROJECT_ID.
What Should Happen?
Expected behavior:
One of the following should occur:
- If org policy prevents switching providers:
- The UI should disable or annotate “Use custom API key”
- Or display a clear message indicating the provider is locked by org policy
OR
- If switching is allowed:
- “Use custom API key: true” should override Vertex AI and use ANTHROPIC_API_KEY
Actual Behavior
- Provider remains Google Vertex AI
- “Use custom API key” toggle has no visible or functional effect
- No warning or explanation is shown to the user
Additional Findings
- Account has "penguinModeOrgEnabled": true
- Vertex AI provider selection appears to be enforced server‑side
- Local config files and environment variables cannot override this
- When Google Application Default Credentials expire, Claude Code fails with:
API Error: Could not load the default credentials
*Re‑authenticating with:
gcloud auth application-default login
resolves the error
Suggestion Improvements
- Disable or annotate “Use custom API key” when provider is locked by org policy
- Improve error messaging when Vertex AI credentials expire
- Clarify provider precedence rules in documentation and UI
Error Messages/Logs
Steps to Reproduce
Setting "Use custom API key" to true in Config does not switch
the API provider from Google Vertex AI to Anthropic API.
Even with:
- ANTHROPIC_API_KEY set as a Windows User environment variable
- "Use custom API key" toggled to
truein Settings → Config
Claude Code continues to authenticate against Google Vertex AI
(confirmed in Settings → Status: "API provider: Google Vertex AI").
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.45
Platform
Google Vertex AI
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗