oc-chatgpt-multi-auth 5.4.0 → 5.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +931 -928
  2. package/config/README.md +88 -86
  3. package/config/opencode-legacy.json +10 -10
  4. package/config/opencode-modern.json +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +63 -121
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/accounts.d.ts +20 -1
  9. package/dist/lib/accounts.d.ts.map +1 -1
  10. package/dist/lib/accounts.js +48 -3
  11. package/dist/lib/accounts.js.map +1 -1
  12. package/dist/lib/constants.d.ts +1 -0
  13. package/dist/lib/constants.d.ts.map +1 -1
  14. package/dist/lib/constants.js +1 -0
  15. package/dist/lib/constants.js.map +1 -1
  16. package/dist/lib/prompts/codex.d.ts +1 -1
  17. package/dist/lib/prompts/codex.d.ts.map +1 -1
  18. package/dist/lib/prompts/codex.js +8 -1
  19. package/dist/lib/prompts/codex.js.map +1 -1
  20. package/dist/lib/request/fetch-helpers.d.ts +2 -0
  21. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  22. package/dist/lib/request/fetch-helpers.js +7 -1
  23. package/dist/lib/request/fetch-helpers.js.map +1 -1
  24. package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
  25. package/dist/lib/request/helpers/model-map.js +18 -0
  26. package/dist/lib/request/helpers/model-map.js.map +1 -1
  27. package/dist/lib/request/request-transformer.d.ts.map +1 -1
  28. package/dist/lib/request/request-transformer.js +33 -16
  29. package/dist/lib/request/request-transformer.js.map +1 -1
  30. package/dist/lib/schemas.d.ts +3 -0
  31. package/dist/lib/schemas.d.ts.map +1 -1
  32. package/dist/lib/storage.d.ts.map +1 -1
  33. package/dist/lib/storage.js +23 -145
  34. package/dist/lib/storage.js.map +1 -1
  35. package/package.json +106 -106
