OpenCode OpenAI Codex Auth Plugin
Access GPT-5 Codex through your ChatGPT Plus/Pro subscription in OpenCode
Found this useful? Follow me on X @nummanthinks for future updates and more projects!
⚠️ Usage Notice
This plugin is for personal development use only. It uses OpenAI’s official OAuth authentication (the same method as OpenAI’s official Codex CLI) for individual coding assistance with your ChatGPT Plus/Pro subscription.
Not for: Commercial services, API resale, or multi-user applications. For production use, see OpenAI Platform API.
Users are responsible for compliance with OpenAI’s Terms of Use.
Quick Links
For Users
- Getting Started - Complete installation and setup guide
- Configuration Guide - Advanced config options and patterns
- Troubleshooting - Debug techniques and common issues
- Privacy & Data Handling - How your data is handled and protected
- Release Notes - Version history and updates
For Developers
Explore the engineering depth behind this plugin:
- Architecture - Technical design, AI SDK compatibility, store:false explained
- Config System - How configuration loading and merging works
- Config Fields - Understanding config keys,
id
, andname
fields - Testing Guide - Test scenarios, integration testing, verification matrix
Getting Started
Installation
Add to your config, run OpenCode, authenticate:
# 1. Add plugin to ~/.config/opencode/opencode.json
# 2. Run OpenCode
opencode
# 3. Authenticate
opencode auth login
Updating
⚠️ OpenCode does NOT auto-update plugins
To get the latest version:
(cd ~ && sed -i.bak '/"opencode-openai-codex-auth"/d' .cache/opencode/package.json && rm -rf .cache/opencode/node_modules/opencode-openai-codex-auth)
opencode # Reinstalls latest
Minimal Configuration
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-openai-codex-auth"],
"model": "openai/gpt-5-codex"
}
Quick Test
opencode run "write hello world to test.txt" --model=openai/gpt-5-codex
Features
✅ OAuth Authentication - Secure ChatGPT Plus/Pro login ✅ Multiple Models - gpt-5, gpt-5-codex, gpt-5-mini, gpt-5-nano ✅ Per-Model Configuration - Different reasoning effort, verbosity for each variant ✅ Multi-Turn Conversations - Full conversation history with stateless backend ✅ Backwards Compatible - Works with old and new config formats ✅ Comprehensive Testing - 159 unit tests + 14 integration tests
Why This Plugin?
Use your ChatGPT subscription instead of OpenAI API credits
- No separate API key needed
- Access Codex models through ChatGPT Plus/Pro
- Same OAuth login as official Codex CLI
- Full feature parity with Codex CLI
How It Works
The plugin intercepts OpenCode’s OpenAI SDK requests and transforms them for the ChatGPT backend API:
- OAuth Token Management - Handles token refresh automatically
- Request Transformation - Converts OpenCode SDK format → Codex API format
- AI SDK Compatibility - Filters SDK-specific constructs for Codex API
- Stateless Operation - Works with ChatGPT backend’s
store: false
requirement
See Architecture for technical details.
Development
This plugin represents significant engineering effort to bridge OpenCode and the ChatGPT Codex backend:
- 7-step fetch flow with precise transformations
- AI SDK compatibility layer handling
item_reference
and other SDK constructs - Stateless multi-turn conversations via encrypted reasoning content
- 15-minute caching to prevent GitHub API rate limits
- Comprehensive test coverage with actual API verification
Explore the development docs to see the depth of implementation:
Support
- Issues: GitHub Issues
- Releases: Release Notes
- Main Repo: GitHub
License
MIT License with Usage Disclaimer - See LICENSE for details
Trademark Notice: Not affiliated with OpenAI. ChatGPT, GPT-5, Codex, and OpenAI are trademarks of OpenAI, L.L.C.