文档目录
接入 Codex CLI
在 config.toml 里配置自定义模型提供方。
Codex CLI 通过自定义“模型提供方”接入。使用 Responses 接口(wire_api = "responses"),接入地址带 /v1。
1. 设置密钥环境变量
macOS / Linux
export TOKENWAY_API_KEY="sk-xxxxxxxx"Windows(新开一个终端后生效)
setx TOKENWAY_API_KEY "sk-xxxxxxxx"2. 编辑 config.toml
文件位置:~/.codex/config.toml(Windows 在用户目录下的 .codex\config.toml)。
~/.codex/config.toml
model = "gpt-5.5"
model_provider = "tokenway"
[model_providers.tokenway]
name = "Tokenway"
base_url = "https://tokenwayapi.com/v1"
env_key = "TOKENWAY_API_KEY"
wire_api = "responses"env_key 写的是环境变量的名字,不是密钥本身,密钥不要直接写进配置文件。
3. 运行
在项目目录里运行 codex。如果想临时换模型,用 codex -m 模型名。
GPT 系列同时支持 Chat Completions 和 Responses,Codex 推荐用 Responses。两种格式的区别见 接口格式。