OpenCode OpenAI Codex Authentication Plugin
This package provides an authentication plugin for the OpenCode AI platform, enabling users to leverage their existing ChatGPT Plus/Pro subscriptions with the OpenAI Codex backend instead of consuming API credits. The current stable version is 4.4.0, and the project demonstrates a very active release cadence with multiple minor and patch releases in quick succession, indicating ongoing development and maintenance. Key differentiators include a simplified one-command installer (`npx opencode-openai-codex-auth@latest`), comprehensive support for various GPT-5.x and Codex model families (including GPT-5.2 Codex), and an official OAuth flow for seamless integration. It handles multimodal input and automatically manages token refresh, aiming to provide a 'one config, every model' philosophy for OpenCode users. It is designed primarily for personal development use, with a warning against production or multi-user applications.
Common errors
-
Invalid JSON response
cause The `/agent create` command failed due to issues in handling SSE/JSON responses or overly aggressive filtering of tool calls during compaction.fixUpgrade to version 4.0.2 or newer, which contains fixes for agent creation failing and correct handling of SSE/JSON responses. -
400 errors during summary/compaction requests when OpenCode sends item_reference pointers to server-stored function calls
cause The plugin was aggressively filtering out `function_call` and `function_call_output` items, even when tools were present, leading to orphaned `function_call_output` errors.fixUpgrade to version 4.0.1 or newer. This version fixes the compaction context loss by only filtering orphaned outputs (without matching calls), preserving matched pairs for context. -
GitHub API rate limiting when fetching Codex instructions
cause Frequent requests to GitHub for Codex instructions could trigger API rate limits, causing failures in fetching necessary data.fixUpgrade to version 4.0.1 or newer, which includes a fallback mechanism to handle GitHub API rate limiting.
Warnings
- breaking The plugin enforced GPT 5.1 model identifiers, deprecating and removing legacy GPT 5.0 models. Existing configurations using GPT-5.0 model names will break.
- breaking Version 4.0.0 migrated all GPT-5.0 models to GPT-5.1. This change requires users to update their model references in configurations and commands.
- gotcha Codex variants (Codex, Codex Max, Codex Mini) do NOT support `reasoning_effort: "none"`. Attempting to set this will auto-convert it to 'low' for Codex/Codex Max, or 'medium' for Codex Mini.
- gotcha This plugin is strictly for personal development use with your own ChatGPT Plus/Pro subscription. It is not intended for production or multi-user applications.
Install
-
npm install opencode-openai-codex-auth -
yarn add opencode-openai-codex-auth -
pnpm add opencode-openai-codex-auth
Imports
- OpenAICodexAuthPlugin
import { OpenAICodexAuthPlugin } from 'opencode-openai-codex-auth'; - IOpenAICodexAuthOptions
import type { IOpenAICodexAuthOptions } from 'opencode-openai-codex-auth'; - Installer
import { Installer } from 'opencode-openai-codex-auth/installer';
Quickstart
npx -y opencode-openai-codex-auth@latest opencode auth login opencode run "write hello world to test.txt" --model=openai/gpt-5.2 --variant=medium # For legacy OpenCode (v1.0.209 and below): npx -y opencode-openai-codex-auth@latest --legacy opencode run "write hello world to test.txt" --model=openai/gpt-5.2-medium