Skip to content

Commit d79b779

Browse files
authored
docs: inline Authorization in Codex config.toml example (#446)
env_key = "PROXY_API_KEY" requires the env var to be visible to the GUI process. macOS/Windows GUI apps do not inherit shell rc files, so users following the README hit `Missing environment variable: PROXY_API_KEY` on first launch and have to learn launchctl setenv or write a LaunchAgent. Switching the canonical example to inline `http_headers` removes that friction; env_key is kept in a callout as the alternative when the key needs to stay out of the config file. Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
1 parent 7a93c6e commit d79b779

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
99
## [Unreleased]
1010

11+
### Changed
12+
13+
- README / README_EN 的 Codex CLI + Codex Desktop 两节示例从 `env_key = "PROXY_API_KEY"` 改成 `[model_providers.proxy_codex.http_headers]` 内嵌 `Authorization = "Bearer ..."`:原写法在 GUI 客户端启动时会因为 macOS / Windows GUI 进程不继承 shell rc 的环境变量而报 `Missing environment variable: PROXY_API_KEY`,普通用户得额外学 `launchctl setenv` 或 LaunchAgent 才能让 Codex Desktop 看到环境变量;http_headers 把 key 直接写在 config 文件里,重启 Codex 即用。`env_key` 写法作为「需要密钥从配置文件解耦」(多人共享 / 仓库提交)场景的备选保留在文档说明里
14+
1115
### Fixed
1216

1317
- `promote-dev-to-master.yml``bump-electron.yml` 末尾各补一步 `gh workflow run docker-publish.yml --ref master`:GitHub Actions 安全策略禁止默认 `GITHUB_TOKEN` 触发的 push 事件再触发其他 workflow(防递归),导致 promote 把 dev fast-forward 到 master、bump 提交版本号 commit + tag 之后,`docker-publish.yml``on: push: branches: [master]` 全部静默不跑——表象就是 ghcr.io 上的 `:latest` / `:vX.Y.Z` 长期停留在最后一次"人手 push master"的时刻(最近一次是 2026-04-30,期间 master 已经吃下 4 天的 promote)。`workflow_dispatch` 是 GITHUB_TOKEN 允许触发的少数事件之一,所以两条管道收尾各 dispatch 一次即可衔接;docker-publish 已有 `concurrency: cancel-in-progress: true`,promote + bump 两次 dispatch 在窗口期重叠时后者直接接管,最终镜像反映 bump 后的新版本号。配套把 promote 的 `permissions: actions``read` 升到 `write`(dispatch 需要)

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,17 @@ claude
283283
name = "Codex Proxy"
284284
base_url = "http://localhost:8080/v1"
285285
wire_api = "responses"
286-
env_key = "PROXY_API_KEY"
286+
287+
# 直接把 API Key 写进 config(推荐:本地单用户场景)
288+
[model_providers.proxy_codex.http_headers]
289+
Authorization = "Bearer your-api-key"
287290

288291
[profiles.default]
289292
model = "gpt-5.4"
290293
model_provider = "proxy_codex"
291294
```
292295

293-
```bash
294-
export PROXY_API_KEY=your-api-key
295-
codex
296-
```
296+
> 💡 也可以改用环境变量:把 `[model_providers.proxy_codex.http_headers]` 这两行删掉,换成 `env_key = "PROXY_API_KEY"`,然后 `export PROXY_API_KEY=your-api-key && codex`。需要避免密钥落到 config 文件(多人共享 / 开源仓库)时用这个。
297297
298298
### Claude Desktop
299299

@@ -335,14 +335,18 @@ codex
335335
name = "Codex Proxy"
336336
base_url = "http://localhost:8080/v1"
337337
wire_api = "responses"
338-
env_key = "PROXY_API_KEY"
338+
339+
[model_providers.proxy_codex.http_headers]
340+
Authorization = "Bearer your-api-key"
339341

340342
[profiles.default]
341343
model = "gpt-5.4"
342344
model_provider = "proxy_codex"
343345
```
344346

345-
> ⚠️ 如果你是通过“登录 ChatGPT 账号”方式使用的,客户端可能会忽略此配置。建议在环境变量中设置 `PROXY_API_KEY` 后启动。
347+
> 💡 **为什么不用 `env_key`** macOS / Windows 的 GUI 应用不读 shell 的 `~/.zshrc` / `.bashrc`,光 `export PROXY_API_KEY=...` 在终端里 GUI 进程根本看不到,启动会直接报 `Missing environment variable``http_headers` 把 Authorization 写在 config 里,重启 Codex 就能用,不用折腾 `launchctl setenv` 或 LaunchAgent。需要密钥从配置文件解耦时(共享机器 / 仓库提交)再换回 `env_key = "PROXY_API_KEY"` 走环境变量。
348+
>
349+
> ⚠️ 如果你是通过"登录 ChatGPT 账号"方式使用的,客户端可能会忽略此配置——只要 `[model_providers.proxy_codex]` 配上、`profiles.default.model_provider = "proxy_codex"`,新会话就会走 proxy;登录会话仍可能直接走官方上游。
346350
347351
### Claude for VSCode / JetBrains
348352

README_EN.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,17 @@ claude
252252
name = "Codex Proxy"
253253
base_url = "http://localhost:8080/v1"
254254
wire_api = "responses"
255-
env_key = "PROXY_API_KEY"
255+
256+
# Inline the API Key (recommended for local single-user setups)
257+
[model_providers.proxy_codex.http_headers]
258+
Authorization = "Bearer your-api-key"
256259

257260
[profiles.default]
258261
model = "gpt-5.4"
259262
model_provider = "proxy_codex"
260263
```
261264

262-
```bash
263-
export PROXY_API_KEY=your-api-key
264-
codex
265-
```
265+
> 💡 To keep the key out of the config file (shared machine / open-source repo), drop the `http_headers` block and use `env_key = "PROXY_API_KEY"` instead, then `export PROXY_API_KEY=your-api-key && codex`.
266266
267267
### Claude Desktop
268268

@@ -302,14 +302,18 @@ The official client shares configuration with the CLI. Restart the app after edi
302302
name = "Codex Proxy"
303303
base_url = "http://localhost:8080/v1"
304304
wire_api = "responses"
305-
env_key = "PROXY_API_KEY"
305+
306+
[model_providers.proxy_codex.http_headers]
307+
Authorization = "Bearer your-api-key"
306308
307309
[profiles.default]
308310
model = "gpt-5.4"
309311
model_provider = "proxy_codex"
310312
```
311313
312-
> ⚠️ If you are logged in via "ChatGPT account", the client might ignore this config. Launching with `PROXY_API_KEY` environment variable set is recommended.
314+
> 💡 **Why not `env_key`?** macOS/Windows GUI apps do not inherit env vars from your shell rc files — `export PROXY_API_KEY=...` in your terminal is invisible to the GUI process and Codex Desktop will fail with `Missing environment variable`. Inlining `Authorization` via `http_headers` avoids `launchctl setenv` / LaunchAgent gymnastics. Switch back to `env_key = "PROXY_API_KEY"` only when you need the key out of the config file.
315+
>
316+
> ⚠️ When logged in via "ChatGPT account", existing sessions might bypass this config and hit the official upstream directly. New sessions started after `[model_providers.proxy_codex]` is wired up + `profiles.default.model_provider = "proxy_codex"` will route through the proxy.
313317
314318
### Claude for VSCode / JetBrains
315319

0 commit comments

Comments
 (0)