opencode-codex-auth-rotation
v1.0.4
Published
OpenAI ChatGPT (Codex backend) OAuth auth plugin for opencode with multi-account rotation - use your ChatGPT Plus/Pro subscription instead of API credits
Maintainers
Readme
Forked from Numman Ali's opencode-openai-codex-auth with multi-account rotation support
One install. Every Codex model. Multi-account rotation.
Install · Models · Configuration · Docs
💡 Philosophy
"One config. Every model." OpenCode should feel effortless. This plugin keeps the setup minimal while giving you full GPT‑5.x + Codex access via ChatGPT OAuth.
┌─────────────────────────────────────────────────────────┐
│ │
│ ChatGPT OAuth → Codex backend → OpenCode │
│ One command install, full model presets, done. │
│ │
└─────────────────────────────────────────────────────────┘🚀 Quick Start
npx -y opencode-codex-auth-rotation@latestThen:
opencode auth login
opencode run "write hello world to test.txt" --model=openai/gpt-5.2 --variant=mediumLegacy OpenCode (v1.0.209 and below):
npx -y opencode-codex-auth-rotation@latest --legacy
opencode run "write hello world to test.txt" --model=openai/gpt-5.2-mediumUninstall:
npx -y opencode-codex-auth-rotation@latest --uninstall
npx -y opencode-codex-auth-rotation@latest --uninstall --all📦 Models
- gpt-5.2 (none/low/medium/high/xhigh)
- gpt-5.2-codex (low/medium/high/xhigh)
- gpt-5.1-codex-max (low/medium/high/xhigh)
- gpt-5.1-codex (low/medium/high)
- gpt-5.1-codex-mini (medium/high)
- gpt-5.1 (none/low/medium/high)
🧩 Configuration
- Modern (OpenCode v1.0.210+):
config/opencode-modern.json - Legacy (OpenCode v1.0.209 and below):
config/opencode-legacy.json
Minimal configs are not supported for GPT‑5.x; use the full configs above.
✅ Features
- ChatGPT Plus/Pro OAuth authentication (official flow)
- 22 model presets across GPT‑5.2 / GPT‑5.2 Codex / GPT‑5.1 families
- Variant system support (v1.0.210+) + legacy presets
- Multimodal input enabled for all models
- Usage‑aware errors + automatic token refresh
📚 Docs
- Getting Started:
docs/getting-started.md - Configuration:
docs/configuration.md - Troubleshooting:
docs/troubleshooting.md - Architecture:
docs/development/ARCHITECTURE.md
🔄 Multi-Account Setup Guide
This plugin supports multiple ChatGPT accounts for automatic failover when rate limits occur.
Configuration
Account credentials are stored in ~/.config/opencode/codex-accounts.json:
// ~/.config/opencode/codex-accounts.json
// auth.json과 동일한 형식 - 수동으로 추가 계정 입력
{
"version": 1,
"accounts": [
{
"type": "oauth",
"access": "eyJhbGci...",
"refresh": "v1.MjE0...",
"expires": 1770555836476,
"accountId": "130e685f-610e-4a52-8c8b-f57bcabcea35",
"email": "[email protected]"
},
{
"type": "oauth",
"access": "eyJhbGci...",
"refresh": "v1.MjE0...",
"expires": 1770555836476,
"accountId": "another-account-id",
"email": "[email protected]"
}
],
"activeIndex": 0
}Account Rotation Strategies
The plugin supports two rotation strategies:
| Strategy | Description | Best For | |----------|-------------|----------| | Sticky (default) | Stay with current account until rate-limited | Low-volume usage | | Round-Robin | Rotate sequentially through accounts | Even distribution |
Environment variable: CODEX_ACCOUNT_STRATEGY=sticky|round-robin
Plugin config (~/.config/opencode/codex-auth-config.json):
{
"strategy": "round-robin"
}🔄 Usage-Based Account Selection
This plugin selects accounts based on actual ChatGPT usage data from the /wham/usage API.
30/60/90% Equal Distribution Strategy
Weekly usage buckets: Accounts are grouped by weekly usage percentage
- Bucket 0: 0-30%
- Bucket 1: 30-60%
- Bucket 2: 60-90%
- Bucket 3: 90%+
Selection logic:
- Filter accounts with the lowest weekly bucket
- Among those, select the one with lowest 5-hour usage
- This ensures all accounts reach similar usage levels before moving to the next bucket
Usage Debugging
Check current usage for all accounts:
bun run scripts/check-usage.tsJSON output:
bun run scripts/check-usage.ts --jsonAutomatic Failover
When a 429 Rate Limit error occurs:
- Current account is marked with
rateLimitResetTime - Plugin automatically switches to next available account
- Rate-limited account is skipped until reset time passes
Adding Multiple Accounts
Run the OAuth flow for each account:
opencode auth loginThe plugin will automatically add new accounts to the configuration.
You can manually enable/disable accounts by setting
"enabled": false.
⚠️ Usage Notice
This plugin is for personal development use with your own ChatGPT Plus/Pro subscription. For production or multi‑user applications, use the OpenAI Platform API.
Built for developers who value simplicity.
