AI Provider Switcher
在一个 VS Code 面板中管理 Claude Code 与 Codex 的官方服务、自定义 Provider、模型和连接代理。
中文为什么使用 AI Provider Switcher?Claude Code 和 Codex 的 Provider 配置分散在 VS Code 设置、环境变量和用户目录文件中。手工切换容易遗漏旧变量、泄露密钥、使用错误模型,或者在代理环境中反复遇到 Codex AI Provider Switcher 将这些工作集中到一个可视化入口:
功能亮点统一管理
Claude Code
Codex
用量与额度 MVP
使用方式:运行 AI Provider Switcher: Configure Provider Usage API 配置接口,然后运行 AI Provider Switcher: Refresh Provider Usage 测试和刷新。优先使用 HTTPS 及只读凭据;如果额度 API 与 Provider 不同域,扩展会在发送已保存凭据前要求明确确认。如果服务商未提供额度 API,扩展只能显示模型接口返回的限流响应头。
系统要求与兼容性
多用户 Linux 服务器的本地端口Claude Desktop 的本地模型路由只监听 若端口已被占用,插件会明确提示并拒绝启动该本地路由,不会随机换端口,因为 Claude Desktop 已保存旧 URL,静默换端口会造成“配置成功但无法连接”。管理员或用户可显式覆盖:
修改端口后重新加载 VS Code,再重新应用 Claude Desktop 服务即可。其他直连服务不受端口冲突影响。 远程开发(Remote-SSH / WSL / 容器)扩展声明为 由此带来三点需要注意,扩展会在界面上主动提示:
如果你主要用这个扩展管理本地 Claude Desktop,而不是远程的 CLI,可以在设置中把扩展固定到本地侧:
改完需要重新加载窗口。固定为 其他要求:
安装从 VSIX 安装
从源码运行
Windows PowerShell 如果阻止 快速开始安装并重载后,可使用任一入口打开管理器:
Claude 使用指南配置 Claude Code(VS Code / 终端)这条流程只影响 VS Code 内的 Claude Code 和终端
配置 Claude Desktop(独立应用)这条流程只影响 Claude Desktop,不会改变 VS Code 内 Claude Code 或终端 CLI:
恢复 Claude 官方订阅
切换到官方模式会清除扩展管理的 Claude Provider 环境变量,并将命令策略恢复为手动确认。 终端 Claude CLI 与 Claude Desktop
配置非 Claude 模型运行 AI Provider Switcher: Configure Claude Model Mapping:
模型映射能解决 Provider 只接受自定义模型 ID、而 Claude Code 尝试使用内置 Claude ID 的问题。Claude Code 是否在原生模型栏展示这些模型,仍取决于客户端版本和 Provider 兼容性。 Claude 配置冲突检查运行 AI Provider Switcher: Inspect Other Claude Configuration。扩展会检查:
认证值会隐藏显示。对可安全修改的文件,扩展会先创建 Codex 使用指南切换到 Codex 自定义 Provider(Windows/macOS/Linux)
根地址示例: 统一 Codex 会话历史(官方与第三方合并为一个历史列表)Codex 按会话记录中的
安全设计:
恢复 Codex 官方服务运行 AI Provider Switcher: Use Codex Official Provider,然后重新加载 VS Code。扩展会删除其管理的自定义 Provider 块,并恢复首次接管前记录的 解决 Codex 反复 Reconnecting为什么会有“代理”这个功能Codex 扩展并不是只发普通的 HTTPS 请求,它还要建立一条长连接(WebSocket)来流式接收回复。这两类连接读取代理配置的路径不一样:
结果就是一个很典型的现象:模型列表能刷出来、账号能登录(HTTPS 走通了),但一开始对话就反复 这个功能做的事情很简单——把一个明确的代理地址写进 部分代理环境能处理 HTTPS,但 Codex 的 WebSocket 连接没有正确使用代理,于是会多次 AI Provider Switcher: Configure Codex WebSocket Proxy 推荐流程
自动检测来源扩展按以下顺序寻找当前设备代理:
第 1、2、3 步在所有系统上都有效;只有第 4、5、6 步依赖具体的操作系统机制。Linux 上第 6 步只覆盖 GNOME,KDE/Xfce 或纯命令行环境探测不到——这只影响“自动填好地址”这一步,不影响功能本身。 如果自动检测失败,选择“设置或更新代理”,填写完整地址,例如
官方服务还是所有 Provider?
|
| 内容 | 保存位置与行为 |
|---|---|
| Claude Provider 元数据、模型缓存 | VS Code 全局设置 |
| Claude Token | VS Code Secret Storage;启用 Provider 时也会写入 claudeCode.environmentVariables,以供 Claude Code 扩展读取 |
| Claude 权限模式 | VS Code 全局设置及 ~/.claude/settings.json |
| Codex Provider 元数据、模型缓存 | VS Code 全局设置 |
| Codex API Key | VS Code Secret Storage;Windows 另存当前用户 DPAPI 加密文件,macOS/Linux 使用权限为 0600 的本地 Key 文件;不写入 config.toml |
| Codex Provider 配置 | Codex 主目录下 config.toml 中的顶层选择和扩展标记块 |
| Codex 模型目录 | Codex 主目录下的 ai-provider-switcher-models.json |
| Codex 代理 | Codex 主目录下 .env 中的扩展标记块 |
| 统一会话历史备份 | Codex 主目录下 ai-provider-switcher-backups/codex-official-history-unify-v1/(迁移)与 codex-official-history-unify-restore-v1/(还原) |
Codex 主目录默认是
~/.codex(Windows 为%USERPROFILE%\.codex)。若设置了CODEX_HOME环境变量,扩展会跟随它写入——因为 Codex 自己也读那里,写到默认目录会是一次没有任何报错的空操作。界面上的提示会直接显示实际使用的完整路径。 | Provider 额度快照 | VS Code 全局设置;仅缓存余额、百分比、限流值和更新时间,不缓存 API 响应正文 |
安全建议:
- 优先使用 HTTPS Provider。HTTP Provider 会使模型发现请求中的凭据面临明文传输风险。
- Claude Code 要读取自定义 Token,因此活动 Token 会出现在 VS Code 用户设置中。请保护用户设置并限制不受信任扩展和本机进程。
- 清除正在使用的 Claude Token 前,先切换回官方模式;单独执行“清除 Token”只删除 Secret Storage 副本。
- Windows DPAPI 文件绑定当前用户;macOS/Linux 依赖用户目录和
0600文件权限。两者都不代表硬件级保护,也不能防御同一用户上下文中的恶意进程。 - “完全放行”会允许危险命令绕过常规确认,禁止在包含真实凭据或重要数据的普通工作环境使用。
常见问题
切换后为什么仍然使用旧 Provider?
重新加载 VS Code,并创建新会话。再运行 Claude 配置检查,确认系统环境变量或项目设置没有覆盖扩展配置。
为什么 Claude 主模型可用,但 Auto 命令仍被阻止?
针对当前已测试的 Claude Code 版本,Auto 可能使用独立安全分类请求。自定义 Provider 能运行主模型,不代表能处理分类请求。可改用“编辑自动接受”或“手动确认”;不要通过宽泛的命令白名单来模拟完全放行。
为什么 Codex 自定义 Provider 没有出现在模型栏?
确认 Provider 支持 Responses API 和 /v1/models,执行“刷新 Codex 模型”,重新加载,然后在 Codex 原生模型栏查看。
配置代理后仍然 Reconnecting?
确认代理软件正在运行、端口正在监听、代理类型为 HTTP 或混合代理,并已重新加载 VS Code。企业 PAC、认证代理或特殊网络策略可能仍需手动配置。
切换 Provider 会删除历史会话吗?
不会。扩展不会删除 Claude 或 Codex 本地会话历史,但不会迁移正在进行的对话上下文。切换后应新建会话。
自建中转站(one-api / new-api / LiteLLM)拉不到模型列表?
Base URL 要按服务实际监听的协议填。这类服务在本机多数只开明文 HTTP,地址应写成 http://127.0.0.1:3000 这种形式,写成 https:// 会连不上。填错时扩展会直接告诉你是域名解析失败、端口拒绝连接还是证书问题,按提示改即可。
提示「不是有效的 JSON,无法安全写入」怎么办?
先用编辑器打开提示里给出的那个文件确认内容。如果内容看起来完全正常,多半是文件开头有一个看不见的 BOM 字节(记事本保存、PowerShell 的 Set-Content 或 > 重定向都会写入)——0.5.5 起扩展会自动忽略 BOM 与空文件,升级即可。若确实是手改坏了(缺引号、多逗号),同目录下有扩展改动前留下的 .ai-provider-switcher-<时间戳>.bak 备份可以还原。
切换了 Claude Desktop,应用里却没变化?
桌面应用只在冷启动时读配置,关掉窗口不等于退出:Windows 要在右下角托盘图标上右键选「Quit / 退出」,macOS 要按 ⌘Q 或菜单栏 Claude → Quit,Linux 要确认进程已结束。全部退出后再重新打开。扩展的提示语会按你当前的系统给出对应说法。
Windows 上提示文件被占用(EPERM / EBUSY)?
配置文件正被别的程序打开:先关闭 Claude Desktop、关闭正在编辑该文件的编辑器,或暂停杀毒软件的实时扫描,然后重试。扩展会自动重试几次,仍失败时会把文件路径写在提示里。
统一会话历史里,跨供应商继续旧会话为什么失败?
会话文件完好无损,失败原因是上游设计:会话中的 encrypted_content 推理密文只能由生成它的后端解密,换供应商继续时对方无法解密。回到创建该会话的供应商继续,或直接新建会话即可。
命令参考
在命令面板中搜索 AI Provider Switcher 可查看全部命令。常用命令:
AI Provider Switcher: Quick Switch ProviderAI Provider Switcher: Open Provider ManagerAI Provider Switcher: Use Claude Official SubscriptionAI Provider Switcher: Switch Claude Desktop ServiceAI Provider Switcher: Manage Claude GatewaysAI Provider Switcher: Edit Claude GatewayAI Provider Switcher: Configure Claude Model MappingAI Provider Switcher: Configure Claude Command StrategyAI Provider Switcher: Configure Claude Desktop ModelsAI Provider Switcher: Inspect Other Claude ConfigurationAI Provider Switcher: Switch Codex ProviderAI Provider Switcher: Use Codex Official ProviderAI Provider Switcher: Manage Codex ProvidersAI Provider Switcher: Edit Codex ProviderAI Provider Switcher: Unified Codex Session HistoryAI Provider Switcher: Refresh Codex ModelsAI Provider Switcher: Configure Codex WebSocket Proxy
开发与贡献
- 编译:
npm run compile - 测试:
npm test - 调试:在 VS Code 中按
F5 - 打包:
npx vsce package
欢迎通过 GitHub Issues 提交错误、兼容性反馈和功能建议。
English
Why AI Provider Switcher?
Claude Code and Codex store provider configuration across VS Code settings, environment variables, and user-level files. Manual switching can leave stale variables behind, expose credentials, select unsupported models, or make Codex repeatedly report Reconnecting in proxied networks.
AI Provider Switcher brings those tasks into one visual workflow:
- Switch between official services and multiple custom providers.
- Save named providers instead of repeatedly editing configuration files.
- Map non-Claude model IDs to every Claude model family and agent role.
- Synchronize custom Codex models into Codex's native model control.
- Keep the standalone terminal Claude CLI in step with the VS Code integration.
- Manage Claude Desktop independently through its third-party inference config library.
- Unify Codex session history so official and third-party conversations share one list.
- Detect external Claude settings that override the selected provider.
- Configure a safe, reversible Codex WebSocket/HTTPS proxy.
- Preserve local session history when switching providers.
Highlights
Unified management
- One visual manager for both Claude and Codex.
- A status bar entry showing each active provider.
- Command Palette and Quick Pick workflows.
- Per-provider names, URLs, cached models, model mappings, and command strategies.
Claude Code
- Switch between an official Claude subscription and multiple Anthropic-compatible providers.
- Enter tokens through a password field and cache them in VS Code Secret Storage.
- Discover and cache provider models from
/v1/models. - Map custom IDs such as DeepSeek, Kimi, or GLM to the main model, Fable, Opus, Sonnet, Haiku, background work, and subagents.
- Configure reasoning effort and opt into a 1M marker only when the provider explicitly supports it.
- Normalize the official DeepSeek root URL to its Anthropic-compatible endpoint and apply a recommended mapping.
- Store a command strategy per provider: Auto, Accept Edits, Manual, or
bypassPermissionswith a high-risk confirmation. - Inspect inherited environment variables and Claude user/project settings for routing, authentication, model, and permission conflicts.
- Back up supported files before removing only conflicting provider fields.
- Sync the same managed environment into
~/.claude/settings.jsonso the terminalclaudeCLI follows the VS Code integration. - Manage Claude Desktop independently: named entries in the app's third-party inference config library, cached model lists and Anthropic-style model aliases, install-directory discovery, desktop state read back from disk, and cleanup when a gateway is deleted.
Codex
- Switch between the built-in OpenAI provider and named OpenAI Responses API-compatible providers.
- Fetch
/v1/models, generate a local Codex model catalog, and use Codex's native model control for selection. - Remove only extension-managed provider blocks and restore the recorded top-level selection when returning to the official provider.
- Keep API keys out of plaintext
config.toml. - Configure a Codex WebSocket/HTTPS proxy with environment, VS Code, Windows, macOS, and GNOME Linux detection; per-device ports; manual HTTP(S) input; provider scope; conflict inspection; and reversible writes.
- Unify Codex session history: run the official subscription under the shared
customprovider id and optionally migrate existing sessions into the shared list, with automatic backups and a ledger-based restore.
Usage and quota MVP
- Show a usage summary for custom providers in the visual manager.
- Cache
x-ratelimit-*headers while refreshing models without sending an extra paid inference request. - Configure a read-only JSON GET endpoint and reuse the provider's saved credential.
- Auto-detect common
balance,five_hour, andweeklyfields, or map custom JSON paths. - Display balance, five-hour and weekly windows, request/token limits, and reset values.
- Official Claude/Codex subscription quotas are not included because no stable third-party public API is available.
Run AI Provider Switcher: Configure Provider Usage API, then AI Provider Switcher: Refresh Provider Usage. Prefer HTTPS and read-only credentials. If the usage API has a different origin, the extension requires explicit confirmation before sending the saved provider credential. Without a provider usage endpoint, only compatible rate-limit response headers can be displayed.
[!WARNING] Custom Codex providers support Windows, macOS, and Linux. Windows uses PowerShell plus DPAPI for the current user; macOS/Linux use a
0600local key file read by a0700shell helper. For WSL/Remote extension hosts, install and run the extension in the same environment where Codex runs.
Compatibility
| Capability | Windows | macOS | Linux |
|---|---|---|---|
| Claude official/custom provider management | ✅ | ✅ | ✅ |
| Claude model mapping and conflict inspection | ✅ | ✅ | ✅ |
| Terminal Claude CLI sync | ✅ | ✅ | ✅ |
| Claude Desktop management | ✅ | ⚠️ | ⚠️ |
| Official Codex provider | ✅ | ✅ | ✅ |
| Codex WebSocket proxy | ✅ | ✅ | ⚠️ |
| Custom Codex providers | ✅ | ✅ | ✅ |
| Unified Codex session history | ✅ | ✅ | ✅ |
⚠️ Claude Desktop has official builds on all three platforms (Linux: https://code.claude.com/docs/en/desktop-linux), but the data-directory layout differs between platform builds and has so far only been verified on Windows. Auto-detection probes: Windows
%LOCALAPPDATA%\Claudeand%APPDATA%\Claude, macOS~/Library/Application Support/Claude, Linux$XDG_CONFIG_HOME/Claudeand~/.config/Claude. If detection fails, setaiProviderSwitcher.claudeDesktopConfigRootmanually.⚠️ Codex proxy auto-detection on Linux understands GNOME (
gsettings org.gnome.system.proxy) and KDE (~/.config/kioslaverc); Xfce and headless setups simply detect nothing and do not error. On macOS a PAC/WPAD auto-configuration script is reported by name — Codex cannot evaluate PAC, so read the real port out of your proxy app and enter it manually. On any platform you can exportHTTPS_PROXYfirst, or enter the address manually — manual entry behaves identically everywhere.
Requirements:
- VS Code
1.90.0or newer. - Install and enable Claude Code to use Claude features.
- Install and enable the official OpenAI Codex IDE extension to use Codex features.
- A custom Claude provider must expose a compatible Anthropic API.
- A custom Codex provider must implement the OpenAI Responses API. Chat Completions-only gateways are not supported.
Local ports on multi-user Linux servers
Claude Desktop's local model routing listens only on 127.0.0.1. A normal multi-user Linux server shares loopback ports within its network namespace — they are not automatically isolated per Unix user. When no port is explicitly configured, the extension derives a stable user-specific port from the current UID (in 24000–31999); the same user keeps it after restart and ordinary different users normally receive different ports. Windows and macOS retain the default 4180.
If the port is occupied, the extension reports it and refuses to start the local route; it never silently picks a random port, because Claude Desktop persists the old URL and a replacement would look configured but fail to connect. An administrator or user can override the port:
{
"aiProviderSwitcher.claudeProxyPort": 26000
}
After changing it, reload VS Code and reapply the Claude Desktop service. Direct services are unaffected by a local-port conflict.
Remote development (Remote-SSH / WSL / containers)
The extension declares "extensionKind": ["workspace", "ui"], so in a remote window it runs on the remote side by default. That is the right place for terminal CLIs: Claude Code and Codex run on the remote host, and so do ~/.claude and ~/.codex. Three consequences follow, each surfaced in the UI:
- The manager states which machine is being written to, e.g. “config is written to the WSL subsystem's
~/.claudeand~/.codex”. - Claude Desktop cannot be managed from the remote side. It is a local GUI application whose data directory lives on the machine you are looking at, which the remote host has no path to. Attempting a Desktop switch in a remote window explains this and links straight to the
remote.extensionKindsetting. 127.0.0.1in a proxy address means different machines on the two sides. A loopback address — detected or typed — is confirmed before being written into the remote~/.codex/.env. Under WSL the message names the fix: the subsystem's127.0.0.1is not the Windows host unless.wslconfigenablesnetworkingMode=mirrored, so use thenameserveraddress from/etc/resolv.confor$(hostname).localfor a Windows-side proxy.
To manage local Claude Desktop instead of a remote CLI, pin the extension to the local side:
// settings.json
"remote.extensionKind": {
"silver-zhang.ai-provider-switcher": ["ui"]
}
Reload after changing it. With "ui", the ~/.claude and ~/.codex directories the extension writes become the local ones too.
Installation
Install a VSIX
- Download the
.vsixfile from Releases. - Open the Extensions view in VS Code.
- Select
…→ Install from VSIX…. - Run Developer: Reload Window.
Run from source
- Install Node.js LTS.
- Clone the repository and run
npm install. - Run
npm test. - Press
F5to open an Extension Development Host.
If PowerShell blocks npm.ps1, use npm.cmd install and npm.cmd test.
Quick start
Open the manager by either:
- clicking the
Claude: ... · Codex: ...status bar entry; - running AI Provider Switcher: Open Provider Manager; or
- running AI Provider Switcher: Quick Switch Provider.
Claude guide
Configure Claude Code (VS Code / terminal)
This flow affects Claude Code inside VS Code and terminal claude only; it does not change Claude Desktop:
- Open the manager; from the overview choose Claude Code (VS Code / terminal) → Switch Claude Code provider.
- If there is no provider yet, add one with the + in the Claude list; enter its name, service root URL, and token. Usually omit a trailing
/v1. - In that provider's Claude Code (VS Code / terminal) section, choose Configure Claude Code models.
- Use Fetch models from service. For non-Claude model IDs, use Auto-assign roles as a starting point, then adjust main, fast, and 1M choices as needed.
- Choose Save Claude Code configuration. When the provider is active, the extension writes VS Code and terminal CLI configuration and offers a VS Code reload; start a new Claude conversation afterward.
- Command strategy also belongs only to Claude Code / CLI and is configured from that provider's Command strategy action.
Configure Claude Desktop (independent app)
This flow affects Claude Desktop only; it does not change Claude Code in VS Code or terminal CLI:
- From the overview choose Claude Desktop (independent app) → Switch Claude Desktop service, then select the relay.
- In that provider's Claude Desktop (independent app) section, choose Configure Desktop models.
- In the Full model catalogue, choose Add all cached models or tick only the real models you need. This is the recommended path for a mixed GPT / Claude relay.
- Choose Save Claude Desktop models. It immediately rewrites the Desktop config only when Desktop is currently using that provider; otherwise it is applied the next time you switch Desktop to it.
- Fully quit and restart Claude Desktop according to the platform-specific instruction — closing a window is usually not enough.
Advanced: legacy compatibility aliases is only for an existing old configuration or a name the relay explicitly documents. New users do not need to configure it.
Return to the official Claude subscription
Run AI Provider Switcher: Use Claude Official Subscription, review external conflicts, and reload VS Code. Managed provider environment entries are removed and the command strategy is returned to Manual.
Terminal Claude CLI and Claude Desktop
- Terminal CLI: switching a gateway (or back to official) writes the same managed
ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKENblock into~/.claude/settings.json'senv— your other env entries and every other setting are preserved, with a timestamped backup before each change. The CLI shares the same session history as the VS Code integration, soclaude --resumeagrees on both sides. - Claude Desktop (independent): run AI Provider Switcher: Switch Claude Desktop Service to switch the desktop app alone; VS Code and CLI configuration are never touched. The desktop app does not read
env— it routes through its own third-party inference mechanism, so the extension writesconfigLibrary/<id>.json(gateway URL and key) andconfigLibrary/_meta.json(appliedIdselects the live entry) under the app data directory, and switchesclaude_desktop_config.json'sdeploymentModeto3p(back to1pfor official). Existing preferences, MCP configuration, and unknown fields are preserved; changes are backed up first.- The data directory is auto-detected (Windows
%LOCALAPPDATA%\Claudeand%APPDATA%\Claude, macOS~/Library/Application Support/Claude, Linux$XDG_CONFIG_HOME/Claudeor~/.config/Claude). For installs elsewhere use the Change Claude Desktop data directory… picker or setaiProviderSwitcher.claudeDesktopConfigRoot; a failed detection lists the paths that were tried. - The manager chip and switch dialog read the desktop state back from disk, so changes made inside the app or by another tool show up truthfully.
- Switching writes the gateway's cached models into the entry's
inferenceModels, so the desktop app stops running its own model discovery — the request most relays answer with 404, which is what leaves the model picker empty and every message failing withYour organization's model list hasn't loaded yet. Refresh the model list first, then switch. A configured model mapping is carried across as each entry'santhropicFamilyTier, which is what makes theopus/sonnet/haikunames in the desktop picker resolve to real models. - ⚠️ The desktop app only accepts model names that read like Anthropic models (containing
claude/opus/sonnet/haiku, etc.). This is the app's own restriction: one non-compliant name invalidates the whole entry, sodeepseek-*,gpt-*,qwen-*original names cannot be written directly. - Advanced compatibility aliases (only for old configuration or an explicit provider requirement): this is not the normal setup path. Once a full model catalogue is active, compatibility aliases do not participate in Desktop routing at all; new users should use the catalogue. Enter an alias only when the provider's documentation explicitly tells you to send that name verbatim.
opus/sonnet/haiku/fableare generation-neutral Desktop tier labels — strongest, general-purpose, fast/low-cost, and enhanced reasoning — not specific official Claude versions, and no gateway is guaranteed to support them. Do not guess aclaude-*-numbermodel name; leave this empty when unsure.- Existing saved aliases are never automatically changed, so an upgrade cannot break a working relay. To migrate, clear the aliases and use the full model catalogue.
- *Local model-name rewriting proxy (how gpt- and other non-Anthropic models reach the desktop app)**: when the gateway only accepts its own literal model IDs (e.g.
gpt-5.6) and does not recognise Claude names, the extension starts a lightweight forwarder on127.0.0.1:<port>that rewrites the desktop app's safe alias back to the real model before forwarding — so the gateway always receives its literal name and never has to map anything itself. The desktop config's gateway URL points at this local forwarder, while the key is still the real gateway key, forwarded untouched. The port defaults to4180(change it withaiProviderSwitcher.claudeProxyPort). The proxy lives inside the VS Code extension host and binds to loopback only, so Claude Desktop must be on the same machine (unreachable under Remote-SSH/WSL); a VS Code reload restarts the proxy, and the fixed port keeps the address stable. - Full model catalogue (local proxy): in a provider's Claude Desktop (independent app) → Configure Desktop models area, fetch the model list, then use Add all cached models in Desktop full model catalogue — or tick just the models you need. Each GPT, Claude, or other model gets a distinct Desktop route. The picker label retains the real model name (for example
gpt-5.6 · REAL-Hajimi-GPT), while its internal ID is a safe opaque route so Desktop's non-Anthropic-name validation does not reject it. The full catalogue takes precedence over advanced compatibility aliases; Clear full model catalogue returns to aliases or native direct routing. - Fully quit and restart the desktop app (including the tray icon) after switching.
- Deleting a Claude gateway also unlinks its desktop config entry and, when it was the live one, restores the official subscription.
- ⚠️ The gateway key is written in plain text into that configuration file (the format the desktop app requires); file protection is whatever the user data directory provides.
- The data directory is auto-detected (Windows
- Note: session history does not decrypt across backends — continuing a conversation created on gateway A with gateway B may fail (the encrypted reasoning block can only be decrypted by the backend that produced it).
Map non-Claude models
Run AI Provider Switcher: Configure Claude Model Mapping. Recommended mode uses one main model and one fast/low-cost model; advanced mode configures each family separately. Enable the 1M marker only when the provider explicitly supports it.
Inspect Claude conflicts
Run AI Provider Switcher: Inspect Other Claude Configuration. The extension checks inherited process variables, ~/.claude/settings.json, and workspace .claude/settings.json / .claude/settings.local.json. Credential values are masked. Supported file edits are preceded by a timestamped backup and preserve permissions and unrelated settings.
Codex guide
Use a custom Codex provider (Windows/macOS/Linux)
- Open the manager and select Manage Providers on the Codex card.
- Add a named provider with its service root URL.
- Switch to it and enter the API key.
- The extension fetches
/v1/models, writes a local catalog, and updates~/.codex/config.toml. - Reload VS Code.
- Open Codex and select a model from Codex's native model control.
- Start a new conversation after switching.
Enter a root such as https://api.example.com; /v1 is derived automatically.
Unified Codex session history (official and third-party in one list)
Codex buckets its history by the model_provider tag each session records: the official subscription lands in the built-in openai bucket while each managed gateway has its own id, so after frequent switches old sessions can look “gone”. AI Provider Switcher: Unified Codex Session History (or the Codex card's Unified history button) removes that split:
- When enabled, the official subscription runs under the shared
customprovider id (authentication still goes through the ChatGPT login inauth.json;base_urlfalls back to the official backend — only the classification tag changes), so official and third-party sessions appear in one history list. - The enable dialog offers “Enable and migrate existing official sessions” (recommended; backed up first) or “Enable only (no migration)” (affects only sessions created afterwards).
- When disabled, migration backups make “Disable and restore migrated sessions” available: a ledger-based restore flips back only sessions that are both in the ledger and still tagged
custom. Sessions created while unified was on cannot be attributed, so they stay in the shared list (visible again when re-enabled).
Safety:
- Migration/restore rewrites only
session_meta.model_provider(~/.codex/sessions,archived_sessions.jsonlfiles) andthreads.model_provider(state_5.sqlite/state.db) — never conversation content. - Full-file backups under
~/.codex/ai-provider-switcher-backups/codex-official-history-unify-v1/<timestamp>/(jsonl/,state/,meta.json) before every rewrite; restores back up first tocodex-official-history-unify-restore-v1/. - Atomic writes, file-unchanged verification, per-item fault isolation, and a bounded startup retry. A database in WAL mode is snapshotted safely.
- Refusal gates: unified routing is not injected when
config.tomlalready carries an explicitmodel_provideror a manually defined[model_providers.custom]section.
[!WARNING] Resuming an old session on a different provider may fail because the other backend cannot decrypt the session's
encrypted_contentreasoning — an upstream Codex design. Unification solves list visibility, not cross-provider continuation; resume old sessions on their original provider.
Return to official Codex
Run AI Provider Switcher: Use Codex Official Provider and reload. This removes extension-managed provider blocks and restores the three recorded top-level keys; it is not a complete rollback of the entire config.toml file.
Fix repeated Codex Reconnecting
Some proxy setups handle HTTPS while Codex's WebSocket connection does not use the proxy correctly, causing repeated reconnect attempts before fallback. Run:
AI Provider Switcher: Configure Codex WebSocket Proxy
Recommended workflow:
- Start your local proxy and ensure its HTTP or mixed port is available.
- Inspect existing
.envproxy conflicts. - Select Auto-detect and apply this device's proxy.
- Keep the default Official OpenAI provider only scope.
- Reload VS Code.
- Start a new Codex conversation and verify that repeated reconnect attempts are gone.
Detection order:
HTTPS_PROXY/https_proxy.HTTP_PROXY/http_proxy.- VS Code
http.proxy. - Windows user proxy settings.
- macOS
scutil --proxy. - GNOME Linux
gsettings.
If detection fails, enter a full HTTP(S) proxy URL such as http://127.0.0.1:7890. The port is never hard-coded. socks5:// URLs are not currently accepted.
Proxy scope
- Official OpenAI provider only (default, recommended): the managed proxy block is active for official Codex and paused while a custom provider is active.
- Official and all custom providers: use only when a custom gateway must also pass through the local proxy. Otherwise this may add latency, change the outbound IP, or make the gateway unreachable.
Safe .env management
The extension owns only a marked block in ~/.codex/.env. It checks existing unmanaged HTTP_PROXY, HTTPS_PROXY, and NO_PROXY entries before writing. Disabling the feature removes only its marked block and preserves unrelated content. Proxy settings use VS Code machine scope and should not be synchronized between devices.
Data and security
| Data | Storage and behavior |
|---|---|
| Claude provider metadata and model cache | Global VS Code settings |
| Claude token | VS Code Secret Storage and, while active, claudeCode.environmentVariables for the Claude Code extension |
| Claude permission mode | Global VS Code settings and ~/.claude/settings.json |
| Terminal CLI environment | A managed env block in ~/.claude/settings.json |
| Claude Desktop configuration | Entries under the app data directory's configLibrary/ with appliedId in _meta.json; deploymentMode in claude_desktop_config.json |
| Codex provider metadata and model cache | Global VS Code settings |
| Codex API key | VS Code Secret Storage; additionally a current-user DPAPI file on Windows or a mode-0600 local key file on macOS/Linux; never written to config.toml |
| Codex provider configuration | Top-level selection and marked blocks in config.toml under the Codex home |
| Codex model catalog | ai-provider-switcher-models.json under the Codex home |
| Codex proxy | A marked block in .env under the Codex home |
| Unified history backups | ai-provider-switcher-backups/codex-official-history-unify-v1/ (migration) and codex-official-history-unify-restore-v1/ (restore), under the Codex home |
The Codex home defaults to
~/.codex(%USERPROFILE%\.codexon Windows). WhenCODEX_HOMEis set, the extension follows it — Codex reads there, so writing to the default would be a silent no-op. Every message in the UI prints the full path actually used. | Provider usage snapshots | Global VS Code settings; only balance, percentages, rate-limit values, and timestamps are cached, not raw API bodies |
Security guidance:
- Prefer HTTPS providers. HTTP transports credentials in model-discovery requests without TLS protection.
- Claude Code needs the active custom token, so it is also present in VS Code user settings while that provider is active. Protect your settings and limit untrusted local processes and extensions.
- Switch Claude back to official mode before clearing a saved token. The clear-token command alone removes only the Secret Storage copy.
- Windows DPAPI binds the file to the current user; macOS/Linux rely on the user directory and
0600file permissions. Neither is hardware-backed protection or protection from malicious processes running as the same user. - Never use
bypassPermissionsin a normal workspace containing important data or real credentials.
Troubleshooting
The old provider is still active
Reload VS Code and start a new conversation. For Claude, run the external configuration inspector to find inherited or project-level overrides.
Claude chat works, but Auto blocks commands
In currently tested Claude Code versions, Auto may use a separate safety-classifier request. A provider serving the main model may still reject that request. Use Accept Edits or Manual instead of broad allow rules.
Custom Codex models do not appear
Verify Responses API and /v1/models support, refresh Codex models, reload, and use Codex's native model control.
Codex still reconnects after proxy configuration
Verify that the proxy process is running, its port is listening, it supports HTTP or mixed proxying, and VS Code was reloaded. PAC files, authenticated enterprise proxies, and special network policies may require manual setup.
Are sessions deleted when switching?
No. Local session history is preserved, but an active conversation is not migrated across providers. Start a new conversation after switching.
A self-hosted relay (one-api / new-api / LiteLLM) returns no models
Enter the Base URL with the scheme the service actually listens on. Locally these usually serve plain HTTP, so the address is http://127.0.0.1:3000, not https://…. When it is wrong, the extension now names the actual cause — DNS failure, refused port, or a rejected certificate — instead of a generic connection error.
"Not valid JSON, cannot write safely"
Open the file named in the message. If its contents look fine, it most likely starts with an invisible BOM (written by Notepad, or by PowerShell Set-Content / > redirection) — since 0.5.5 the extension ignores a BOM and treats an empty file as empty, so upgrading is the fix. If the file really was hand-edited into invalid JSON, a .ai-provider-switcher-<timestamp>.bak copy from before the last change sits next to it.
Claude Desktop was switched but nothing changed
The desktop app reads its config only on a cold start, and closing the window is not quitting: on Windows right-click the tray icon and choose Quit, on macOS press ⌘Q or use Claude → Quit, on Linux confirm the process has exited. The extension's own message states this for the platform you are on.
Windows reports the file is in use (EPERM / EBUSY)
Another program holds the config open. Close Claude Desktop, close any editor with the file open, or pause real-time antivirus scanning, then retry. The extension retries briefly on its own and names the file if it still fails.
Why does resuming an old session fail under unified Codex history?
The session file is intact. The cause is upstream design: the encrypted_content reasoning ciphertext can only be decrypted by the backend that produced it, so another provider cannot continue it. Resume on the original provider, or start a new session.
Commands
Search AI Provider Switcher in the Command Palette. Common commands include:
AI Provider Switcher: Quick Switch ProviderAI Provider Switcher: Open Provider ManagerAI Provider Switcher: Use Claude Official SubscriptionAI Provider Switcher: Switch Claude Desktop ServiceAI Provider Switcher: Manage Claude GatewaysAI Provider Switcher: Edit Claude GatewayAI Provider Switcher: Configure Claude Model MappingAI Provider Switcher: Configure Claude Command StrategyAI Provider Switcher: Configure Claude Desktop ModelsAI Provider Switcher: Inspect Other Claude ConfigurationAI Provider Switcher: Switch Codex ProviderAI Provider Switcher: Use Codex Official ProviderAI Provider Switcher: Manage Codex ProvidersAI Provider Switcher: Edit Codex ProviderAI Provider Switcher: Unified Codex Session HistoryAI Provider Switcher: Refresh Codex ModelsAI Provider Switcher: Configure Codex WebSocket Proxy
Development and contributing
- Build:
npm run compile - Test:
npm test - Debug: press
F5in VS Code - Package:
npx vsce package
Bug reports, compatibility feedback, and feature requests are welcome through GitHub Issues.
License
See LICENSE.