Skip to content
CuriosityOSPublic

About

Run GPT-5.6 (on your ChatGPT plan) and Claude side by side in one Claude Code session — full prompt caching, zero injected context, no API keys.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

GPT-in-CC

GPT-in-CC — two minds, one terminal

Run GPT-5.6 — on your ChatGPT plan — inside Claude Code, side by side with your Claude models.

One /model picker, two providers, zero API keys:

   Select model
     1.  Opus                             Opus 4.8 · your claude.ai login
     2.  Sonnet                           Sonnet 5 · your claude.ai login
     3.  Haiku                            Haiku 4.5 · your claude.ai login
   ❯ 4.  GPT-5.6 Sol (Codex) ✔            From gateway · your ChatGPT login
     5.  GPT-5.6 Sol (Codex, Extra High)  From gateway
     6.  GPT-5.6 Sol (Codex, Max)         From gateway
     7.  GPT-5.6 Terra (Codex, balanced)  From gateway
     8.  GPT-5.6 Luna (Codex, fast)       From gateway
     9.  GPT-5.5 (Codex)                  From gateway

GPT models run through your ChatGPT/Codex OAuth (Plus/Pro plan — no OpenAI API billing). Claude models run through your claude.ai login, forwarded byte-for-byte (subscription, prompt caching, and beta capabilities all intact). Switch freely mid-session.

Why this exists (and why naive proxies burn your quota)

Pointing Claude Code at the ChatGPT Codex backend through a simple translator has three nasty failure modes. GPT-in-CC fixes all of them, mirroring what the Codex CLI itself does on the wire:

Problem Fix Measured result
Prompt cache never hits — the backend routes requests by session headers; without them every request re-bills your full context Replays codex-rs's session affinity: session-id/thread-id/x-client-request-id + the x-codex-turn-state sticky-routing token; cached reasoning is re-injected at its original position so the prefix stays byte-stable 93–97% cache reads from turn 2, matching the native Codex CLI
~3.7k tokens of hidden context injected server-side around every request (hosted web tooling, platform instructions) Responses Lite — the transport codex-rs hardcodes for the GPT-5.6 family. Instructions and tools travel inside input; the backend adds nothing Identical probe request: 182 tokens on lite vs 4,658 without
Broken accounting — OpenAI's input_tokens includes cached tokens; Anthropic's excludes them Usage translated to Anthropic semantics; live token estimates stream in message_start Claude Code's context meter and cost tracking stay exact

