Skip to content

Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) - Claude

Quick fix

Delete primaryApiKey from claude.json, or change the environment variable to ANTHROPIC_API_KEY, to resolve the auth conflict.

Error output
Auth conflict:Both a token (ANTHROPIC_AUTH_TOKEN) and an API key (/login managed   key) are set. This may lead to unexpected behavior.

When switching to a third-party provider, cc-switch writes ANTHROPIC_AUTH_TOKEN into settings.json by default. If you previously signed in to Claude Code officially, claude.json still holds a primaryApiKey field, and having both present makes Claude Code report the Auth conflict error. Separately, for a Claude Desktop direct provider the client expects to read ANTHROPIC_API_KEY, so the default ANTHROPIC_AUTH_TOKEN also fails authentication.

  1. Delete the API key left behind by the official login: open claude.json and remove the primaryApiKey field.

    // ~/.claude/claude.json
    {
    "primaryApiKey": "sk-ant-..."
    }
  2. Alternatively, change the environment variable name in the config from ANTHROPIC_AUTH_TOKEN to ANTHROPIC_API_KEY, for Claude Desktop compatibility or to avoid the header conflict.

    // ~/.claude/settings.json
    {
    "env": {
    "ANTHROPIC_AUTH_TOKEN": "your-token",
    "ANTHROPIC_API_KEY": "your-token"
    }
    }
ToolClaude Code
VersionUnknown
PlatformsWindowsmacOSLinux
Why does switching provider in cc-switch overwrite my existing hooks, permissions, and similar config?
That is expected. Some providers have unique fields (CLAUDE_CODE_MAX_OUTPUT_TOKENS, for example), and to stop fields from different providers interfering — causing errors or hurting performance — cc-switch rewrites the config file. Use the general config feature to write shared configuration quickly.
My provider forbids sending Authorization and x-auth-api headers together. What now?
While editing the provider in cc-switch, set the auth field to ANTHROPIC_API_KEY (Bearer mode), or add "auth_mode": "bearer_only" to the config to disable x-api-key.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.