Complete installation and setup guide for the OpenCode OpenAI Codex Auth Plugin.
Before You Begin
[!CAUTION] This plugin is for personal development use only. It uses OpenAI's official OAuth authentication for individual coding assistance with your ChatGPT Plus/Pro subscription.
Not intended for: Commercial services, API resale, multi-user applications, or any use that violates OpenAI's Terms of Use.
For production applications, use the OpenAI Platform API.
| Requirement | Notes |
|---|---|
| OpenCode | Installation guide |
| ChatGPT Plus or Pro | Required for Codex access |
| Node.js 20+ | For OpenCode runtime |
Option A: One-Command Install (Recommended)
Works on Windows, macOS, and Linux:
npx -y oc-chatgpt-multi-auth@latestThis:
- Writes config to
~/.config/opencode/opencode.json - Backs up existing config
- Clears OpenCode plugin cache
Legacy OpenCode (v1.0.209 and below)?
npx -y oc-chatgpt-multi-auth@latest --legacyOption B: Install from Source
git clone https://github.com/ndycode/oc-chatgpt-multi-auth.git
cd oc-chatgpt-multi-auth
npm ci
npm run buildPoint OpenCode at the local build output:
{
"plugin": ["file:///absolute/path/to/oc-chatgpt-multi-auth/dist"]
}Note: Must point to
dist/folder (built output), not root.
Edit ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["oc-chatgpt-multi-auth@latest"]
}If you installed from source, use the
file://path instead.
opencode auth login- Select "OpenAI"
- Choose "ChatGPT Plus/Pro (Codex Subscription)"
- Browser opens automatically for OAuth flow
- Log in with your ChatGPT account
- Done! Token saved to
~/.opencode/auth/openai.json
OAuth Not Working?
Port conflict:
- Stop Codex CLI if running (both use port 1455)
- Check:
lsof -i :1455(macOS/Linux) ornetstat -ano | findstr :1455(Windows)
SSH/WSL/Remote:
- Select "ChatGPT Plus/Pro (Manual URL Paste)"
- Paste the full redirect URL after login
Use one of the provided config files:
| OpenCode Version | Config File |
|---|---|
| v1.0.210+ (modern) | config/opencode-modern.json |
| v1.0.209 and below | config/opencode-legacy.json |
Copy the relevant config to your ~/.config/opencode/opencode.json.
The shipped templates include 21 presets and intentionally omit Spark IDs. Add gpt-5.3-codex-spark manually only when your workspace is entitled.
Why use the full config?
- GPT-5 models need proper configuration to work reliably
- Full configs include
limitmetadata for OpenCode UI features - Minimal configs are for debugging only
# Modern OpenCode (v1.0.210+)
opencode run "write hello world to test.txt" --model=openai/gpt-5.2 --variant=medium
opencode run "write hello world to test.txt" --model=openai/gpt-5-codex --variant=medium
# Legacy OpenCode (v1.0.209 and below)
opencode run "write hello world to test.txt" --model=openai/gpt-5.2-medium
# Or start interactive session
opencodeYou'll see all 21 GPT-5.x variants in the model selector!
If gpt-5-codex or gpt-5.3-codex-spark returns an unsupported-model entitlement error, re-auth with opencode auth login or add another entitled account/workspace first. The plugin tries remaining accounts/workspaces before model fallback. See Configuration for strict vs fallback policy controls.
If you manually add Spark IDs and want to confirm effective upstream routing, run with ENABLE_PLUGIN_REQUEST_LOGGING=1 CODEX_PLUGIN_LOG_BODIES=1 and inspect ~/.opencode/logs/codex-plugin/request-*-after-transform.json.
After adding accounts, run:
codex-setup
codex-help topic="setup"
codex-doctor
codex-next
If your terminal supports menus, you can use guided onboarding:
codex-setup mode="wizard"
Notes:
codex-switch,codex-label, andcodex-removesupport interactive account pickers whenindexis omitted in interactive terminals.- On plugin startup, a one-line preflight summary is shown (healthy/blocked/rate-limited + suggested next action).
If you want conservative retry behavior while learning:
// ~/.opencode/openai-codex-auth-config.json
{
"beginnerSafeMode": true
}Or via environment variable:
CODEX_AUTH_BEGINNER_SAFE_MODE=1 opencodeSafe mode effects:
- Forces conservative retry profile
- Disables all-accounts rate-limit wait/retry
- Caps all-accounts retries to one attempt
| Model | Variants | Notes |
|---|---|---|
gpt-5.2 |
none, low, medium, high, xhigh | Latest GPT-5.2 |
gpt-5-codex |
low, medium, high | Canonical Codex for code generation |
gpt-5.3-codex-spark |
low, medium, high, xhigh | Optional manual model; entitlement-gated by account/workspace |
gpt-5.1-codex-max |
low, medium, high, xhigh | Maximum context |
gpt-5.1-codex |
low, medium, high | Standard Codex |
gpt-5.1-codex-mini |
medium, high | Lightweight |
gpt-5.1 |
none, low, medium, high | Base model |
Total: 21 template presets with 272k context / 128k output (+ optional Spark IDs when entitled).
OpenCode checks multiple config files in order:
| Priority | Location | Use Case |
|---|---|---|
| 1 | ./.opencode.json |
Project-specific |
| 2 | Parent directories | Monorepo |
| 3 | ~/.config/opencode/opencode.json |
Global defaults |
Recommendation: Plugin in global config, model/agent overrides in project config.
From npm
OpenCode caches plugins. Re-run the installer:
npx -y oc-chatgpt-multi-auth@latestFrom source
cd oc-chatgpt-multi-auth
git pull
npm ci
npm run buildWhen to update:
- New features released
- Bug fixes available
- Security updates
Check for updates: Releases Page
opencode --version
# Should not show any plugin errorscat ~/.opencode/auth/openai.json
# Should show OAuth credentials# Enable logging to verify requests
ENABLE_PLUGIN_REQUEST_LOGGING=1 opencode run "test" --model=openai/gpt-5.2
# Check logs
ls ~/.opencode/logs/codex-plugin/- Configuration Guide — Advanced config options
- Troubleshooting — Common issues and solutions
- Architecture — Technical deep dive
Back to: Documentation Home | Main README