Plus the Claude Code integration details that make it feel native:

  • /model picker rows for every GPT model via gateway model discovery (works even on OAuth-only sessions, where Claude Code normally skips discovery — the launcher refreshes the discovery cache itself).
  • /effort works: Claude Code's effort slider steers GPT reasoning effort (low → xhigh/max). Explicit @level suffixes win; bare sol defaults to high, same as the Codex CLI.
  • Thinking streams live — reasoning summaries render as Claude-style thinking blocks instead of a silent spinner.
  • Web search works from GPT sessions: Claude Code's WebSearch/WebFetch executors need Anthropic's server-side tools, so the proxy reroutes just those requests through your Claude login.
  • 372k context window advertised to Claude Code (GPT-5.6's real window) instead of the 200k default for unknown models.
  • Isolated profile (~/.gpt-in-cc/profile) — nothing here can touch your normal claude setup, and your main profile's plugins/MCP context stays out of GPT requests.

Requirements

  • Node 18+ and git
  • Claude Code v2.1.129+ (claude on PATH) with a claude.ai login (for the Claude side)
  • ChatGPT Plus/Pro with the Codex CLI logged in once (~/.codex/auth.json) — or use the built-in login page (below)

Install

git clone https://github.com/CuriosityOS/GPT-in-CC.git ~/GPT-in-CC
cd ~/GPT-in-CC
npm install
npm link        # puts `gpt-in-cc` on your PATH

Then:

gpt-in-cc

First run: pick a theme, trust your folder, and /login once with your claude.ai account (stored in the isolated profile). GPT models work immediately if the Codex CLI is logged in; otherwise open http://127.0.0.1:17870/codex/login while the proxy is running.

Let your agent install it

Paste this into any coding agent (Claude Code, Codex, etc.):

Clone https://github.com/CuriosityOS/GPT-in-CC to ~/GPT-in-CC, then run npm install and npm link in it. Verify with gpt-in-cc --status and confirm ~/.codex/auth.json exists (if not, tell me to log in with the Codex CLI or visit http://127.0.0.1:17870/codex/login after starting gpt-in-cc). Read the repo's CLAUDE.md if anything fails.

Usage

gpt-in-cc                 # launch Claude Code with both model families
gpt-in-cc -d              # with --dangerously-skip-permissions
gpt-in-cc --status        # where things live
gpt-in-cc --proxy-status  # is the proxy up
gpt-in-cc --restart       # apply proxy code/config changes
gpt-in-cc --stop          # stop the proxy daemon

The proxy runs as a small local daemon on 127.0.0.1:17870 (never exposed to the network). It deliberately outlives the session that started it, so several Claude Code sessions can share it; stop it with --stop.

Models and shortcuts

Pick from the /model picker, or type:

Shortcut Model Notes
sol gpt-5.6-sol Frontier. Follows /effort, defaults to high
sol@xhigh / xhigh gpt-5.6-sol Extra High reasoning
sol@max / max gpt-5.6-sol Max reasoning — slowest, hardest problems
fast / smart / deep gpt-5.6-sol @low / @medium / @high
terra gpt-5.6-terra Balanced everyday model
luna gpt-5.6-luna Fast & light — good for subagents
gpt55 gpt-5.5 Previous frontier (standard transport; the lite endpoint is 5.6-only)
opus / sonnet / haiku / any claude-* Claude models Your claude.ai login, passed through untouched

Every codex model accepts an @low|@medium|@high|@xhigh|@max suffix, e.g. /model terra@max.

Effort

  • /effort (Claude Code's slider) steers GPT reasoning when the model has no @level suffix.
  • An explicit suffix (sol@max) always wins.
  • Neither set → high, the Codex CLI's own default.

Subagents & workflows

GPT-5.6 Sol deliberates between tool calls (that's the model, not the transport — transport is ~2s/turn even with a 24k-token uncached payload, and 8 concurrent agents complete without throttling). For fast fan-out stages use sonnet or luna, or give GPT agents effort: 'low'; save sol@xhigh/@max for verify/judge/synthesis stages.

How it works

Claude Code ── Anthropic Messages API ──► local proxy (127.0.0.1:17870)
                                            │
                        claude-* models ────┤ transparent passthrough: your own
                                            │ Authorization header + anthropic-*
                                            │ headers forwarded verbatim to
                                            │ api.anthropic.com; response bytes
                                            │ relayed untouched
                                            │
                        gpt-* models ───────┤ translated to the ChatGPT Codex
                                            │ backend's Responses API over
                                            │ Responses Lite, with codex-rs's
                                            │ session-affinity headers and
                                            │ encrypted-reasoning replay
                                            ▼
                              chatgpt.com/backend-api/codex/responses

Key wire decisions (all verified against codex-rs source and live traffic):

  • Responses Lite (x-openai-internal-codex-responses-lite: true): instructions and tools are sent as developer items at the head of input; the request has no top-level instructions/tools; reasoning.context: all_turns; hosted tools omitted. The backend applies no scaffolding — the model sees exactly what Claude Code sends. Only the GPT-5.6 family is accepted on this transport; gpt-5.5 stays on the standard path. Kill-switch: CCX_RESPONSES_LITE=0.
  • Cache affinity: prompt_cache_key (UUID derived from Claude Code's session id) is also sent as session-id/thread-id/x-client-request-id, and the x-codex-turn-state response header is replayed on the next request. Without these, cache hits are load-balancer luck.
  • Reasoning replay: encrypted reasoning items (reasoning.encrypted_content) are cached per session and re-injected immediately before the last assistant message — their original position — so the request prefix stays byte-identical and the server cache keeps hitting.
  • Claude passthrough: with no ANTHROPIC_API_KEY configured, the proxy never sees or stores your Anthropic credentials — it forwards the client's own auth headers and relays responses byte-for-byte (Claude Code's error-recovery logic depends on exact upstream wording).

Configuration

Everything works with zero config. Optional environment variables:

Variable Default Purpose
GPTCC_CONFIG_DIR ~/.gpt-in-cc/profile Isolated Claude Code profile location
GPTCC_CONTEXT_WINDOW_TOKENS 372000 Context window advertised to Claude Code
GPTCC_AUTO_COMPACT_WINDOW_TOKENS 95% of window Auto-compact threshold
GPTCC_DISABLE_COMPACT unset 1 disables auto-compaction
CLAUDE_PROXY_PORT 17870 Proxy port
CODEX_REASONING_EFFORT unset Effort when neither @suffix nor /effort is set (else high)
CODEX_REASONING_SUMMARY detailed Reasoning summary verbosity (auto/concise/detailed/none)
CODEX_TEXT_VERBOSITY unset low/medium/high response verbosity
CCX_RESPONSES_LITE on 0 reverts the 5.6 family to the standard (scaffolded) transport
CCX_SEARCH_MODEL claude-sonnet-5 Claude model that executes WebSearch/WebFetch
OPENAI_API_KEY unset Optional: routes openai: models via api.openai.com instead of OAuth

State lives in ~/.gpt-in-cc/ (proxy log, PID lock, Codex OAuth tokens if you used the login page, and the isolated profile).

Troubleshooting

Symptom Cause / fix
Unable to connect to API (ConnectionRefused) Proxy not running — launch gpt-in-cc (it starts one) or check gpt-in-cc --proxy-status; log at ~/.gpt-in-cc/proxy.log
Changes to adapters/ don't take effect The daemon reuses the running proxy — gpt-in-cc --restart
Claude models return 401 /login inside the gpt-in-cc session (the isolated profile has its own login)
GPT models return 401 Codex CLI not logged in — codex login, or open http://127.0.0.1:17870/codex/login
No GPT rows in /model The launcher writes the discovery cache on start — relaunch gpt-in-cc; check GET http://127.0.0.1:17870/v1/models
GPT model "not supported when using X-OpenAI-Internal-Codex-Responses-Lite" You routed a non-5.6 model over lite (custom shortcut?) — the built-ins gate this correctly; CCX_RESPONSES_LITE=0 as a blunt fallback
Cache reads at 0 on every turn Check ~/.gpt-in-cc/proxy.log for cacheRead= per request; turn 1 of each session is legitimately 0 (there is no shared prefix — that's the point)

Every request is logged to ~/.gpt-in-cc/proxy.log with token counts, cache reads, effort, and timing (firstEventMs/totalMs) — the first place to look when something feels off.

Development

npm run build   # typecheck
npm test        # vitest (60 tests: wire format, cache stability, routing, launcher)
npm run start:proxy   # run the gateway in the foreground

See CLAUDE.md for the agent-oriented map of the codebase.

Credits & license

MIT. Built on the excellent aryan877/claude-proxy (gateway skeleton, launcher plumbing), heavily reworked for cache-correct Codex transport, Responses Lite, Anthropic passthrough, and Claude Code integration. Wire format cross-checked against openai/codex (codex-rs).

Not affiliated with OpenAI or Anthropic. Use under your accounts' respective terms.

About

Run GPT-5.6 (on your ChatGPT plan) and Claude side by side in one Claude Code session — full prompt caching, zero injected context, no API keys.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages