oc-chatgpt-multi-auth 5.4.2 → 5.4.3

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