22
33[ ![ CI] ( https://github.com/gaoguobin/codex-fast-proxy/actions/workflows/ci.yml/badge.svg )] ( https://github.com/gaoguobin/codex-fast-proxy/actions/workflows/ci.yml )
44
5- Local Fast proxy for Codex App and Codex CLI. It lets Codex use providers that
6- support ` service_tier="priority" ` even when the official Codex App does not send
7- that field.
5+ Use third-party OpenAI-compatible API providers with Codex App while keeping the
6+ Fast / priority request path enabled.
87
9- [ 中文说明] ( #中文说明 ) · [ Install] ( #install ) · [ Change Upstream] ( #change-upstream ) · [ Update] ( #update ) · [ Uninstall] ( #uninstall ) · [ Safety] ( #safety-model ) · [ Sponsor] ( #sponsor )
8+ Codex CLI already has a Fast path, but Codex App requests may arrive at
9+ ` POST /v1/responses ` without the wire-level ` service_tier ` field. This local
10+ proxy fills only that missing field, keeps streaming untouched, and gives users
11+ a read-only dashboard to verify real traffic and benchmark whether their
12+ provider actually benefits from the priority lane.
1013
11- ## What It Does
14+ [ Chinese ] ( #chinese ) · [ Install ] ( #install ) · [ Dashboard ] ( #dashboard ) · [ Benchmark ] ( #benchmark ) · [ Change Upstream ] ( #change-upstream ) · [ Update ] ( #update ) · [ Uninstall ] ( #uninstall ) · [ Safety ] ( #safety-model ) · [ Sponsor ] ( #sponsor )
1215
13- - Injects ` service_tier="priority" ` only into ` POST /v1/responses ` requests when the field is absent.
14- - Leaves ` model ` , ` reasoning ` , ` tools ` , ` input ` , and all existing request fields unchanged.
15- - Preserves SSE streaming responses without parsing or rewriting ` event: ` / ` data: ` frames.
16- - Reads the active Codex provider from ` ~/.codex/config.toml ` and saves the original ` base_url ` as the upstream.
17- - Backs up Codex config, restores safely, and avoids overwriting user edits during uninstall.
18- - Installs a Codex ` SessionStart ` hook after enable, so future Codex App/CLI startups restart the
19- proxy before the first provider request when config still points to the proxy.
20- - Serves a read-only local status page for browser visits to the proxy root or base URL.
21- - Writes redacted JSONL logs without headers, API keys, cookies, request bodies, or prompts.
22- - Ships with a Codex skill so users can ask Codex to install, enable, check, update, or uninstall it.
16+ ![ Codex Fast Proxy dashboard] ( docs/assets/dashboard.png )
17+
18+ ## Why
19+
20+ This project is for Codex App users who already use a third-party API provider
21+ or relay service and want the same Fast / priority behavior they can get from
22+ Codex CLI. It is designed to be installed and operated by Codex itself: paste
23+ the install prompt, restart once for skill discovery, then ask Codex to enable
24+ the proxy.
25+
26+ ## Highlights
27+
28+ | Capability | What it means |
29+ | --- | --- |
30+ | Narrow injection | Adds ` service_tier="priority" ` only to ` POST /v1/responses ` when the field is absent. |
31+ | Streaming safe | Preserves SSE responses without parsing or rewriting ` event: ` / ` data: ` frames. |
32+ | Request safe | Leaves ` model ` , ` reasoning ` , ` tools ` , ` input ` , and all existing request fields unchanged. |
33+ | Provider agnostic | Reads the active Codex provider from ` ~/.codex/config.toml ` and stores the original upstream URL. |
34+ | Visual verification | Serves a local read-only dashboard with status, recent redacted requests, and benchmark summary. |
35+ | Real benchmark | Runs opt-in A/B tests against real Codex-style requests to show whether priority is accepted and faster. |
36+ | Startup hook | Installs a Codex ` SessionStart ` hook so future Codex App/CLI sessions can restart the proxy automatically. |
37+ | Safe rollback | Backs up Codex config, restores conservatively, and avoids overwriting user edits during uninstall. |
2338
2439## Compatibility
2540
@@ -44,7 +59,7 @@ After installation, restart Codex App and return to the same conversation, or op
4459process. Then ask:
4560
4661``` text
47- 启用 Codex Fast proxy
62+ Enable Codex Fast proxy
4863```
4964
5065After enabling, restart Codex App again, or open a new Codex CLI process, so the running Codex
@@ -56,7 +71,7 @@ to restart the proxy automatically when the recorded provider still points to th
5671Ask Codex:
5772
5873``` text
59- 查看 Codex Fast proxy 状态
74+ Show Codex Fast proxy status
6075```
6176
6277Or run:
@@ -75,12 +90,26 @@ You can also open `http://127.0.0.1:8787/v1` in a browser. Browser-style HTML re
7590read-only dashboard with local proxy status and recent redacted events; API requests continue to be
7691forwarded normally.
7792
93+ ## Dashboard
94+
95+ The local dashboard is available at the configured proxy base URL, usually
96+ ` http://127.0.0.1:8787/v1 ` . It is intentionally read-only and uses only redacted
97+ runtime metadata:
98+
99+ - Current local proxy status, upstream URL, injected tier, and recent success count.
100+ - Recent ` /v1/responses ` traffic with local time, status, latency, injection state, and stream flag.
101+ - Latest saved benchmark result, including observed speedup and sample counts when the user has run one.
102+ - Quick manager commands and privacy notes for agents operating inside Codex.
103+
104+ The dashboard does not expose request bodies, prompts, headers, API keys, tool
105+ arguments, or response contents.
106+
78107## Benchmark
79108
80109Ask Codex:
81110
82111``` text
83- 跑一下 Codex Fast proxy A/B benchmark
112+ Run the Codex Fast proxy A/B benchmark
84113```
85114
86115Or run:
@@ -136,7 +165,7 @@ python -m codex_fast_proxy set-upstream --upstream-base https://api.example.com/
136165Or ask Codex:
137166
138167``` text
139- 把 Codex Fast proxy 的上游切到 https://api.example.com/v1
168+ Set Codex Fast proxy upstream to https://api.example.com/v1
140169```
141170
142171` set-upstream ` refuses to run if the recorded provider no longer points to the local proxy. When it
@@ -268,12 +297,18 @@ python -m codex_fast_proxy serve `
268297 --service-tier priority
269298```
270299
300+ <a id =" chinese " ></a >
301+
271302## 中文说明
272303
273304` codex-fast-proxy ` 是一个本地 Fast 代理,面向 Codex App 和 Codex CLI。它解决的核心问题是:
274305Codex App 发送 ` POST /v1/responses ` 时可能没有 ` service_tier ` 字段,而部分上游 provider
275306需要 ` service_tier="priority" ` 才会进入 Fast / priority 通道。
276307
308+ 它适合已经在 Codex App 中使用第三方 OpenAI-compatible API provider / 中转站的用户。安装后仍然
309+ 由 Codex 读取自己的 provider 配置,proxy 只补缺失的 Fast 参数,并通过本地只读 dashboard 展示
310+ 状态、最近请求和 benchmark 结果,方便确认 App 是否真的走到了 priority 通道。
311+
277312### 快速安装
278313
279314把这句话贴给 Codex:
@@ -308,6 +343,10 @@ python -m codex_fast_proxy status
308343日志里应出现 ` /v1/responses ` ,并显示 ` service_tier_before="<absent>" ` 、
309344` service_tier_after="priority" ` 、` service_tier_injected=true ` 、` response_content_type="text/event-stream" ` 。
310345
346+ 也可以在浏览器打开 ` http://127.0.0.1:8787/v1 ` 查看本地只读 dashboard。它会显示 proxy 状态、
347+ 当前 upstream、最近脱敏请求、是否注入 priority、SSE 状态,以及最近一次 benchmark 摘要;不会展示
348+ prompt、请求体、API key、headers、tool arguments 或响应内容。
349+
311350### Benchmark
312351
313352对 Codex 说:
0 commit comments