You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,33 @@ Use Claude, Gemini, Grok, GLM, DeepSeek, Kimi, Qwen, Ollama, or any other LLM wi
17
17
18
18
opencodex is a lightweight local proxy that translates Codex's Responses API into whatever your provider speaks. Streaming, tool calls, reasoning tokens, images — everything works, in both directions.
19
19
20
+
It can also manage a **ChatGPT account pool** for Codex auth. Add multiple ChatGPT / Codex accounts,
21
+
refresh their 5h / weekly / 30d quota in the dashboard, and let new sessions auto-route to the
22
+
lowest-usage healthy account. Existing Codex threads stay pinned to the account that started them,
23
+
so long SSH, tmux, or mobile-connected sessions do not jump accounts mid-conversation.
@@ -115,9 +135,27 @@ Routed models also appear in the **Codex App** model picker with per-model reaso
115
135
<imgsrc="assets/codex-app-picker.png"alt="Codex App showing opencodex routed models with reasoning effort picker"width="480">
116
136
</p>
117
137
138
+
## ChatGPT account pool
139
+
140
+
Open **Codex Auth** in the dashboard to add pool accounts and choose which account should handle the
141
+
next Codex session. opencodex keeps two separate behaviors:
142
+
143
+
-**Existing sessions keep affinity.** A thread id is bound to the selected account and reused on
144
+
later turns, so a long request or a mobile/SSH-attached session keeps using the same account.
145
+
-**New sessions can auto-route.** When auto-switch is enabled, opencodex compares the hottest known
146
+
quota window across 5h, weekly, and 30d usage, then picks a lower-usage eligible account for new
147
+
sessions once the active account crosses the threshold.
148
+
-**Quota lookup is built in.** The dashboard can refresh all account quotas in one click, and the
149
+
request log labels pool traffic with non-PII account ordinals.
150
+
-**Failures fail closed.** Token failures mark reauthentication instead of falling back to another
151
+
credential silently; 429 quota responses put the account in cooldown and can fail over future work
152
+
to another eligible pool account.
153
+
118
154
## Highlights
119
155
120
156
-**Use any LLM with Codex.** 5 protocol adapters cover Anthropic Messages, Google Gemini, Azure, OpenAI Responses passthrough, and every OpenAI-compatible Chat Completions endpoint — that's 40+ providers out of the box.
157
+
-**Pool ChatGPT accounts safely.** Keep existing Codex threads on one account while new sessions
158
+
can auto-pick a lower-usage account from the pool, with quota refresh and non-PII request labels.
121
159
-**Log in once, skip the API key.** OAuth support for xAI, Anthropic, and Kimi means you can authenticate with your existing account. Tokens auto-refresh. Or forward your `codex login`, paste an API key, or use `${ENV_VAR}` references — your call.
122
160
-**Works everywhere Codex does.** Injects into Codex CLI, TUI, App, and SDK automatically. Routed models show up in Codex's model picker just like native ones.
123
161
-**Delegate to the right model.** Feature up to five routed or native models in Codex's subagent picker from the dashboard or config — route complex tasks to a reasoning model, fast tasks to a cheap one.

25
+
26
+
## Codex auth account selection
27
+
28
+
When the selected provider is the ChatGPT/Codex passthrough, opencodex can choose a stored pool
29
+
account before the request is forwarded upstream. The rule is intentionally split:
30
+
31
+
-**Existing thread ids keep affinity.** A thread is bound to the account generation that started it,
32
+
so a long SSH, tmux, or mobile-attached Codex session keeps using one account instead of being
33
+
rebalanced mid-conversation.
34
+
-**New sessions can rebalance.** For a new thread, opencodex compares known quota usage across 5h,
35
+
weekly, and 30d windows, skips accounts that need reauthentication or are in cooldown, and can
36
+
switch to a lower-usage eligible account when the active account crosses the configured threshold.
37
+
-**Quota and failure signals feed routing.** The dashboard can force a quota refresh with
|**Stop**| A sidebar button that gracefully shuts down the proxy, stops the background service if installed, and restores native Codex — all in one click (`POST /api/stop`). |
35
37
38
+
## Codex Auth and account pools
39
+
40
+
The **Codex Auth** page is for the native ChatGPT/Codex path. It separates existing sessions from
41
+
new sessions:
42
+
43
+
- Existing Codex thread ids keep their selected account, which makes SSH, tmux, and mobile-attached
44
+
sessions stable. A long-running conversation does not silently move between accounts.
45
+
- New sessions can automatically use the lowest-usage eligible account when auto-switch is enabled.
46
+
The score uses the hottest known quota window across 5h, weekly, and 30d usage.
47
+
- The quota refresh button calls the proxy to re-read account usage immediately, so routing and the
48
+
visible account cards stay in sync.
49
+
- Pool request logs use non-PII labels such as `chatgpt-1`, not account emails.
50
+
36
51
## How the dashboard talks to the proxy
37
52
38
53
The GUI is a thin client over the proxy's management API. Useful endpoints (all JSON):
@@ -45,6 +60,11 @@ The GUI is a thin client over the proxy's management API. Useful endpoints (all
45
60
|`GET /api/key-providers`| The API-key catalog (incl. Ollama Cloud). |
46
61
|`GET /api/oauth/providers`| Which providers support OAuth login. |
47
62
|`POST /api/oauth/login` · `GET /api/oauth/status`| Start an OAuth flow and poll for completion. |
63
+
|`GET /api/codex-auth/accounts?refresh=1`| List main + pool accounts and force quota refresh. |
64
+
|`PUT /api/codex-auth/active`| Choose the account used for the next new Codex session. |
65
+
|`PUT /api/codex-auth/auto-switch`| Set the quota threshold for automatic new-session account selection. |
66
+
|`PUT /api/codex-auth/failover`| Set how many transient upstream failures trigger future-session failover. |
67
+
|`POST /api/codex-auth/login` · `GET /api/codex-auth/login-status`| Add a pool account through the browser login flow. |
48
68
|`GET` / `PUT /api/subagent-models`| Read / set the featured subagent models. |
49
69
|`POST /api/stop`| Gracefully stop the proxy (and the background service if installed), restore native Codex, then exit. |
0 commit comments