Codex Model Router在 VS Code 中为 Codex 管理模型接入。扩展内置代理默认只监听本机,也可改为局域网监听:Codex 选择稳定的模型别名,Router 将后续请求转发到你配置的供应商和实际模型。更换上游时,可以保留会话正在使用的别名。 Manage Codex model connections inside VS Code. The extension runs a proxy that listens on loopback by default and can optionally listen on the LAN. Codex selects a stable model alias, and Router forwards subsequent requests to your configured provider and actual model. You can change the upstream destination while keeping the alias used by a conversation. 本扩展是独立的社区工具,并非 OpenAI 或 VS Code 官方扩展。需要另行安装 Codex 扩展,并自行准备可用的供应商账号和 API Key。 This is an independent community tool, not an official OpenAI or VS Code extension. Install the Codex extension separately and provide your own supported provider account and API key. 工作方式 / How it worksRouter 在 VS Code 扩展主机内提供本地 Responses 代理和图片生成 MCP 工具。配置面板维护供应商、Codex 可见的模型、实际模型映射及图片设置;无需另外启动常驻代理程序。 Router provides a local Responses proxy and an image-generation MCP tool inside the VS Code extension host. Its panel manages providers, Codex-visible models, upstream model mappings, and image settings. No separate background proxy program is required.
Codex 从本机 Codex reads model capabilities from its local
供应商地址、API Key、“别名 → 供应商 → 实际模型”的映射和详细日志开关保存后,对后续请求生效;已经发出的请求沿用开始时的配置。新增别名、调整显示名称或模型能力会更新 Codex 模型目录,保存后还需重新加载 Codex。改动代理监听端口或监听范围会自动重新绑定监听,并需要同步更新 Codex 的接入地址。 Provider URLs, API keys, alias-to-provider-to-model mappings, and the detailed-logging switch take effect for subsequent requests after saving; in-flight requests keep their original settings. New aliases, display names, and model capabilities update the Codex model catalog and require a Codex reload after saving. Changing the proxy port or listen mode rebinds its listener and requires an updated Codex connection URL. 保存结果会指出本次修改的具体类别。更换映射供应商或实际模型不会改变别名的能力设置,也不需要重载 Codex;模型选择器的供应商标记可在下次重载时刷新。若此前还有模型列表或能力变更待加载,面板会单独说明,运行时路由仍实时生效。 Save feedback identifies the categories changed by that operation. Changing the mapped provider or actual model preserves the alias's capabilities and does not require a Codex reload; supplier labels in the model picker can refresh on the next reload. Earlier pending catalog or capability changes are reported separately and do not prevent live routing updates. 开始使用 / Get started安装桌面版 VS Code 1.95 或更新版本及 Codex 扩展,然后安装 Codex Model Router。在活动栏打开 Codex Router。首次启动会创建本地配置,默认没有预置供应商、个人代理地址或 API Key。 Install desktop VS Code 1.95 or later and the Codex extension, then install Codex Model Router. Open Codex Router from the Activity Bar. The first launch creates local configuration without preconfigured providers, private proxy URLs, or API keys. 先在 设置 页填写并保存对外代理 API Key;允许 2–256 位大小写字母、数字和 First set and save the Router API key in Settings using 2–256 ASCII letters, digits, or 在 Codex加载模型 页建立 Codex 可见的模型别名并填写模型能力;在 模型映射 页把别名关联到供应商和实际模型 ID。点击底部的 保存配置。对话模型能力包括上下文窗口、图片输入及可选推理强度,应按实际供应商能力填写;Router 不会自动检测这些规格。 In Codex models, create a model alias visible to Codex and enter its capabilities. In Model mappings, connect that alias to a provider and an actual upstream model ID. Click Save configuration at the bottom. Enter conversation-model capabilities such as context window, image input, and reasoning levels according to your provider; Router does not discover those specifications automatically. 在 设置 页点击 复制接入配置,再点击旁边的 打开 Codex 配置文件,把片段合并到 In Settings, select Copy Codex configuration, then Open Codex config file, and merge the snippet into 下列内容仅说明接入形状; The following shows the connection shape only;
局域网客户端请在 Router 主机的 模型文件 区点击 打开模型文件目录,把 For a LAN client, use Open model-file directory on the Router host, copy 首次接入或修改模型目录后重新加载 Codex,然后在 Codex 的模型选择器中选择别名。Router 不会自动改写 Codex 的 TOML 文件;更换已有别名的上游映射时,则只需在 Router 中保存。 Reload Codex after initial connection or a catalog change, then select an alias in the Codex model picker. Router does not edit Codex's TOML file automatically. To change the upstream destination of an existing alias, save the mapping in Router. 配置页面 / Configuration pagesCodex加载模型 管理别名、用途和能力;供应商 管理 API 地址及密钥;模型映射 管理实际模型的去向。这三页把 Codex 所见的名字、访问凭证和上游模型分开,因此同一个实际模型可以由多个别名引用。 Codex models manages aliases, purpose, and capabilities; Providers manages API endpoints and keys; Model mappings manages upstream destinations. These pages keep the name visible to Codex, credentials, and actual model ID separate, so several aliases may use one upstream model. 图片MCP 管理可用图片模型、默认模型和图片保存模式;设置 管理监听范围、端口、入口密钥、日志开关、Codex 接入片段、重载入口以及配置备份。多窗口同时编辑时,旧版本配置不会覆盖另一窗口的新保存;需要加载最新配置再继续编辑。 Image MCP manages available image models, the default model, and image storage mode. Settings provides the listener mode and port, ingress key, logging switch, Codex connection snippet, reload action, and configuration backup. When multiple windows edit the same files, an older draft cannot overwrite a newer save from another window; reload the latest configuration before continuing. 图片生成 / Image generation图片生成模型与对话模型分别配置。把图片别名映射到支持 Configure image-generation models separately from conversation models. Map an image alias to a provider supporting 内存模式默认不在本地生成图片副本;文件模式或单次工具调用的 Memory mode does not save a local copy by default. File mode, or 备份与迁移 / Backup and migrationRouter 把用户设置保存在 Router stores user settings in 设置 页可以把 Settings can export 适用场景 / When to use it当多个供应商提供兼容的 Responses 接口,或者同一模型有不同上游渠道时,Router 可以让 Codex 使用固定别名,在配置面板里切换后续请求的目标。它也适合保留备用别名,以便给不同会话选择不同映射;修改一个共享别名会影响所有使用它的会话后续请求。 Router is useful when several providers offer compatible Responses APIs, or when the same model is available through several upstream channels. Codex can keep a stable alias while you change the destination for later requests. Reserve aliases can give different conversations different mappings; changing a shared alias affects future requests from every conversation using it. Router 不会把 Chat Completions 接口转换为 Responses,也不会替供应商补齐不支持的工具调用、压缩或图片能力。上游报错会返回给 Codex,代理不会自动换供应商重试。模型目录中填写的能力应与实际模型匹配,尤其是上下文、图片输入和推理档位。 Router does not convert Chat Completions to Responses or add tool calling, compaction, or image features missing from a provider. Upstream errors go back to Codex; the proxy does not automatically retry with another provider. Catalog capabilities should match the actual model, especially context size, image input, and reasoning levels. 隐私与运行边界 / Privacy and runtime boundariesAPI Key 按本扩展的设计明文保存在本机 By design, API keys are stored in plain text in the local 详细日志开启后,Responses 和压缩接口的 token 统计由旁路解析,不会改动或等待客户端响应。当前支持未压缩的 JSON 与 SSE;HTTP 内容编码为 gzip 或 br 时仍原样透传,用量显示为 With detailed logging enabled, Responses and compaction token statistics are parsed separately without modifying or holding back client responses. Uncompressed JSON and SSE are supported; HTTP bodies encoded with gzip or br are forwarded unchanged and their usage is shown as 代理随 VS Code 扩展主机运行;关闭全部相关窗口或停用扩展会停止监听。多个窗口可以复用同一配置、密钥、端口和监听范围,但正在进行的请求不会在宿主窗口退出时迁移。Remote SSH、WSL 或容器环境中,Codex 进程必须能访问运行 Router 的主机地址;远程场景需要自行核对连通性。 The proxy runs with the VS Code extension host; closing all relevant windows or disabling the extension stops its listener. Multiple windows can share the same configuration, key, port, and listen mode, but in-flight requests do not migrate if the host window exits. Under Remote SSH, WSL, or containers, the Codex process must be able to reach the Router host; verify connectivity in your remote setup. 本项目使用 MIT 许可证。版本变更见扩展详情页的 Changelog。 This project is licensed under MIT. See the extension's Changelog page for release notes. |