Use your ChatGPT (Codex) subscription as a native provider in claude-code-router. No API key, no extra proxy: just the OAuth login you already have from the Codex CLI.
claude-code-router has no built-in support for Codex OAuth, and the ChatGPT Codex backend has quirks that break ccr's stock transformers: it requires store:false and stream:true, sends no Content-Type header on SSE responses, and returns an empty output in response.completed. Existing workarounds run a separate proxy process. This plugin is a single transformer file that handles all of it inside ccr itself.
The plugin is a ccr transformer chained after openai-responses. On every request it:
- Reads your Codex CLI credentials from
~/.codex/auth.jsonand injects the OAuth headers (Authorization,chatgpt-account-id,originator). - Auto-refreshes the access token when it has less than 30 minutes left (same flow and client id as
codex login, written back atomically). - Forces
store:false/stream:trueand fixes the missingContent-Typeon responses; aggregates the SSE into JSON when the client asked for a non-streaming response. - Translates Claude Code's effort setting (
output_config.effort, including/modeland--effort) into Codexreasoning.effort:low/medium/high/xhighmap 1:1,maxmaps toxhigh. Reasoning summaries stream back as native thinking blocks.
Prerequisites: claude-code-router v2+, and the Codex CLI logged in with your ChatGPT subscription (codex login).
- Copy
codex-oauth.jsto~/.claude-code-router/plugins/. - In
~/.claude-code-router/config.json, register the transformer and add the provider:
{
"transformers": [
{ "path": "/Users/you/.claude-code-router/plugins/codex-oauth.js" }
],
"Providers": [
{
"name": "codex",
"api_base_url": "https://chatgpt.com/backend-api/codex/responses",
"api_key": "unused",
"models": ["gpt-5.6-sol"],
"transformer": { "use": ["openai-responses", "codex-oauth"] }
}
],
"Router": {
"default": "codex,gpt-5.6-sol"
}
}ccr restart, thenccr code.
To verify what actually goes out (model and reasoning effort per request), register the transformer with debug on:
"transformers": [
{ "path": "/Users/you/.claude-code-router/plugins/codex-oauth.js", "options": { "debug": true } }
]Then watch ~/.claude-code-router/logs/codex-oauth.jsonl: one JSON line per request with timestamp, model and effort. Off by default.
Built and tested on macOS. It should work on Linux and Windows (plain Node, no OS-specific APIs), but that hasn't been verified. If you test it or fix something on another OS, please open a PR so this section stays accurate.
This talks to the ChatGPT internal Codex backend, which is undocumented and may change without notice. Use at your own risk. Not affiliated with OpenAI, Anthropic, or claude-code-router.
MIT