package/README.md CHANGED
@@ -1,928 +1,931 @@
1
- # OpenAI Codex Auth Plugin for OpenCode
2
-
3
- [![npm version](https://img.shields.io/npm/v/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
4
- [![npm downloads](https://img.shields.io/npm/dw/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
5
-
6
- OAuth plugin for OpenCode that lets you use ChatGPT Plus/Pro rate limits with models like `gpt-5.2`, `gpt-5-codex`, and `gpt-5.1-codex-max` (plus optional entitlement-gated Spark IDs and legacy Codex aliases).
7
-
8
- > [!NOTE]
9
- > **Renamed from `opencode-openai-codex-auth-multi`** — If you were using the old package, update your config to use `oc-chatgpt-multi-auth` instead. The rename was necessary because OpenCode blocks plugins containing `opencode-openai-codex-auth` in the name.
10
-
11
- ## What You Get
12
-
13
- - **GPT-5.2, GPT-5 Codex, GPT-5.1 Codex Max** and all GPT-5.x variants via ChatGPT OAuth
14
- - **Multi-account support** — Add up to 20 ChatGPT accounts, health-aware rotation with automatic failover
15
- - **Per-project accounts** — Each project gets its own account storage (new in v4.10.0)
16
- - **Workspace-aware identity persistence** — Keeps workspace/org identity stable across token refresh and verify-flagged restore flows
17
- - **Click-to-switch** — Switch accounts directly from the OpenCode TUI
18
- - **Beginner command toolkit** — Guided onboarding with `codex-help`, `codex-setup`, `codex-doctor`, and `codex-next`
19
- - **Account metadata controls** — Per-account labels, tags, and notes with quick filtering
20
- - **Safer backup/import flow** — Timestamped exports, import dry-run preview, and conditional pre-import backups when existing accounts are present
21
- - **Startup preflight summary** — One-line health/readiness summary at plugin startup with suggested next step
22
- - **Strict tool validation** — Automatically cleans schemas for compatibility with strict models
23
- - **Auto-update notifications** — Get notified when a new version is available
24
- - **21 template model presets** — Full variant system with reasoning levels (none/low/medium/high/xhigh)
25
- - **Prompt caching** — Session-based caching for faster multi-turn conversations
26
- - **Usage-aware errors** — Friendly messages with rate limit reset timing
27
- - **Plugin compatible** — Works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
28
-
29
- ---
30
-
31
- <details open>
32
- <summary><b>Terms of Service Warning — Read Before Installing</b></summary>
33
-
34
- > [!CAUTION]
35
- > This plugin uses OpenAI's official OAuth authentication (the same method as OpenAI's official Codex CLI) for personal development use with your ChatGPT Plus/Pro subscription.
36
- >
37
- > **This plugin is for personal development only:**
38
- > - Not for commercial services, API resale, or multi-user applications
39
- > - For production use, see [OpenAI Platform API](https://platform.openai.com/)
40
- >
41
- > **By using this plugin, you acknowledge:**
42
- > - This is an unofficial tool not endorsed by OpenAI
43
- > - Users are responsible for compliance with [OpenAI's Terms of Use](https://openai.com/policies/terms-of-use/)
44
- > - You assume all risks associated with using this plugin
45
-
46
- </details>
47
-
48
- ---
49
-
50
- ## Installation
51
-
52
- <details open>
53
- <summary><b>For Humans</b></summary>
54
-
55
- **Option A: Let an LLM do it**
56
-
57
- Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
58
-
59
- ```
60
- Install the oc-chatgpt-multi-auth plugin and add the OpenAI model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/ndycode/oc-chatgpt-multi-auth/main/README.md
61
- ```
62
-
63
- **Option B: One-command install**
64
-
65
- ```bash
66
- npx -y oc-chatgpt-multi-auth@latest
67
- ```
68
-
69
- This writes the config to `~/.config/opencode/opencode.json`, backs up existing config, and clears the plugin cache.
70
-
71
- > Want legacy config (OpenCode v1.0.209 and below)? Add `--legacy` flag.
72
-
73
- **Option C: Manual setup**
74
-
75
- 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
76
-
77
- ```json
78
- {
79
- "plugin": ["oc-chatgpt-multi-auth@latest"]
80
- }
81
- ```
82
-
83
- 2. **Login** with your ChatGPT account:
84
-
85
- ```bash
86
- opencode auth login
87
- ```
88
-
89
- 3. **Add models** — Copy the [full configuration](#models) below
90
-
91
- 4. **Use it:**
92
-
93
- ```bash
94
- opencode run "Hello" --model=openai/gpt-5.2 --variant=medium
95
- ```
96
-
97
- </details>
98
-
99
- <details>
100
- <summary><b>For LLM Agents</b></summary>
101
-
102
- ### Step-by-Step Instructions
103
-
104
- 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
105
-
106
- > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
107
-
108
- 2. Add the plugin to the `plugin` array:
109
- ```json
110
- {
111
- "plugin": ["oc-chatgpt-multi-auth@latest"]
112
- }
113
- ```
114
-
115
- 3. Add the model definitions from the [Full Models Configuration](#full-models-configuration-copy-paste-ready) section
116
-
117
- 4. Set `provider` to `"openai"` and choose a model
118
-
119
- ### Verification
120
-
121
- ```bash
122
- opencode run "Hello" --model=openai/gpt-5.2 --variant=medium
123
- ```
124
-
125
- </details>
126
-
127
- ---
128
-
129
- ## Models
130
-
131
- ### Model Reference
132
-
133
- | Model | Variants | Notes |
134
- |-------|----------|-------|
135
- | `gpt-5.2` | none, low, medium, high, xhigh | Latest GPT-5.2 with reasoning levels |
136
- | `gpt-5-codex` | low, medium, high | Canonical Codex model for code generation (default: high) |
137
- | `gpt-5.3-codex-spark` | low, medium, high, xhigh | Spark IDs are supported by the plugin, but access is entitlement-gated by account/workspace |
138
- | `gpt-5.1-codex-max` | low, medium, high, xhigh | Maximum context Codex |
139
- | `gpt-5.1-codex` | low, medium, high | Standard Codex |
140
- | `gpt-5.1-codex-mini` | medium, high | Lightweight Codex |
141
- | `gpt-5.1` | none, low, medium, high | GPT-5.1 base model |
142
-
143
- Config templates intentionally omit Spark model IDs by default to reduce entitlement failures on unsupported accounts. Add Spark manually only if your workspace is entitled.
144
-
145
- **Using variants:**
146
- ```bash
147
- # Modern OpenCode (v1.0.210+)
148
- opencode run "Hello" --model=openai/gpt-5.2 --variant=high
149
-
150
- # Legacy OpenCode (v1.0.209 and below)
151
- opencode run "Hello" --model=openai/gpt-5.2-high
152
- ```
153
-
154
- <details>
155
- <summary><b>Full Models Configuration (Copy-Paste Ready)</b></summary>
156
-
157
- Add this to your `~/.config/opencode/opencode.json`:
158
-
159
- ```json
160
- {
161
- "$schema": "https://opencode.ai/config.json",
162
- "plugin": ["oc-chatgpt-multi-auth@latest"],
163
- "provider": {
164
- "openai": {
165
- "options": {
166
- "reasoningEffort": "medium",
167
- "reasoningSummary": "auto",
168
- "textVerbosity": "medium",
169
- "include": ["reasoning.encrypted_content"],
170
- "store": false
171
- },
172
- "models": {
173
- "gpt-5.2": {
174
- "name": "GPT 5.2 (OAuth)",
175
- "limit": { "context": 272000, "output": 128000 },
176
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
177
- "variants": {
178
- "none": { "reasoningEffort": "none" },
179
- "low": { "reasoningEffort": "low" },
180
- "medium": { "reasoningEffort": "medium" },
181
- "high": { "reasoningEffort": "high" },
182
- "xhigh": { "reasoningEffort": "xhigh" }
183
- }
184
- },
185
- "gpt-5-codex": {
186
- "name": "GPT 5 Codex (OAuth)",
187
- "limit": { "context": 272000, "output": 128000 },
188
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
189
- "variants": {
190
- "low": { "reasoningEffort": "low" },
191
- "medium": { "reasoningEffort": "medium" },
192
- "high": { "reasoningEffort": "high" }
193
- },
194
- "options": {
195
- "reasoningEffort": "high",
196
- "reasoningSummary": "detailed"
197
- }
198
- },
199
- "gpt-5.1-codex-max": {
200
- "name": "GPT 5.1 Codex Max (OAuth)",
201
- "limit": { "context": 272000, "output": 128000 },
202
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
203
- "variants": {
204
- "low": { "reasoningEffort": "low" },
205
- "medium": { "reasoningEffort": "medium" },
206
- "high": { "reasoningEffort": "high" },
207
- "xhigh": { "reasoningEffort": "xhigh" }
208
- }
209
- },
210
- "gpt-5.1-codex": {
211
- "name": "GPT 5.1 Codex (OAuth)",
212
- "limit": { "context": 272000, "output": 128000 },
213
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
214
- "variants": {
215
- "low": { "reasoningEffort": "low" },
216
- "medium": { "reasoningEffort": "medium" },
217
- "high": { "reasoningEffort": "high" }
218
- }
219
- },
220
- "gpt-5.1-codex-mini": {
221
- "name": "GPT 5.1 Codex Mini (OAuth)",
222
- "limit": { "context": 272000, "output": 128000 },
223
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
224
- "variants": {
225
- "medium": { "reasoningEffort": "medium" },
226
- "high": { "reasoningEffort": "high" }
227
- }
228
- },
229
- "gpt-5.1": {
230
- "name": "GPT 5.1 (OAuth)",
231
- "limit": { "context": 272000, "output": 128000 },
232
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
233
- "variants": {
234
- "none": { "reasoningEffort": "none" },
235
- "low": { "reasoningEffort": "low" },
236
- "medium": { "reasoningEffort": "medium" },
237
- "high": { "reasoningEffort": "high" }
238
- }
239
- }
240
- }
241
- }
242
- }
243
- }
244
- ```
245
-
246
- Optional Spark model block (manual add only when entitled):
247
- ```json
248
- "gpt-5.3-codex-spark": {
249
- "name": "GPT 5.3 Codex Spark (OAuth)",
250
- "limit": { "context": 272000, "output": 128000 },
251
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
252
- "variants": {
253
- "low": { "reasoningEffort": "low" },
254
- "medium": { "reasoningEffort": "medium" },
255
- "high": { "reasoningEffort": "high" },
256
- "xhigh": { "reasoningEffort": "xhigh" }
257
- }
258
- }
259
- ```
260
-
261
- For legacy OpenCode (v1.0.209 and below), use `config/opencode-legacy.json` which has individual model entries like `gpt-5.2-low`, `gpt-5.2-medium`, etc.
262
-
263
- </details>
264
-
265
- ---
266
-
267
- ## Multi-Account Setup
268
-
269
- Add multiple ChatGPT accounts for higher combined quotas. The plugin uses **health-aware rotation** with automatic failover and supports up to 20 accounts.
270
-
271
- ```bash
272
- opencode auth login # Run again to add more accounts
273
- ```
274
-
275
- ---
276
-
277
- ## Account Management Tools
278
-
279
- The plugin provides built-in tools for managing your OpenAI accounts. These are available directly in OpenCode — just ask the agent or type the tool name.
280
-
281
- > **Note:** Tools were renamed from `openai-accounts-*` to `codex-*` in v4.12.0 for brevity.
282
-
283
- ### codex-list
284
-
285
- List all configured accounts with status badges.
286
-
287
- ```text
288
- codex-list
289
- ```
290
-
291
- Filter by tag:
292
-
293
- ```text
294
- codex-list tag="work"
295
- ```
296
-
297
- Shows account labels, IDs, tags, active state, and rate-limit/cooldown markers.
298
-
299
- ---
300
-
301
- ### codex-switch
302
-
303
- Switch to a different account. If `index` is omitted and your terminal supports menus, an interactive picker opens.
304
-
305
- ```text
306
- codex-switch index=2
307
- ```
308
-
309
- or:
310
-
311
- ```text
312
- codex-switch
313
- ```
314
-
315
- ---
316
-
317
- ### codex-label
318
-
319
- Set or clear a display label for an account. Useful for workspace naming.
320
-
321
- ```text
322
- codex-label index=2 label="Work"
323
- ```
324
-
325
- Clear:
326
-
327
- ```text
328
- codex-label index=2 label=""
329
- ```
330
-
331
- If `index` is omitted in interactive terminals, a picker opens.
332
-
333
- ---
334
-
335
- ### codex-tag
336
-
337
- Set or clear comma-separated tags for filtering and grouping.
338
-
339
- ```text
340
- codex-tag index=2 tags="work,team-a"
341
- ```
342
-
343
- Clear:
344
-
345
- ```text
346
- codex-tag index=2 tags=""
347
- ```
348
-
349
- Use tags with `codex-list tag="work"`.
350
-
351
- ---
352
-
353
- ### codex-note
354
-
355
- Set or clear a short per-account note for reminders.
356
-
357
- ```text
358
- codex-note index=2 note="primary for weekday daytime usage"
359
- ```
360
-
361
- Clear:
362
-
363
- ```text
364
- codex-note index=2 note=""
365
- ```
366
-
367
- ---
368
-
369
- ### codex-help
370
-
371
- Show beginner-friendly command guidance. Optional topic filter:
372
-
373
- ```text
374
- codex-help
375
- codex-help topic="backup"
376
- ```
377
-
378
- Available topics: `setup`, `switch`, `health`, `backup`, `dashboard`, `metrics`.
379
-
380
- ---
381
-
382
- ### codex-setup
383
-
384
- Show readiness checklist for first-run onboarding and account health.
385
-
386
- ```text
387
- codex-setup
388
- ```
389
-
390
- Open guided wizard (menu-driven when terminal supports it, checklist fallback otherwise):
391
-
392
- ```text
393
- codex-setup wizard=true
394
- ```
395
-
396
- ---
397
-
398
- ### codex-doctor
399
-
400
- Run diagnostics with actionable findings.
401
-
402
- ```text
403
- codex-doctor
404
- codex-doctor deep=true
405
- ```
406
-
407
- Apply safe auto-fixes (`--fix` equivalent):
408
- - Refreshes tokens where possible
409
- - Persists refreshed credentials
410
- - Switches active account to the healthiest eligible account
411
-
412
- ```text
413
- codex-doctor fix=true
414
- ```
415
-
416
- ---
417
-
418
- ### codex-next
419
-
420
- Show the single most recommended next action based on current account/runtime state.
421
-
422
- ```text
423
- codex-next
424
- ```
425
-
426
- ---
427
-
428
- ### codex-status
429
-
430
- Show detailed status including rate limits and health scores.
431
-
432
- ```text
433
- codex-status
434
- ```
435
-
436
- ---
437
-
438
- ### codex-metrics
439
-
440
- Show live runtime metrics (request counts, latency, errors, retries, and safe mode).
441
-
442
- ```text
443
- codex-metrics
444
- ```
445
-
446
- ---
447
-
448
- ### codex-health
449
-
450
- Check if all account tokens are still valid (read-only check).
451
-
452
- ```text
453
- codex-health
454
- ```
455
-
456
- ---
457
-
458
- ### codex-refresh
459
-
460
- Refresh all OAuth tokens and save them to disk. Use this after long idle periods.
461
-
462
- ```text
463
- codex-refresh
464
- ```
465
-
466
- `codex-health` validates. `codex-refresh` validates + refreshes + persists.
467
-
468
- ---
469
-
470
- ### codex-remove
471
-
472
- Remove an account entry. If `index` is omitted and your terminal supports menus, an interactive picker opens.
473
-
474
- ```text
475
- codex-remove index=3
476
- ```
477
-
478
- or:
479
-
480
- ```text
481
- codex-remove
482
- ```
483
-
484
- ---
485
-
486
- ### codex-export
487
-
488
- Export accounts to JSON for backup/migration.
489
-
490
- Explicit path:
491
-
492
- ```text
493
- codex-export path="~/backup/accounts.json"
494
- ```
495
-
496
- Auto timestamped backup path (default behavior when `path` is omitted):
497
-
498
- ```text
499
- codex-export
500
- ```
501
-
502
- Generated paths are stored in a `backups/` subdirectory near the active account storage file.
503
-
504
- ---
505
-
506
- ### codex-import
507
-
508
- Import accounts from a JSON file (dedupe-aware merge).
509
-
510
- Dry-run preview (no writes):
511
-
512
- ```text
513
- codex-import path="~/backup/accounts.json" dryRun=true
514
- ```
515
-
516
- Apply import:
517
-
518
- ```text
519
- codex-import path="~/backup/accounts.json"
520
- ```
521
-
522
- Before apply, the plugin creates an automatic timestamped pre-import backup when existing accounts are present. If backup creation fails, import apply is aborted.
523
-
524
- ---
525
-
526
- ### codex-dashboard
527
-
528
- Show live account eligibility, retry budget usage, refresh queue metrics, and the recommended next step.
529
-
530
- ```text
531
- codex-dashboard
532
- ```
533
-
534
- ---
535
-
536
- ### Quick Reference
537
-
538
- | Tool | What It Does | Example |
539
- |------|--------------|---------|
540
- | `codex-help` | Command guide by topic | `codex-help topic="setup"` |
541
- | `codex-setup` | Readiness checklist/wizard | `codex-setup wizard=true` |
542
- | `codex-next` | Best next action | `codex-next` |
543
- | `codex-doctor` | Diagnostics and optional safe fixes | `codex-doctor fix=true` |
544
- | `codex-list` | List/filter accounts | `codex-list tag="work"` |
545
- | `codex-switch` | Switch active account | `codex-switch index=2` |
546
- | `codex-label` | Set/clear display label | `codex-label index=2 label="Work"` |
547
- | `codex-tag` | Set/clear tag list | `codex-tag index=2 tags="work,team-a"` |
548
- | `codex-note` | Set/clear account note | `codex-note index=2 note="night backup"` |
549
- | `codex-status` | Per-account health/rate limit detail | `codex-status` |
550
- | `codex-dashboard` | Live selection and retry view | `codex-dashboard` |
551
- | `codex-metrics` | Runtime metrics summary | `codex-metrics` |
552
- | `codex-health` | Validate token health (read-only) | `codex-health` |
553
- | `codex-refresh` | Refresh and persist tokens | `codex-refresh` |
554
- | `codex-remove` | Remove account entry | `codex-remove index=3` |
555
- | `codex-export` | Export account backups | `codex-export` |
556
- | `codex-import` | Dry-run or apply imports | `codex-import path="~/backup/accounts.json" dryRun=true` |
557
-
558
- ---
559
-
560
- ### Sample Output (codex-list)
561
-
562
- ```text
563
- Codex Accounts (3):
564
-
565
- [1] Account 1 (user@gmail.com, workspace:Work, tags:work,team-a) active
566
- [2] Account 2 (backup@email.com, tags:backup) ok
567
- [3] Account 3 (personal@email.com) rate-limited
568
-
569
- Storage: ~/.opencode/openai-codex-accounts.json
570
- ```
571
-
572
- ## Rotation Behavior
573
-
574
- **How rotation works:**
575
- - Health scoring tracks success/failure per account
576
- - Token bucket prevents hitting rate limits
577
- - Hybrid selection prefers healthy accounts with available tokens
578
- - Always retries when all accounts are rate-limited (waits for reset with live countdown)
579
- - 20% jitter on retry delays to avoid thundering herd
580
- - Auto-removes accounts after 3 consecutive auth failures (new in v4.11.0)
581
-
582
- **Per-project accounts (v4.10.0+):**
583
-
584
- By default, each project gets its own account storage namespace. This means you can keep different active accounts per project without writing account files into your repo. Works from subdirectories too; the plugin walks up to find the project root (v4.11.0). Disable with `perProjectAccounts: false` in your config.
585
-
586
- **Storage locations:**
587
- - Per-project: `~/.opencode/projects/{project-key}/openai-codex-accounts.json`
588
- - Global (when per-project disabled): `~/.opencode/openai-codex-accounts.json`
589
-
590
- ---
591
-
592
- ## Troubleshooting
593
-
594
- > **Quick reset**: Most issues can be resolved by deleting `~/.opencode/auth/openai.json` and running `opencode auth login` again.
595
-
596
- ### Configuration Paths (All Platforms)
597
-
598
- OpenCode uses `~/.config/opencode/` on **all platforms** including Windows.
599
-
600
- | File | Path |
601
- |------|------|
602
- | Main config | `~/.config/opencode/opencode.json` |
603
- | Auth tokens | `~/.opencode/auth/openai.json` |
604
- | Multi-account (global) | `~/.opencode/openai-codex-accounts.json` |
605
- | Multi-account (per-project) | `~/.opencode/projects/{project-key}/openai-codex-accounts.json` |
606
- | Flagged accounts | `~/.opencode/openai-codex-flagged-accounts.json` |
607
- | Plugin config | `~/.opencode/openai-codex-auth-config.json` |
608
- | Debug logs | `~/.opencode/logs/codex-plugin/` |
609
-
610
- > **Windows users**: `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
611
-
612
- ---
613
-
614
- <details>
615
- <summary><b>401 Unauthorized Error</b></summary>
616
-
617
- **Cause:** Token expired or not authenticated.
618
-
619
- **Solutions:**
620
- 1. Re-authenticate:
621
- ```bash
622
- opencode auth login
623
- ```
624
- 2. Check auth file exists:
625
- ```bash
626
- cat ~/.opencode/auth/openai.json
627
- ```
628
-
629
- </details>
630
-
631
- <details>
632
- <summary><b>Browser Doesn't Open for OAuth</b></summary>
633
-
634
- **Cause:** Port 1455 conflict or SSH/WSL environment.
635
-
636
- **Solutions:**
637
- 1. **Manual URL paste:**
638
- - Re-run `opencode auth login`
639
- - Select **"ChatGPT Plus/Pro (manual URL paste)"**
640
- - Paste the full redirect URL (including `#code=...`) after login
641
-
642
- 2. **Check port availability:**
643
- ```bash
644
- # macOS/Linux
645
- lsof -i :1455
646
-
647
- # Windows
648
- netstat -ano | findstr :1455
649
- ```
650
-
651
- 3. **Stop Codex CLI if running** — Both use port 1455
652
-
653
- </details>
654
-
655
- <details>
656
- <summary><b>Model Not Found</b></summary>
657
-
658
- **Cause:** Missing provider prefix or config mismatch.
659
-
660
- **Solutions:**
661
- 1. Use `openai/` prefix:
662
- ```bash
663
- # Correct
664
- --model=openai/gpt-5.2
665
-
666
- # Wrong
667
- --model=gpt-5.2
668
- ```
669
-
670
- 2. Verify model is in your config:
671
- ```json
672
- { "models": { "gpt-5.2": { ... } } }
673
- ```
674
-
675
- </details>
676
-
677
- <details>
678
- <summary><b>Unsupported Codex Model for ChatGPT Account</b></summary>
679
-
680
- **Error example:** `Bad Request: {"detail":"The 'gpt-5.3-codex-spark' model is not supported when using Codex with a ChatGPT account."}`
681
-
682
- **Cause:** Active workspace/account is not entitled for the requested Codex model.
683
-
684
- **Solutions:**
685
- 1. Re-auth to refresh workspace selection (most common Spark fix):
686
- ```bash
687
- opencode auth login
688
- ```
689
- 2. Add another entitled account/workspace. The plugin will try remaining accounts/workspaces before model fallback.
690
- 3. Enable automatic fallback only if you want degraded-model retries when Spark is not entitled:
691
- ```bash
692
- CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback opencode
693
- ```
694
- 4. Use custom fallback chain in `~/.opencode/openai-codex-auth-config.json`:
695
- ```json
696
- {
697
- "unsupportedCodexPolicy": "fallback",
698
- "fallbackOnUnsupportedCodexModel": true,
699
- "unsupportedCodexFallbackChain": {
700
- "gpt-5-codex": ["gpt-5.2-codex"],
701
- "gpt-5.3-codex": ["gpt-5-codex", "gpt-5.2-codex"],
702
- "gpt-5.3-codex-spark": ["gpt-5-codex", "gpt-5.3-codex", "gpt-5.2-codex"]
703
- }
704
- }
705
- ```
706
- 5. Verify effective upstream model when needed:
707
- ```bash
708
- ENABLE_PLUGIN_REQUEST_LOGGING=1 CODEX_PLUGIN_LOG_BODIES=1 opencode run "ping" --model=openai/gpt-5.3-codex-spark
709
- ```
710
- The UI can keep showing your selected model while fallback is applied internally.
711
-
712
- </details>
713
-
714
- <details>
715
- <summary><b>Rate Limit Exceeded</b></summary>
716
-
717
- **Cause:** ChatGPT subscription usage limit reached.
718
-
719
- **Solutions:**
720
- 1. Wait for reset (plugin shows timing in error message)
721
- 2. Add more accounts: `opencode auth login`
722
- 3. Switch to a different model family
723
-
724
- </details>
725
-
726
- <details>
727
- <summary><b>Multi-Turn Context Lost</b></summary>
728
-
729
- **Cause:** Old plugin version or missing config.
730
-
731
- **Solutions:**
732
- 1. Update plugin:
733
- ```bash
734
- npx -y oc-chatgpt-multi-auth@latest
735
- ```
736
- 2. Ensure config has:
737
- ```json
738
- {
739
- "include": ["reasoning.encrypted_content"],
740
- "store": false
741
- }
742
- ```
743
-
744
- </details>
745
-
746
- <details>
747
- <summary><b>OAuth Callback Issues (Safari/WSL/Docker)</b></summary>
748
-
749
- **Safari HTTPS-only mode:**
750
- - Use Chrome or Firefox instead, or
751
- - Temporarily disable Safari > Settings > Privacy > "Enable HTTPS-only mode"
752
-
753
- **WSL2:**
754
- - Use VS Code's port forwarding, or
755
- - Configure Windows → WSL port forwarding
756
-
757
- **SSH / Remote:**
758
- ```bash
759
- ssh -L 1455:localhost:1455 user@remote
760
- ```
761
-
762
- **Docker / Containers:**
763
- - OAuth with localhost redirect doesn't work in containers
764
- - Use SSH port forwarding or manual URL flow
765
-
766
- </details>
767
-
768
- ---
769
-
770
- ## Plugin Compatibility
771
-
772
- ### oh-my-opencode
773
-
774
- Works alongside oh-my-opencode. No special configuration needed.
775
-
776
- ```json
777
- {
778
- "plugin": [
779
- "oc-chatgpt-multi-auth@latest",
780
- "oh-my-opencode@latest"
781
- ]
782
- }
783
- ```
784
-
785
- ### @tarquinen/opencode-dcp
786
-
787
- List this plugin before dcp:
788
-
789
- ```json
790
- {
791
- "plugin": [
792
- "oc-chatgpt-multi-auth@latest",
793
- "@tarquinen/opencode-dcp@latest"
794
- ]
795
- }
796
- ```
797
-
798
- ### Plugins You Don't Need
799
-
800
- - **openai-codex-auth** Not needed. This plugin replaces the original.
801
-
802
- ---
803
-
804
- ## Configuration
805
-
806
- Create `~/.opencode/openai-codex-auth-config.json` for optional settings:
807
-
808
- ### Model Behavior
809
-
810
- | Option | Default | What It Does |
811
- |--------|---------|--------------|
812
- | `requestTransformMode` | `native` | Request shaping mode: `native` keeps OpenCode payloads unchanged; `legacy` enables Codex compatibility rewrites |
813
- | `codexMode` | `true` | Legacy-only bridge prompt behavior (applies when `requestTransformMode=legacy`) |
814
- | `codexTuiV2` | `true` | Enables Codex-style terminal UI output (set `false` for legacy output) |
815
- | `codexTuiColorProfile` | `truecolor` | Terminal color profile for Codex UI (`truecolor`, `ansi256`, `ansi16`) |
816
- | `codexTuiGlyphMode` | `ascii` | Glyph mode for Codex UI (`ascii`, `unicode`, `auto`) |
817
- | `fastSession` | `false` | Forces low-latency settings per request (`reasoningEffort=none/low`, `reasoningSummary=auto`, `textVerbosity=low`) |
818
- | `fastSessionStrategy` | `hybrid` | `hybrid` speeds simple turns but keeps full-depth on complex prompts; `always` forces fast tuning on every turn |
819
- | `fastSessionMaxInputItems` | `30` | Max input items kept when fast tuning is applied |
820
-
821
- ### Account Settings (v4.10.0+)
822
-
823
- | Option | Default | What It Does |
824
- |--------|---------|--------------|
825
- | `perProjectAccounts` | `true` | Each project gets its own account storage namespace under `~/.opencode/projects/` |
826
- | `toastDurationMs` | `5000` | How long toast notifications stay visible (ms) |
827
- | `beginnerSafeMode` | `false` | Beginner-safe retry profile: conservative retry budget, disables all-accounts wait/retry, and caps all-accounts retries |
828
-
829
- ### Retry Behavior
830
-
831
- | Option | Default | What It Does |
832
- |--------|---------|--------------|
833
- | `retryProfile` | `balanced` | Global retry budget profile (`conservative`, `balanced`, `aggressive`) |
834
- | `retryBudgetOverrides` | `{}` | Per-class retry budget overrides (`authRefresh`, `network`, `server`, `rateLimitShort`, `rateLimitGlobal`, `emptyResponse`) |
835
- | `retryAllAccountsRateLimited` | `true` | Wait and retry when all accounts are rate-limited |
836
- | `retryAllAccountsMaxWaitMs` | `0` | Max wait time (0 = unlimited) |
837
- | `retryAllAccountsMaxRetries` | `Infinity` | Max retry attempts |
838
- | `unsupportedCodexPolicy` | `strict` | Unsupported-model behavior: `strict` (return entitlement error) or `fallback` (retry next model in fallback chain) |
839
- | `fallbackOnUnsupportedCodexModel` | `false` | Legacy fallback toggle mapped to `unsupportedCodexPolicy` (prefer using `unsupportedCodexPolicy`) |
840
- | `fallbackToGpt52OnUnsupportedGpt53` | `true` | Legacy compatibility toggle for the `gpt-5.3-codex -> gpt-5.2-codex` edge when generic fallback is enabled |
841
- | `unsupportedCodexFallbackChain` | `{}` | Optional per-model fallback-chain override (map of `model -> [fallback1, fallback2, ...]`) |
842
- | `fetchTimeoutMs` | `60000` | Request timeout to Codex backend (ms) |
843
- | `streamStallTimeoutMs` | `45000` | Abort non-stream parsing if SSE stalls (ms) |
844
-
845
- Default unsupported-model fallback chain (used when `unsupportedCodexPolicy` is `fallback`):
846
- - `gpt-5.3-codex -> gpt-5-codex -> gpt-5.2-codex`
847
- - `gpt-5.3-codex-spark -> gpt-5-codex -> gpt-5.3-codex -> gpt-5.2-codex` (applies if you manually select Spark model IDs)
848
- - `gpt-5.2-codex -> gpt-5-codex`
849
- - `gpt-5.1-codex -> gpt-5-codex`
850
-
851
- When `beginnerSafeMode` is enabled, runtime behavior is intentionally conservative:
852
- - Retry profile is forced to `conservative`
853
- - `retryAllAccountsRateLimited` is forced `false`
854
- - `retryAllAccountsMaxRetries` is capped to `1`
855
-
856
- ### Environment Variables
857
-
858
- ```bash
859
- DEBUG_CODEX_PLUGIN=1 opencode # Enable debug logging
860
- ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode # Log request metadata
861
- CODEX_PLUGIN_LOG_BODIES=1 opencode # Include raw request/response payloads in request logs (sensitive)
862
- CODEX_PLUGIN_LOG_LEVEL=debug opencode # Set log level (debug|info|warn|error)
863
- CODEX_AUTH_REQUEST_TRANSFORM_MODE=legacy opencode # Re-enable legacy Codex request rewrites
864
- CODEX_MODE=0 opencode # Temporarily disable bridge prompt
865
- CODEX_TUI_V2=0 opencode # Disable Codex-style UI (legacy output)
866
- CODEX_TUI_COLOR_PROFILE=ansi16 opencode # Force UI color profile
867
- CODEX_TUI_GLYPHS=unicode opencode # Override glyph mode (ascii|unicode|auto)
868
- CODEX_AUTH_PREWARM=0 opencode # Disable startup prewarm (prompt/instruction cache warmup)
869
- CODEX_AUTH_FAST_SESSION=1 opencode # Enable faster response defaults
870
- CODEX_AUTH_FAST_SESSION_STRATEGY=always opencode # Force fast mode for all prompts
871
- CODEX_AUTH_FAST_SESSION_MAX_INPUT_ITEMS=24 opencode # Tune fast-mode history window
872
- CODEX_AUTH_BEGINNER_SAFE_MODE=1 opencode # Enable beginner-safe runtime profile
873
- CODEX_AUTH_RETRY_PROFILE=aggressive opencode # Override retry profile (ignored when beginner safe mode is on)
874
- CODEX_AUTH_RETRY_ALL_RATE_LIMITED=0 opencode # Disable all-accounts wait-and-retry
875
- CODEX_AUTH_RETRY_ALL_MAX_WAIT_MS=30000 opencode # Cap all-accounts wait duration
876
- CODEX_AUTH_RETRY_ALL_MAX_RETRIES=1 opencode # Cap all-accounts retry attempts
877
- CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback opencode # Enable generic unsupported-model fallback
878
- CODEX_AUTH_FALLBACK_UNSUPPORTED_MODEL=1 opencode # Legacy fallback toggle (prefer policy var above)
879
- CODEX_AUTH_FALLBACK_GPT53_TO_GPT52=0 opencode # Disable only the legacy gpt-5.3 -> gpt-5.2 edge
880
- CODEX_AUTH_FETCH_TIMEOUT_MS=120000 opencode # Override request timeout
881
- CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=60000 opencode # Override SSE stall timeout
882
- ```
883
-
884
- For all options, see [docs/configuration.md](docs/configuration.md).
885
-
886
- ---
887
-
888
- ## Documentation
889
-
890
- - [Getting Started](docs/getting-started.md) — Complete installation guide
891
- - [Configuration](docs/configuration.md) — All configuration options
892
- - [Troubleshooting](docs/troubleshooting.md) — Common issues and fixes
893
- - [Architecture](docs/development/ARCHITECTURE.md) — How the plugin works
894
-
895
- ---
896
-
897
- ## Credits
898
-
899
- - [numman-ali/opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth) by [numman-ali](https://github.com/numman-ali) — Original plugin
900
- - [ndycode](https://github.com/ndycode) — Multi-account support and maintenance
901
-
902
- ## License
903
-
904
- MIT License. See [LICENSE](LICENSE) for details.
905
-
906
- <details>
907
- <summary><b>Legal</b></summary>
908
-
909
- ### Intended Use
910
-
911
- - Personal / internal development only
912
- - Respect subscription quotas and data handling policies
913
- - Not for production services or bypassing intended limits
914
-
915
- ### Warning
916
-
917
- By using this plugin, you acknowledge:
918
-
919
- - **Terms of Service risk** — This approach may violate ToS of AI model providers
920
- - **No guarantees** APIs may change without notice
921
- - **Assumption of risk** — You assume all legal, financial, and technical risks
922
-
923
- ### Disclaimer
924
-
925
- - Not affiliated with OpenAI. This is an independent open-source project.
926
- - "ChatGPT", "GPT-5", "Codex", and "OpenAI" are trademarks of OpenAI, L.L.C.
927
-
928
- </details>
1
+ # OpenAI Codex Auth Plugin for OpenCode
2
+
3
+ [![npm version](https://img.shields.io/npm/v/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
4
+ [![npm downloads](https://img.shields.io/npm/dw/oc-chatgpt-multi-auth.svg)](https://www.npmjs.com/package/oc-chatgpt-multi-auth)
5
+
6
+ OAuth plugin for OpenCode that lets you use ChatGPT Plus/Pro rate limits with models like `gpt-5.4`, `gpt-5-codex`, and `gpt-5.1-codex-max` (plus optional/manual `gpt-5.4-pro`, entitlement-gated Spark IDs, and legacy Codex aliases).
7
+
8
+ > [!NOTE]
9
+ > **Renamed from `opencode-openai-codex-auth-multi`** — If you were using the old package, update your config to use `oc-chatgpt-multi-auth` instead. The rename was necessary because OpenCode blocks plugins containing `opencode-openai-codex-auth` in the name.
10
+
11
+ ## What You Get
12
+
13
+ - **GPT-5.4, GPT-5 Codex, GPT-5.1 Codex Max** and all GPT-5.x variants via ChatGPT OAuth
14
+ - **Multi-account support** — Add up to 20 ChatGPT accounts, health-aware rotation with automatic failover
15
+ - **Per-project accounts** — Each project gets its own account storage (new in v4.10.0)
16
+ - **Workspace-aware identity persistence** — Keeps workspace/org identity stable across token refresh and verify-flagged restore flows
17
+ - **Click-to-switch** — Switch accounts directly from the OpenCode TUI
18
+ - **Beginner command toolkit** — Guided onboarding with `codex-help`, `codex-setup`, `codex-doctor`, and `codex-next`
19
+ - **Account metadata controls** — Per-account labels, tags, and notes with quick filtering
20
+ - **Safer backup/import flow** — Timestamped exports, import dry-run preview, and conditional pre-import backups when existing accounts are present
21
+ - **Startup preflight summary** — One-line health/readiness summary at plugin startup with suggested next step
22
+ - **Strict tool validation** — Automatically cleans schemas for compatibility with strict models
23
+ - **Auto-update notifications** — Get notified when a new version is available
24
+ - **21 template model presets** — Full variant system with reasoning levels (none/low/medium/high/xhigh)
25
+ - **Prompt caching** — Session-based caching for faster multi-turn conversations
26
+ - **Usage-aware errors** — Friendly messages with rate limit reset timing
27
+ - **Plugin compatible** — Works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
28
+
29
+ ---
30
+
31
+ <details open>
32
+ <summary><b>Terms of Service Warning — Read Before Installing</b></summary>
33
+
34
+ > [!CAUTION]
35
+ > This plugin uses OpenAI's official OAuth authentication (the same method as OpenAI's official Codex CLI) for personal development use with your ChatGPT Plus/Pro subscription.
36
+ >
37
+ > **This plugin is for personal development only:**
38
+ > - Not for commercial services, API resale, or multi-user applications
39
+ > - For production use, see [OpenAI Platform API](https://platform.openai.com/)
40
+ >
41
+ > **By using this plugin, you acknowledge:**
42
+ > - This is an unofficial tool not endorsed by OpenAI
43
+ > - Users are responsible for compliance with [OpenAI's Terms of Use](https://openai.com/policies/terms-of-use/)
44
+ > - You assume all risks associated with using this plugin
45
+
46
+ </details>
47
+
48
+ ---
49
+
50
+ ## Installation
51
+
52
+ <details open>
53
+ <summary><b>For Humans</b></summary>
54
+
55
+ **Option A: Let an LLM do it**
56
+
57
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
58
+
59
+ ```
60
+ Install the oc-chatgpt-multi-auth plugin and add the OpenAI model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/ndycode/oc-chatgpt-multi-auth/main/README.md
61
+ ```
62
+
63
+ **Option B: One-command install**
64
+
65
+ ```bash
66
+ npx -y oc-chatgpt-multi-auth@latest
67
+ ```
68
+
69
+ This writes the config to `~/.config/opencode/opencode.json`, backs up existing config, and clears the plugin cache.
70
+
71
+ > Want legacy config (OpenCode v1.0.209 and below)? Add `--legacy` flag.
72
+
73
+ **Option C: Manual setup**
74
+
75
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
76
+
77
+ ```json
78
+ {
79
+ "plugin": ["oc-chatgpt-multi-auth@latest"]
80
+ }
81
+ ```
82
+
83
+ 2. **Login** with your ChatGPT account:
84
+
85
+ ```bash
86
+ opencode auth login
87
+ ```
88
+
89
+ 3. **Add models** — Copy the [full configuration](#models) below
90
+
91
+ 4. **Use it:**
92
+
93
+ ```bash
94
+ opencode run "Hello" --model=openai/gpt-5.4 --variant=medium
95
+ ```
96
+
97
+ </details>
98
+
99
+ <details>
100
+ <summary><b>For LLM Agents</b></summary>
101
+
102
+ ### Step-by-Step Instructions
103
+
104
+ 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
105
+
106
+ > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
107
+
108
+ 2. Add the plugin to the `plugin` array:
109
+ ```json
110
+ {
111
+ "plugin": ["oc-chatgpt-multi-auth@latest"]
112
+ }
113
+ ```
114
+
115
+ 3. Add the model definitions from the [Full Models Configuration](#full-models-configuration-copy-paste-ready) section
116
+
117
+ 4. Set `provider` to `"openai"` and choose a model
118
+
119
+ ### Verification
120
+
121
+ ```bash
122
+ opencode run "Hello" --model=openai/gpt-5.4 --variant=medium
123
+ ```
124
+
125
+ </details>
126
+
127
+ ---
128
+
129
+ ## Models
130
+
131
+ ### Model Reference
132
+
133
+ | Model | Variants | Notes |
134
+ |-------|----------|-------|
135
+ | `gpt-5.4` | none, low, medium, high, xhigh | Latest GPT-5.4 with reasoning levels |
136
+ | `gpt-5.4-pro` | low, medium, high, xhigh | Optional manual model for deeper reasoning; fallback default is `gpt-5.4-pro -> gpt-5.4` |
137
+ | `gpt-5-codex` | low, medium, high | Canonical Codex model for code generation (default: high) |
138
+ | `gpt-5.3-codex-spark` | low, medium, high, xhigh | Spark IDs are supported by the plugin, but access is entitlement-gated by account/workspace |
139
+ | `gpt-5.1-codex-max` | low, medium, high, xhigh | Maximum context Codex |
140
+ | `gpt-5.1-codex` | low, medium, high | Standard Codex |
141
+ | `gpt-5.1-codex-mini` | medium, high | Lightweight Codex |
142
+ | `gpt-5.1` | none, low, medium, high | GPT-5.1 base model |
143
+
144
+ Config templates intentionally omit Spark model IDs by default to reduce entitlement failures on unsupported accounts. Add Spark manually only if your workspace is entitled.
145
+
146
+ **Using variants:**
147
+ ```bash
148
+ # Modern OpenCode (v1.0.210+)
149
+ opencode run "Hello" --model=openai/gpt-5.4 --variant=high
150
+
151
+ # Legacy OpenCode (v1.0.209 and below)
152
+ opencode run "Hello" --model=openai/gpt-5.4-high
153
+ ```
154
+
155
+ <details>
156
+ <summary><b>Full Models Configuration (Copy-Paste Ready)</b></summary>
157
+
158
+ Add this to your `~/.config/opencode/opencode.json`:
159
+
160
+ ```json
161
+ {
162
+ "$schema": "https://opencode.ai/config.json",
163
+ "plugin": ["oc-chatgpt-multi-auth@latest"],
164
+ "provider": {
165
+ "openai": {
166
+ "options": {
167
+ "reasoningEffort": "medium",
168
+ "reasoningSummary": "auto",
169
+ "textVerbosity": "medium",
170
+ "include": ["reasoning.encrypted_content"],
171
+ "store": false
172
+ },
173
+ "models": {
174
+ "gpt-5.4": {
175
+ "name": "GPT 5.4 (OAuth)",
176
+ "limit": { "context": 272000, "output": 128000 },
177
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
178
+ "variants": {
179
+ "none": { "reasoningEffort": "none" },
180
+ "low": { "reasoningEffort": "low" },
181
+ "medium": { "reasoningEffort": "medium" },
182
+ "high": { "reasoningEffort": "high" },
183
+ "xhigh": { "reasoningEffort": "xhigh" }
184
+ }
185
+ },
186
+ "gpt-5-codex": {
187
+ "name": "GPT 5 Codex (OAuth)",
188
+ "limit": { "context": 272000, "output": 128000 },
189
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
190
+ "variants": {
191
+ "low": { "reasoningEffort": "low" },
192
+ "medium": { "reasoningEffort": "medium" },
193
+ "high": { "reasoningEffort": "high" }
194
+ },
195
+ "options": {
196
+ "reasoningEffort": "high",
197
+ "reasoningSummary": "detailed"
198
+ }
199
+ },
200
+ "gpt-5.1-codex-max": {
201
+ "name": "GPT 5.1 Codex Max (OAuth)",
202
+ "limit": { "context": 272000, "output": 128000 },
203
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
204
+ "variants": {
205
+ "low": { "reasoningEffort": "low" },
206
+ "medium": { "reasoningEffort": "medium" },
207
+ "high": { "reasoningEffort": "high" },
208
+ "xhigh": { "reasoningEffort": "xhigh" }
209
+ }
210
+ },
211
+ "gpt-5.1-codex": {
212
+ "name": "GPT 5.1 Codex (OAuth)",
213
+ "limit": { "context": 272000, "output": 128000 },
214
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
215
+ "variants": {
216
+ "low": { "reasoningEffort": "low" },
217
+ "medium": { "reasoningEffort": "medium" },
218
+ "high": { "reasoningEffort": "high" }
219
+ }
220
+ },
221
+ "gpt-5.1-codex-mini": {
222
+ "name": "GPT 5.1 Codex Mini (OAuth)",
223
+ "limit": { "context": 272000, "output": 128000 },
224
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
225
+ "variants": {
226
+ "medium": { "reasoningEffort": "medium" },
227
+ "high": { "reasoningEffort": "high" }
228
+ }
229
+ },
230
+ "gpt-5.1": {
231
+ "name": "GPT 5.1 (OAuth)",
232
+ "limit": { "context": 272000, "output": 128000 },
233
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
234
+ "variants": {
235
+ "none": { "reasoningEffort": "none" },
236
+ "low": { "reasoningEffort": "low" },
237
+ "medium": { "reasoningEffort": "medium" },
238
+ "high": { "reasoningEffort": "high" }
239
+ }
240
+ }
241
+ }
242
+ }
243
+ }
244
+ }
245
+ ```
246
+
247
+ Optional Spark model block (manual add only when entitled):
248
+ ```json
249
+ "gpt-5.3-codex-spark": {
250
+ "name": "GPT 5.3 Codex Spark (OAuth)",
251
+ "limit": { "context": 272000, "output": 128000 },
252
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
253
+ "variants": {
254
+ "low": { "reasoningEffort": "low" },
255
+ "medium": { "reasoningEffort": "medium" },
256
+ "high": { "reasoningEffort": "high" },
257
+ "xhigh": { "reasoningEffort": "xhigh" }
258
+ }
259
+ }
260
+ ```
261
+
262
+ For legacy OpenCode (v1.0.209 and below), use `config/opencode-legacy.json` which has individual model entries like `gpt-5.4-low`, `gpt-5.4-medium`, etc.
263
+
264
+ </details>
265
+
266
+ ---
267
+
268
+ ## Multi-Account Setup
269
+
270
+ Add multiple ChatGPT accounts for higher combined quotas. The plugin uses **health-aware rotation** with automatic failover and supports up to 20 accounts.
271
+
272
+ ```bash
273
+ opencode auth login # Run again to add more accounts
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Account Management Tools
279
+
280
+ The plugin provides built-in tools for managing your OpenAI accounts. These are available directly in OpenCode — just ask the agent or type the tool name.
281
+
282
+ > **Note:** Tools were renamed from `openai-accounts-*` to `codex-*` in v4.12.0 for brevity.
283
+
284
+ ### codex-list
285
+
286
+ List all configured accounts with status badges.
287
+
288
+ ```text
289
+ codex-list
290
+ ```
291
+
292
+ Filter by tag:
293
+
294
+ ```text
295
+ codex-list tag="work"
296
+ ```
297
+
298
+ Shows account labels, IDs, tags, active state, and rate-limit/cooldown markers.
299
+
300
+ ---
301
+
302
+ ### codex-switch
303
+
304
+ Switch to a different account. If `index` is omitted and your terminal supports menus, an interactive picker opens.
305
+
306
+ ```text
307
+ codex-switch index=2
308
+ ```
309
+
310
+ or:
311
+
312
+ ```text
313
+ codex-switch
314
+ ```
315
+
316
+ ---
317
+
318
+ ### codex-label
319
+
320
+ Set or clear a display label for an account. Useful for workspace naming.
321
+
322
+ ```text
323
+ codex-label index=2 label="Work"
324
+ ```
325
+
326
+ Clear:
327
+
328
+ ```text
329
+ codex-label index=2 label=""
330
+ ```
331
+
332
+ If `index` is omitted in interactive terminals, a picker opens.
333
+
334
+ ---
335
+
336
+ ### codex-tag
337
+
338
+ Set or clear comma-separated tags for filtering and grouping.
339
+
340
+ ```text
341
+ codex-tag index=2 tags="work,team-a"
342
+ ```
343
+
344
+ Clear:
345
+
346
+ ```text
347
+ codex-tag index=2 tags=""
348
+ ```
349
+
350
+ Use tags with `codex-list tag="work"`.
351
+
352
+ ---
353
+
354
+ ### codex-note
355
+
356
+ Set or clear a short per-account note for reminders.
357
+
358
+ ```text
359
+ codex-note index=2 note="primary for weekday daytime usage"
360
+ ```
361
+
362
+ Clear:
363
+
364
+ ```text
365
+ codex-note index=2 note=""
366
+ ```
367
+
368
+ ---
369
+
370
+ ### codex-help
371
+
372
+ Show beginner-friendly command guidance. Optional topic filter:
373
+
374
+ ```text
375
+ codex-help
376
+ codex-help topic="backup"
377
+ ```
378
+
379
+ Available topics: `setup`, `switch`, `health`, `backup`, `dashboard`, `metrics`.
380
+
381
+ ---
382
+
383
+ ### codex-setup
384
+
385
+ Show readiness checklist for first-run onboarding and account health.
386
+
387
+ ```text
388
+ codex-setup
389
+ ```
390
+
391
+ Open guided wizard (menu-driven when terminal supports it, checklist fallback otherwise):
392
+
393
+ ```text
394
+ codex-setup wizard=true
395
+ ```
396
+
397
+ ---
398
+
399
+ ### codex-doctor
400
+
401
+ Run diagnostics with actionable findings.
402
+
403
+ ```text
404
+ codex-doctor
405
+ codex-doctor deep=true
406
+ ```
407
+
408
+ Apply safe auto-fixes (`--fix` equivalent):
409
+ - Refreshes tokens where possible
410
+ - Persists refreshed credentials
411
+ - Switches active account to the healthiest eligible account
412
+
413
+ ```text
414
+ codex-doctor fix=true
415
+ ```
416
+
417
+ ---
418
+
419
+ ### codex-next
420
+
421
+ Show the single most recommended next action based on current account/runtime state.
422
+
423
+ ```text
424
+ codex-next
425
+ ```
426
+
427
+ ---
428
+
429
+ ### codex-status
430
+
431
+ Show detailed status including rate limits and health scores.
432
+
433
+ ```text
434
+ codex-status
435
+ ```
436
+
437
+ ---
438
+
439
+ ### codex-metrics
440
+
441
+ Show live runtime metrics (request counts, latency, errors, retries, and safe mode).
442
+
443
+ ```text
444
+ codex-metrics
445
+ ```
446
+
447
+ ---
448
+
449
+ ### codex-health
450
+
451
+ Check if all account tokens are still valid (read-only check).
452
+
453
+ ```text
454
+ codex-health
455
+ ```
456
+
457
+ ---
458
+
459
+ ### codex-refresh
460
+
461
+ Refresh all OAuth tokens and save them to disk. Use this after long idle periods.
462
+
463
+ ```text
464
+ codex-refresh
465
+ ```
466
+
467
+ `codex-health` validates. `codex-refresh` validates + refreshes + persists.
468
+
469
+ ---
470
+
471
+ ### codex-remove
472
+
473
+ Remove an account entry. If `index` is omitted and your terminal supports menus, an interactive picker opens.
474
+
475
+ ```text
476
+ codex-remove index=3
477
+ ```
478
+
479
+ or:
480
+
481
+ ```text
482
+ codex-remove
483
+ ```
484
+
485
+ ---
486
+
487
+ ### codex-export
488
+
489
+ Export accounts to JSON for backup/migration.
490
+
491
+ Explicit path:
492
+
493
+ ```text
494
+ codex-export path="~/backup/accounts.json"
495
+ ```
496
+
497
+ Auto timestamped backup path (default behavior when `path` is omitted):
498
+
499
+ ```text
500
+ codex-export
501
+ ```
502
+
503
+ Generated paths are stored in a `backups/` subdirectory near the active account storage file.
504
+
505
+ ---
506
+
507
+ ### codex-import
508
+
509
+ Import accounts from a JSON file (dedupe-aware merge).
510
+
511
+ Dry-run preview (no writes):
512
+
513
+ ```text
514
+ codex-import path="~/backup/accounts.json" dryRun=true
515
+ ```
516
+
517
+ Apply import:
518
+
519
+ ```text
520
+ codex-import path="~/backup/accounts.json"
521
+ ```
522
+
523
+ Before apply, the plugin creates an automatic timestamped pre-import backup when existing accounts are present. If backup creation fails, import apply is aborted.
524
+
525
+ ---
526
+
527
+ ### codex-dashboard
528
+
529
+ Show live account eligibility, retry budget usage, refresh queue metrics, and the recommended next step.
530
+
531
+ ```text
532
+ codex-dashboard
533
+ ```
534
+
535
+ ---
536
+
537
+ ### Quick Reference
538
+
539
+ | Tool | What It Does | Example |
540
+ |------|--------------|---------|
541
+ | `codex-help` | Command guide by topic | `codex-help topic="setup"` |
542
+ | `codex-setup` | Readiness checklist/wizard | `codex-setup wizard=true` |
543
+ | `codex-next` | Best next action | `codex-next` |
544
+ | `codex-doctor` | Diagnostics and optional safe fixes | `codex-doctor fix=true` |
545
+ | `codex-list` | List/filter accounts | `codex-list tag="work"` |
546
+ | `codex-switch` | Switch active account | `codex-switch index=2` |
547
+ | `codex-label` | Set/clear display label | `codex-label index=2 label="Work"` |
548
+ | `codex-tag` | Set/clear tag list | `codex-tag index=2 tags="work,team-a"` |
549
+ | `codex-note` | Set/clear account note | `codex-note index=2 note="night backup"` |
550
+ | `codex-status` | Per-account health/rate limit detail | `codex-status` |
551
+ | `codex-dashboard` | Live selection and retry view | `codex-dashboard` |
552
+ | `codex-metrics` | Runtime metrics summary | `codex-metrics` |
553
+ | `codex-health` | Validate token health (read-only) | `codex-health` |
554
+ | `codex-refresh` | Refresh and persist tokens | `codex-refresh` |
555
+ | `codex-remove` | Remove account entry | `codex-remove index=3` |
556
+ | `codex-export` | Export account backups | `codex-export` |
557
+ | `codex-import` | Dry-run or apply imports | `codex-import path="~/backup/accounts.json" dryRun=true` |
558
+
559
+ ---
560
+
561
+ ### Sample Output (codex-list)
562
+
563
+ ```text
564
+ Codex Accounts (3):
565
+
566
+ [1] Account 1 (user@gmail.com, workspace:Work, tags:work,team-a) active
567
+ [2] Account 2 (backup@email.com, tags:backup) ok
568
+ [3] Account 3 (personal@email.com) rate-limited
569
+
570
+ Storage: ~/.opencode/openai-codex-accounts.json
571
+ ```
572
+
573
+ ## Rotation Behavior
574
+
575
+ **How rotation works:**
576
+ - Health scoring tracks success/failure per account
577
+ - Token bucket prevents hitting rate limits
578
+ - Hybrid selection prefers healthy accounts with available tokens
579
+ - Always retries when all accounts are rate-limited (waits for reset with live countdown)
580
+ - 20% jitter on retry delays to avoid thundering herd
581
+ - Auto-removes accounts after 3 consecutive auth failures (new in v4.11.0)
582
+
583
+ **Per-project accounts (v4.10.0+):**
584
+
585
+ By default, each project gets its own account storage namespace. This means you can keep different active accounts per project without writing account files into your repo. Works from subdirectories too; the plugin walks up to find the project root (v4.11.0). Disable with `perProjectAccounts: false` in your config.
586
+
587
+ **Storage locations:**
588
+ - Per-project: `~/.opencode/projects/{project-key}/openai-codex-accounts.json`
589
+ - Global (when per-project disabled): `~/.opencode/openai-codex-accounts.json`
590
+
591
+ ---
592
+
593
+ ## Troubleshooting
594
+
595
+ > **Quick reset**: Most issues can be resolved by deleting `~/.opencode/auth/openai.json` and running `opencode auth login` again.
596
+
597
+ ### Configuration Paths (All Platforms)
598
+
599
+ OpenCode uses `~/.config/opencode/` on **all platforms** including Windows.
600
+
601
+ | File | Path |
602
+ |------|------|
603
+ | Main config | `~/.config/opencode/opencode.json` |
604
+ | Auth tokens | `~/.opencode/auth/openai.json` |
605
+ | Multi-account (global) | `~/.opencode/openai-codex-accounts.json` |
606
+ | Multi-account (per-project) | `~/.opencode/projects/{project-key}/openai-codex-accounts.json` |
607
+ | Flagged accounts | `~/.opencode/openai-codex-flagged-accounts.json` |
608
+ | Plugin config | `~/.opencode/openai-codex-auth-config.json` |
609
+ | Debug logs | `~/.opencode/logs/codex-plugin/` |
610
+
611
+ > **Windows users**: `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
612
+
613
+ ---
614
+
615
+ <details>
616
+ <summary><b>401 Unauthorized Error</b></summary>
617
+
618
+ **Cause:** Token expired or not authenticated.
619
+
620
+ **Solutions:**
621
+ 1. Re-authenticate:
622
+ ```bash
623
+ opencode auth login
624
+ ```
625
+ 2. Check auth file exists:
626
+ ```bash
627
+ cat ~/.opencode/auth/openai.json
628
+ ```
629
+
630
+ </details>
631
+
632
+ <details>
633
+ <summary><b>Browser Doesn't Open for OAuth</b></summary>
634
+
635
+ **Cause:** Port 1455 conflict or SSH/WSL environment.
636
+
637
+ **Solutions:**
638
+ 1. **Manual URL paste:**
639
+ - Re-run `opencode auth login`
640
+ - Select **"ChatGPT Plus/Pro (manual URL paste)"**
641
+ - Paste the full redirect URL (including `#code=...`) after login
642
+
643
+ 2. **Check port availability:**
644
+ ```bash
645
+ # macOS/Linux
646
+ lsof -i :1455
647
+
648
+ # Windows
649
+ netstat -ano | findstr :1455
650
+ ```
651
+
652
+ 3. **Stop Codex CLI if running** — Both use port 1455
653
+
654
+ </details>
655
+
656
+ <details>
657
+ <summary><b>Model Not Found</b></summary>
658
+
659
+ **Cause:** Missing provider prefix or config mismatch.
660
+
661
+ **Solutions:**
662
+ 1. Use `openai/` prefix:
663
+ ```bash
664
+ # Correct
665
+ --model=openai/gpt-5.4
666
+
667
+ # Wrong
668
+ --model=gpt-5.4
669
+ ```
670
+
671
+ 2. Verify model is in your config:
672
+ ```json
673
+ { "models": { "gpt-5.4": { ... } } }
674
+ ```
675
+
676
+ </details>
677
+
678
+ <details>
679
+ <summary><b>Unsupported Codex Model for ChatGPT Account</b></summary>
680
+
681
+ **Error example:** `Bad Request: {"detail":"The 'gpt-5.3-codex-spark' model is not supported when using Codex with a ChatGPT account."}`
682
+
683
+ **Cause:** Active workspace/account is not entitled for the requested Codex model.
684
+
685
+ **Solutions:**
686
+ 1. Re-auth to refresh workspace selection (most common Spark fix):
687
+ ```bash
688
+ opencode auth login
689
+ ```
690
+ 2. Add another entitled account/workspace. The plugin will try remaining accounts/workspaces before model fallback.
691
+ 3. Enable automatic fallback only if you want degraded-model retries when Spark is not entitled:
692
+ ```bash
693
+ CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback opencode
694
+ ```
695
+ 4. Use custom fallback chain in `~/.opencode/openai-codex-auth-config.json`:
696
+ ```json
697
+ {
698
+ "unsupportedCodexPolicy": "fallback",
699
+ "fallbackOnUnsupportedCodexModel": true,
700
+ "unsupportedCodexFallbackChain": {
701
+ "gpt-5.4-pro": ["gpt-5.4"],
702
+ "gpt-5-codex": ["gpt-5.2-codex"],
703
+ "gpt-5.3-codex": ["gpt-5-codex", "gpt-5.2-codex"],
704
+ "gpt-5.3-codex-spark": ["gpt-5-codex", "gpt-5.3-codex", "gpt-5.2-codex"]
705
+ }
706
+ }
707
+ ```
708
+ 5. Verify effective upstream model when needed:
709
+ ```bash
710
+ ENABLE_PLUGIN_REQUEST_LOGGING=1 CODEX_PLUGIN_LOG_BODIES=1 opencode run "ping" --model=openai/gpt-5.3-codex-spark
711
+ ```
712
+ The UI can keep showing your selected model while fallback is applied internally.
713
+
714
+ </details>
715
+
716
+ <details>
717
+ <summary><b>Rate Limit Exceeded</b></summary>
718
+
719
+ **Cause:** ChatGPT subscription usage limit reached.
720
+
721
+ **Solutions:**
722
+ 1. Wait for reset (plugin shows timing in error message)
723
+ 2. Add more accounts: `opencode auth login`
724
+ 3. Switch to a different model family
725
+
726
+ </details>
727
+
728
+ <details>
729
+ <summary><b>Multi-Turn Context Lost</b></summary>
730
+
731
+ **Cause:** Old plugin version or missing config.
732
+
733
+ **Solutions:**
734
+ 1. Update plugin:
735
+ ```bash
736
+ npx -y oc-chatgpt-multi-auth@latest
737
+ ```
738
+ 2. Ensure config has:
739
+ ```json
740
+ {
741
+ "include": ["reasoning.encrypted_content"],
742
+ "store": false
743
+ }
744
+ ```
745
+
746
+ </details>
747
+
748
+ <details>
749
+ <summary><b>OAuth Callback Issues (Safari/WSL/Docker)</b></summary>
750
+
751
+ **Safari HTTPS-only mode:**
752
+ - Use Chrome or Firefox instead, or
753
+ - Temporarily disable Safari > Settings > Privacy > "Enable HTTPS-only mode"
754
+
755
+ **WSL2:**
756
+ - Use VS Code's port forwarding, or
757
+ - Configure Windows → WSL port forwarding
758
+
759
+ **SSH / Remote:**
760
+ ```bash
761
+ ssh -L 1455:localhost:1455 user@remote
762
+ ```
763
+
764
+ **Docker / Containers:**
765
+ - OAuth with localhost redirect doesn't work in containers
766
+ - Use SSH port forwarding or manual URL flow
767
+
768
+ </details>
769
+
770
+ ---
771
+
772
+ ## Plugin Compatibility
773
+
774
+ ### oh-my-opencode
775
+
776
+ Works alongside oh-my-opencode. No special configuration needed.
777
+
778
+ ```json
779
+ {
780
+ "plugin": [
781
+ "oc-chatgpt-multi-auth@latest",
782
+ "oh-my-opencode@latest"
783
+ ]
784
+ }
785
+ ```
786
+
787
+ ### @tarquinen/opencode-dcp
788
+
789
+ List this plugin before dcp:
790
+
791
+ ```json
792
+ {
793
+ "plugin": [
794
+ "oc-chatgpt-multi-auth@latest",
795
+ "@tarquinen/opencode-dcp@latest"
796
+ ]
797
+ }
798
+ ```
799
+
800
+ ### Plugins You Don't Need
801
+
802
+ - **openai-codex-auth** — Not needed. This plugin replaces the original.
803
+
804
+ ---
805
+
806
+ ## Configuration
807
+
808
+ Create `~/.opencode/openai-codex-auth-config.json` for optional settings:
809
+
810
+ ### Model Behavior
811
+
812
+ | Option | Default | What It Does |
813
+ |--------|---------|--------------|
814
+ | `requestTransformMode` | `native` | Request shaping mode: `native` keeps OpenCode payloads unchanged; `legacy` enables Codex compatibility rewrites |
815
+ | `codexMode` | `true` | Legacy-only bridge prompt behavior (applies when `requestTransformMode=legacy`) |
816
+ | `codexTuiV2` | `true` | Enables Codex-style terminal UI output (set `false` for legacy output) |
817
+ | `codexTuiColorProfile` | `truecolor` | Terminal color profile for Codex UI (`truecolor`, `ansi256`, `ansi16`) |
818
+ | `codexTuiGlyphMode` | `ascii` | Glyph mode for Codex UI (`ascii`, `unicode`, `auto`) |
819
+ | `fastSession` | `false` | Forces low-latency settings per request (`reasoningEffort=none/low`, `reasoningSummary=auto`, `textVerbosity=low`) |
820
+ | `fastSessionStrategy` | `hybrid` | `hybrid` speeds simple turns but keeps full-depth on complex prompts; `always` forces fast tuning on every turn |
821
+ | `fastSessionMaxInputItems` | `30` | Max input items kept when fast tuning is applied |
822
+
823
+ ### Account Settings (v4.10.0+)
824
+
825
+ | Option | Default | What It Does |
826
+ |--------|---------|--------------|
827
+ | `perProjectAccounts` | `true` | Each project gets its own account storage namespace under `~/.opencode/projects/` |
828
+ | `toastDurationMs` | `5000` | How long toast notifications stay visible (ms) |
829
+ | `beginnerSafeMode` | `false` | Beginner-safe retry profile: conservative retry budget, disables all-accounts wait/retry, and caps all-accounts retries |
830
+
831
+ ### Retry Behavior
832
+
833
+ | Option | Default | What It Does |
834
+ |--------|---------|--------------|
835
+ | `retryProfile` | `balanced` | Global retry budget profile (`conservative`, `balanced`, `aggressive`) |
836
+ | `retryBudgetOverrides` | `{}` | Per-class retry budget overrides (`authRefresh`, `network`, `server`, `rateLimitShort`, `rateLimitGlobal`, `emptyResponse`) |
837
+ | `retryAllAccountsRateLimited` | `true` | Wait and retry when all accounts are rate-limited |
838
+ | `retryAllAccountsMaxWaitMs` | `0` | Max wait time (0 = unlimited) |
839
+ | `retryAllAccountsMaxRetries` | `Infinity` | Max retry attempts |
840
+ | `unsupportedCodexPolicy` | `strict` | Unsupported-model behavior: `strict` (return entitlement error) or `fallback` (retry next model in fallback chain) |
841
+ | `fallbackOnUnsupportedCodexModel` | `false` | Legacy fallback toggle mapped to `unsupportedCodexPolicy` (prefer using `unsupportedCodexPolicy`) |
842
+ | `fallbackToGpt52OnUnsupportedGpt53` | `true` | Legacy compatibility toggle for the `gpt-5.3-codex -> gpt-5.2-codex` edge when generic fallback is enabled |
843
+ | `unsupportedCodexFallbackChain` | `{}` | Optional per-model fallback-chain override (map of `model -> [fallback1, fallback2, ...]`) |
844
+ | `fetchTimeoutMs` | `60000` | Request timeout to Codex backend (ms) |
845
+ | `streamStallTimeoutMs` | `45000` | Abort non-stream parsing if SSE stalls (ms) |
846
+
847
+ Default unsupported-model fallback chain (used when `unsupportedCodexPolicy` is `fallback`):
848
+ - `gpt-5.4-pro -> gpt-5.4` (if `gpt-5.4-pro` is selected manually)
849
+ - `gpt-5.3-codex -> gpt-5-codex -> gpt-5.2-codex`
850
+ - `gpt-5.3-codex-spark -> gpt-5-codex -> gpt-5.3-codex -> gpt-5.2-codex` (applies if you manually select Spark model IDs)
851
+ - `gpt-5.2-codex -> gpt-5-codex`
852
+ - `gpt-5.1-codex -> gpt-5-codex`
853
+
854
+ When `beginnerSafeMode` is enabled, runtime behavior is intentionally conservative:
855
+ - Retry profile is forced to `conservative`
856
+ - `retryAllAccountsRateLimited` is forced `false`
857
+ - `retryAllAccountsMaxRetries` is capped to `1`
858
+
859
+ ### Environment Variables
860
+
861
+ ```bash
862
+ DEBUG_CODEX_PLUGIN=1 opencode # Enable debug logging
863
+ ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode # Log request metadata
864
+ CODEX_PLUGIN_LOG_BODIES=1 opencode # Include raw request/response payloads in request logs (sensitive)
865
+ CODEX_PLUGIN_LOG_LEVEL=debug opencode # Set log level (debug|info|warn|error)
866
+ CODEX_AUTH_REQUEST_TRANSFORM_MODE=legacy opencode # Re-enable legacy Codex request rewrites
867
+ CODEX_MODE=0 opencode # Temporarily disable bridge prompt
868
+ CODEX_TUI_V2=0 opencode # Disable Codex-style UI (legacy output)
869
+ CODEX_TUI_COLOR_PROFILE=ansi16 opencode # Force UI color profile
870
+ CODEX_TUI_GLYPHS=unicode opencode # Override glyph mode (ascii|unicode|auto)
871
+ CODEX_AUTH_PREWARM=0 opencode # Disable startup prewarm (prompt/instruction cache warmup)
872
+ CODEX_AUTH_FAST_SESSION=1 opencode # Enable faster response defaults
873
+ CODEX_AUTH_FAST_SESSION_STRATEGY=always opencode # Force fast mode for all prompts
874
+ CODEX_AUTH_FAST_SESSION_MAX_INPUT_ITEMS=24 opencode # Tune fast-mode history window
875
+ CODEX_AUTH_BEGINNER_SAFE_MODE=1 opencode # Enable beginner-safe runtime profile
876
+ CODEX_AUTH_RETRY_PROFILE=aggressive opencode # Override retry profile (ignored when beginner safe mode is on)
877
+ CODEX_AUTH_RETRY_ALL_RATE_LIMITED=0 opencode # Disable all-accounts wait-and-retry
878
+ CODEX_AUTH_RETRY_ALL_MAX_WAIT_MS=30000 opencode # Cap all-accounts wait duration
879
+ CODEX_AUTH_RETRY_ALL_MAX_RETRIES=1 opencode # Cap all-accounts retry attempts
880
+ CODEX_AUTH_UNSUPPORTED_MODEL_POLICY=fallback opencode # Enable generic unsupported-model fallback
881
+ CODEX_AUTH_FALLBACK_UNSUPPORTED_MODEL=1 opencode # Legacy fallback toggle (prefer policy var above)
882
+ CODEX_AUTH_FALLBACK_GPT53_TO_GPT52=0 opencode # Disable only the legacy gpt-5.3 -> gpt-5.2 edge
883
+ CODEX_AUTH_FETCH_TIMEOUT_MS=120000 opencode # Override request timeout
884
+ CODEX_AUTH_STREAM_STALL_TIMEOUT_MS=60000 opencode # Override SSE stall timeout
885
+ ```
886
+
887
+ For all options, see [docs/configuration.md](docs/configuration.md).
888
+
889
+ ---
890
+
891
+ ## Documentation
892
+
893
+ - [Getting Started](docs/getting-started.md) — Complete installation guide
894
+ - [Configuration](docs/configuration.md) — All configuration options
895
+ - [Troubleshooting](docs/troubleshooting.md) — Common issues and fixes
896
+ - [Architecture](docs/development/ARCHITECTURE.md) — How the plugin works
897
+
898
+ ---
899
+
900
+ ## Credits
901
+
902
+ - [numman-ali/opencode-openai-codex-auth](https://github.com/numman-ali/opencode-openai-codex-auth) by [numman-ali](https://github.com/numman-ali) — Original plugin
903
+ - [ndycode](https://github.com/ndycode) — Multi-account support and maintenance
904
+
905
+ ## License
906
+
907
+ MIT License. See [LICENSE](LICENSE) for details.
908
+
909
+ <details>
910
+ <summary><b>Legal</b></summary>
911
+
912
+ ### Intended Use
913
+
914
+ - Personal / internal development only
915
+ - Respect subscription quotas and data handling policies
916
+ - Not for production services or bypassing intended limits
917
+
918
+ ### Warning
919
+
920
+ By using this plugin, you acknowledge:
921
+
922
+ - **Terms of Service risk** — This approach may violate ToS of AI model providers
923
+ - **No guarantees** — APIs may change without notice
924
+ - **Assumption of risk** — You assume all legal, financial, and technical risks
925
+
926
+ ### Disclaimer
927
+
928
+ - Not affiliated with OpenAI. This is an independent open-source project.
929
+ - "ChatGPT", "GPT-5", "Codex", and "OpenAI" are trademarks of OpenAI, L.L.C.
930
+
931
+ </details>