OpenCode Codex Auth Plugin

Access GPT-5 Codex through your ChatGPT Plus/Pro subscription

Download as .zip Download as .tar.gz View on GitHub

OpenCode OpenAI Codex Auth Plugin

Access GPT-5 Codex through your ChatGPT Plus/Pro subscription in OpenCode

npm version Tests

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.


For Users

For Developers

Explore the engineering depth behind this plugin:


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


How It Works

The plugin intercepts OpenCode’s OpenAI SDK requests and transforms them for the ChatGPT backend API:

  1. OAuth Token Management - Handles token refresh automatically
  2. Request Transformation - Converts OpenCode SDK format → Codex API format
  3. AI SDK Compatibility - Filters SDK-specific constructs for Codex API
  4. 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:

Explore the development docs to see the depth of implementation:


Support


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.