Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cc-openai-proxy

Run the Claude Code harness (its UI, tools, subagents, skills) on non-Claude (OpenAI) models — while keeping plain claude untouched on Anthropic.

It works by pointing Claude Code at a local CLIProxyAPI instance that speaks Anthropic's API format on the front and reuses your ChatGPT/Codex OAuth login on the back. A claudex shell function flips the model per-launch; claude stays exactly as-is.

claude       # Claude (Opus/Sonnet), Anthropic direct        — your Claude sub
claudex      # Claude Code harness on gpt-5.6-sol via proxy   — your ChatGPT/Codex sub
claudexp     # pick ANY model the proxy exposes, then launch

Inspired by Theo's setup.

Requirements

  • macOS with Homebrew
  • Claude Code (claude on your PATH)
  • A ChatGPT/Codex account with access to the GPT models you want

Install

git clone https://github.com/matheustimbo/cc-openai-proxy.git
cd cc-openai-proxy
./install.sh

The installer:

  1. brew install cliproxyapi
  2. Generates a fresh local proxy token (nothing secret is ever committed)
  3. Writes the proxy config to $(brew --prefix)/etc/cliproxyapi.conf (localhost-only, :8317)
  4. Installs the shell module to ~/.config/claudex/claudex.zsh and sources it from ~/.zshrc
  5. Runs the interactive Codex OAuth login (cliproxyapi -codex-login) — opens a browser
  6. Starts the proxy as a background service and verifies it

Then open a new terminal (or source ~/.zshrc).

Skip the browser login for now: ./install.sh --no-login, and run cliproxyapi -codex-login later.

Usage

claudex                                # start on the default model (gpt-5.6-sol)
CLAUDEX_MODEL=gpt-5.6-terra claudex     # any model, this run only
claudexp                                # interactive picker over all proxy models
claudex --continue                      # extra args pass through to claude

The in-session /model picker

Claude Code's /model menu is a fixed Claude-tier UI (Opus/Sonnet/Haiku) — it cannot enumerate every OpenAI model. This setup maps the three slots to three GPT models so /model becomes a live 3-way switcher:

Slot Env var Default
Opus CLAUDEX_OPUS gpt-5.6-sol
Sonnet CLAUDEX_SONNET gpt-5.6-terra
Haiku CLAUDEX_HAIKU gpt-5.4-mini

Override in ~/.zshrc, e.g. export CLAUDEX_SONNET=gpt-5.6-luna. For anything outside these three, use claudexp or CLAUDEX_MODEL=….

How it works

claudex  ──env──▶  claude (Claude Code CLI)
                      │  ANTHROPIC_BASE_URL=http://127.0.0.1:8317
                      │  ANTHROPIC_AUTH_TOKEN=<local proxy token>
                      ▼
              CLIProxyAPI  :8317  (Anthropic-compatible /v1/messages)
                      │  reuses your Codex OAuth token in ~/.cli-proxy-api
                      ▼
              OpenAI (gpt-5.6-*, …)

claudex only sets these in its own subshell — plain claude never sees them, so it keeps talking to Anthropic directly.

The env flags it sets (matching Theo's recipe):

Var Effect
--model <id> main session model
CLAUDE_CODE_SUBAGENT_MODEL subagents use the same model
CLAUDE_CODE_ALWAYS_ENABLE_EFFORT=1 enable effort controls
CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCY=3 cap concurrent tool calls
ENABLE_TOOL_SEARCH=false disable dynamic tool search

Managing the proxy

brew services restart cliproxyapi     # after a config change
brew services stop cliproxyapi
brew services info cliproxyapi
curl -s localhost:8317/v1/models -H "Authorization: Bearer $CLAUDEX_PROXY_TOKEN" | jq .

Config: $(brew --prefix)/etc/cliproxyapi.conf · OAuth tokens: ~/.cli-proxy-api/

Want the proxy to also serve Claude models (multi-account pooling, failover)? cliproxyapi -claude-login. Not needed for the Claude↔GPT switching above.

Uninstall

./uninstall.sh            # remove shell module + config, keep cliproxyapi & logins
./uninstall.sh --purge    # also uninstall cliproxyapi and delete OAuth tokens

Caveat

Routing a ChatGPT/Codex subscription through a third-party proxy to power a different harness sits in a gray area of the provider's Terms of Service. It's your machine and your account; use accordingly. This repo is not affiliated with Anthropic or OpenAI.

License

MIT

About

Run the Claude Code harness on non-Claude (OpenAI) models via a local CLIProxyAPI — while plain `claude` stays on Anthropic. Inspired by Theo's setup.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages