Skip to content

Claude Code: warning when both claude.ai session and ANTHROPIC_API_KEY are set #23

Description

@numikel

Summary

When Claude Code is launched via the proxy (tray Run Claude Code or the manual snippet), the CLI prints two startup warnings:

‼ Both claude.ai and ANTHROPIC_API_KEY set · auth may not work as expected
  · to use claude.ai: Unset the ANTHROPIC_API_KEY environment variable, or claude /logout then say "No" to the API key approval before login.
  · to use ANTHROPIC_API_KEY: claude /logout to sign out of claude.ai.
⚠ claude.ai connectors are disabled because ANTHROPIC_API_KEY or another auth source is set and takes precedence over your claude.ai login · Unset it to…

This happens because the proxy must set ANTHROPIC_API_KEY=proxy-managed (dummy value — the real upstream key is injected by the proxy at request time), while many users also have an active claude.ai OAuth session from prior standalone use.

Steps to reproduce

  1. Configure an endpoint with the Messages API (/messages).
  2. Set an upstream API key in the proxy settings.
  3. Fill all required Claude Code model slots.
  4. Ensure you are logged into claude.ai in Claude Code (claude used outside the proxy at least once).
  5. Launch Claude Code from the tray (Run Claude Code) or paste the manual snippet from settings.

Expected behavior

Claude Code starts cleanly against the proxy with no misleading auth warnings — the dummy ANTHROPIC_API_KEY is intentional and routing goes through ANTHROPIC_BASE_URL.

Actual behavior

Both warnings above appear on every launch. They suggest unsetting ANTHROPIC_API_KEY or logging out of claude.ai — neither is desirable for proxy users who rely on the env var + base URL pattern (same approach as Codex with CODEX_PROXY_KEY=proxy-managed).

The connectors warning additionally tells users that claude.ai connectors (MCP integrations tied to the OAuth session) are disabled while the dummy API key is present — even though proxy mode is intentional, not a misconfiguration.

Root cause

spawn_agent / manual_command always set:

$env:ANTHROPIC_BASE_URL="http://127.0.0.1:<port>"
$env:ANTHROPIC_API_KEY="proxy-managed"   # dummy — proxy injects real key

Claude Code treats a non-empty ANTHROPIC_API_KEY as API-key auth mode and conflicts that with an existing claude.ai OAuth session. The connectors warning is a downstream effect of the same precedence rule: API-key auth wins over claude.ai login.

Relevant code: src-tauri/src/commands.rs (ANTHROPIC_API_KEY_VALUE = "proxy-managed").

Impact

  • Noisy, confusing UX on every proxy launch (two warnings).
  • Users may /logout or unset the env var and break proxy routing.
  • Unclear whether auth actually fails or the warnings are benign when ANTHROPIC_BASE_URL points at the proxy.
  • claude.ai connectors are unavailable in proxy-launched sessions — may surprise users who expect OAuth-only features (connectors) to keep working alongside custom upstream routing.

Possible directions

  • Document both warnings as expected + safe to ignore when using the proxy (settings snippet comment / README); note that connectors require claude.ai OAuth and are intentionally unavailable in proxy/API-key mode.
  • Investigate whether Claude Code supports proxy-only auth without setting ANTHROPIC_API_KEY (e.g. base URL + gateway token only).
  • Investigate upstream (anthropics/claude-code) for a flag or env to suppress the hybrid-auth warning when ANTHROPIC_BASE_URL is overridden.
  • Pre-launch hint in the UI when Messages API is active: "If you use claude.ai login elsewhere, you may see auth warnings — proxy mode uses the dummy API key by design; claude.ai connectors will not be available."

Environment

  • App: copilot-cli-custom-proxy (Claude Code / Messages API support)
  • OS: Windows (PowerShell launch path)
  • Claude Code: any recent version that prints the hybrid-auth and connectors warnings

Related

  • Design: docs/superpowers/specs/2026-06-28-claude-code-design.md §3 (launch env vars)
  • Analogous pattern: Codex CODEX_PROXY_KEY=proxy-managed (no equivalent warning observed)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions