Skip to content

Bug Report: Claude Code v2.1.72 Auth & Model Persistence Conflict #57

@sakuralost

Description

@sakuralost

Environment

Claude Code Version: v2.1.72

OS: Linux (Remote Server via SSH)

Tool: cc-switch (SaladDay/cc-switch-cli)

Setup: Dual provider (1. Official Team via OAuth; 2. Third-party API via Key & Base URL)

Problem Description

Even when switching providers using cc-switch, Claude Code v2.1.72 retains a "Sticky Session" state that causes the following issues:

Auth Conflict: When switching from an OAuth (Team) provider to an API Key (Third-party) provider, Claude Code still detects and prioritizes the ANTHROPIC_AUTH_TOKEN stored in ~/.claude/auth.json. This leads to a fatal error: "Both a token and an API key are set."

Model Identity Persistence: Despite switching to a custom Base URL (e.g., a forwarding API), the CLI keeps requesting the official model ID claude-sonnet-4-6, which causes a "Model not found" error on third-party endpoints that use specific IDs (like claude-3-5-sonnet-20241022).

Variable Ignorance: v2.1.72 seems to ignore ANTHROPIC_BASE_URL if a previous OAuth session exists, making it nearly impossible to toggle between a paid Team account and a backup API without a manual rm -rf ~/.claude.

Steps to Reproduce

Login to an official Team account using /login.

Use cc-switch provider add to create a custom API provider with a Base URL and API Key.

Run cc-switch provider switch [custom-api-provider].

Run claude.

Observe the Auth Conflict and Model Selection failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions