Skip to content

Open sessions continue using a third-party ANTHROPIC_BASE_URL — Claude Code

Quick fix

Set legacy ANTHROPIC_* keys to empty strings in the official provider configuration's env, then switch back to the official provider.

Error output
开着的会话继续使用第三方的 `ANTHROPIC_BASE_URL`、`ANTHROPIC_AUTH_TOKEN` 和模型映射,直到重启会话。
English translation

Open sessions continue using the third-party `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, and model mapping until the session is restarted.

Claude Code hot-loads added or changed env values in settings, but deleting keys from settings does not remove old environment variables retained by the running process. When switching back to official Claude, third-party keys such as `ANTHROPIC_BASE_URL` and `ANTHROPIC_AUTH_TOKEN` are deleted, so the current session still uses their old values.

Verified in a macOS session of Claude Code 2.1.286: changing these keys to empty strings returns the next request to official OAuth immediately; deleting them still sends requests to the third-party address.

  1. Edit the official Claude provider's own configuration, not the general configuration.

  2. In the official provider's `env`, set the Anthropic environment variables used by the previous third-party provider to empty strings.

    settings.json
    "ANTHROPIC_BASE_URL": "",
    "ANTHROPIC_AUTH_TOKEN": "",
    "ANTHROPIC_MODEL": "",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": ""
  3. After switching back to official Claude, continue sending messages in the existing Claude Code session. The empty strings are applied through live settings and return the session to the official provider.

ToolClaude Code
Version2.1.286(受影响版本;仅此版本已验证)
PlatformsmacOS

(No FAQ yet)

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.