Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ccr-codex

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.

Why

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.

How it works

The plugin is a ccr transformer chained after openai-responses. On every request it:

  1. Reads your Codex CLI credentials from ~/.codex/auth.json and injects the OAuth headers (Authorization, chatgpt-account-id, originator).
  2. Auto-refreshes the access token when it has less than 30 minutes left (same flow and client id as codex login, written back atomically).
  3. Forces store:false / stream:true and fixes the missing Content-Type on responses; aggregates the SSE into JSON when the client asked for a non-streaming response.
  4. Translates Claude Code's effort setting (output_config.effort, including /model and --effort) into Codex reasoning.effort: low/medium/high/xhigh map 1:1, max maps to xhigh. Reasoning summaries stream back as native thinking blocks.

Install

Prerequisites: claude-code-router v2+, and the Codex CLI logged in with your ChatGPT subscription (codex login).

  1. Copy codex-oauth.js to ~/.claude-code-router/plugins/.
  2. 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"
  }
}
  1. ccr restart, then ccr code.

Debug mode

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.

Compatibility

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.

Disclaimer

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.

License

MIT

About

Your Codex subscription as a native provider in claude-code-router

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages