opencodex: Run Codex and Claude Code on Any LLM
opencodex is a local proxy that translates Codex’s Responses API into whatever protocol your LLM provider speaks. You can use Claude, Gemini, DeepSeek, Grok, GLM, Qwen, or even a local Ollama model inside Codex CLI, Codex App, and SDK — and in Claude Code too — without waiting for anyone to add official support.
Streaming, tool calls, reasoning tokens, image generation — everything works, in both directions.
npm install -g @bitkyc08/opencodex
ocx init
ocx startThree commands, and Codex is rerouted. It forwards your ChatGPT login by default; you can add more models anytime.
How It Works
Codex CLI / App / SDK ──/v1/responses──▶ opencodex ──▶ Any provider
│
Anthropic · xAI · Kimi · Google · DeepSeek · Groq · OpenRouter
Ollama Cloud · Azure · GLM · Mistral · Qwen · GitHub Copilot · Local Ollamaopencodex runs an HTTP service on localhost:10100. Codex requests hit this proxy first, which translates them into the target provider’s protocol. To Codex, it’s just an OpenAI-compatible endpoint; to downstream providers, the request format matches their native API.
Five adapters cover all major protocols:
| Adapter | Covers |
|---|---|
openai-responses | OpenAI Responses API passthrough |
openai-chat | OpenAI Chat Completions (and all compatible endpoints) |
anthropic | Anthropic Messages API |
google | Google Gemini (AI Studio / Vertex / Antigravity) |
azure-openai | Azure OpenAI |
One protocol layer handles 50+ providers.
Adding Third-Party Models
This is opencodex’s core value: plugging any model into Codex.
Method 1: OAuth Login (Recommended)
These 7 providers support OAuth login — no API key needed. Just log in with your existing account, and tokens auto-refresh:
ocx login xai # xAI Grok
ocx login anthropic # Anthropic Claude
ocx login kimi # Moonshot Kimi
ocx login kiro # Kiro
ocx login google-antigravity # Google Cloud Code Assist
ocx login cursor # Cursor (experimental)
ocx login github-copilot # GitHub Copilot (device-flow OAuth)After logging in, use them directly in Codex:
codex -m "anthropic/claude-opus-4-8" "Explain this stack trace"
codex -m "xai/grok-4.5" "Write a Rust HTTP server"
codex -m "cursor/gpt-5.6-sol" "Refactor this module"Method 2: API Key
For 40+ providers that use API keys. The easiest way is through the web dashboard:
ocx gui # Opens http://localhost:10100- Click “Add Provider”
- Pick one from the built-in provider list
- Paste your API key
- Models are auto-discovered from the provider’s
/v1/modelsendpoint — ready immediately
Full API-key provider list:
| Category | Providers |
|---|---|
| OpenAI | openai-apikey |
| Anthropic | anthropic-apikey |
google (Gemini), google-vertex (Vertex AI) | |
| Azure | azure-openai |
| OpenRouter | openrouter, orcarouter |
| Chinese LLMs | deepseek, zai (GLM), qwen-cloud, qianfan (Baidu), moonshot (Kimi API), kimi-code, minimax, minimax-cn, alibaba, alibaba-token-plan, alibaba-token-plan-intl |
| International | mistral, cerebras, together, fireworks, firepass, nvidia (NIM), groq |
| Gateways / Aggregators | openrouter, zenmux, litellm, vercel-ai-gateway, cloudflare-ai-gateway, cloudflare-workers-ai |
| Coding Assistants | github-copilot (OAuth also available), gitlab-duo, umans, opencode-go, neuralwatt |
| Others | ollama-cloud, huggingface, venice, nanogpt, synthetic, parallel, opencode-zen, opencode-free, xiaomi (MiMo), kilo, mimo-free |
You can also edit ~/.opencodex/config.json directly:
{
"port": 10100,
"defaultProvider": "deepseek",
"providers": {
"deepseek": {
"adapter": "openai-chat",
"baseUrl": "https://api.deepseek.com",
"apiKey": "${DEEPSEEK_API_KEY}",
"defaultModel": "deepseek-chat"
},
"openrouter": {
"adapter": "openai-chat",
"baseUrl": "https://openrouter.ai/api/v1",
"apiKey": "${OPENROUTER_API_KEY}"
}
}
}The ${ENV_VAR} syntax resolves at request time from environment variables — keys never land in the config file.
Method 3: Local Models
Ollama, vLLM, LM Studio — anything that exposes an OpenAI-compatible endpoint works:
{
"providers": {
"ollama": {
"adapter": "openai-chat",
"baseUrl": "http://localhost:11434/v1",
"apiKey": "",
"defaultModel": "qwen3:32b"
},
"vllm": {
"adapter": "openai-chat",
"baseUrl": "http://localhost:8000/v1",
"apiKey": "",
"defaultModel": "Qwen/Qwen3-32B"
}
}
}Method 4: Custom OpenAI-Compatible Endpoint
Any OpenAI Chat Completions-compatible endpoint works — just fill in baseUrl + apiKey. Choose Custom in the dashboard, or pick custom in ocx init and enter the base URL.
Once added, models appear in the Codex App model picker with per-model reasoning effort controls (low / medium / high / xhigh / max / ultra), right alongside native models.
Model Routing
Target any provider and model using provider/model syntax:
# Claude Opus via Anthropic
codex -m "anthropic/claude-opus-4-8" "Explain this stack trace"
# Gemini via Google
codex -m "google/gemini-3-pro" "Write unit tests for auth.ts"
# DeepSeek
codex -m "deepseek/deepseek-chat" "Write a SQL migration"
# Local Ollama model
codex -m "ollama/llama3" "Refactor this function"Omitting the provider/ prefix routes to the default provider, or auto-matches by model name pattern (claude-* → Anthropic, gpt-* → OpenAI).
Sub-Agent Delegation
opencodex lets you pin up to 5 models in Codex’s subagent picker — route complex tasks to a reasoning model and quick tasks to a cheap one:
{
"subagentModels": [
"anthropic/claude-opus-4-8",
"deepseek/deepseek-chat",
"google/gemini-3-pro"
]
}On the v2 multi-agent surface, the proxy auto-injects delegation guidance (preferred sub-agent model + effort level + model roster).
Sidecars: Web Search & Vision for Any Model
opencodex gives non-OpenAI models real web search and image understanding via a gpt-5.4-mini sidecar running on your ChatGPT login.
- Web Search Sidecar: When a routed model triggers a search, the request is forwarded to the sidecar for real web search, and results are fed back to the routed model
- Vision Sidecar: When a text-only model encounters an image, the sidecar describes it using
gpt-5.4-minibefore passing it to the routed model
Both sidecars support configurable on/off, backend (openai / anthropic), model, and per-turn call limits.
Claude Code Integration
The same proxy serves Claude Code too:
ocx claude [args...]This launches a fully wired Claude Code instance. Routed models appear in the native /model picker via claude-ocx-<provider>--<model> aliases. Your Claude Code OAuth login stays untouched.
ChatGPT Account Pool
If you have multiple ChatGPT / Codex accounts, opencodex manages them as a pool:
- Existing threads keep affinity: Thread IDs bind to an account and persist across turns — long sessions won’t break
- New sessions auto-route: Compares 5-hour / weekly / 30-day quotas, picks the lowest-usage healthy account
- One-click quota refresh: From the Codex Auth page in the dashboard
- 429 auto cooldown + failover: Quota exhaustion doesn’t hard-fail
Background Service + Clean Exit
ocx service install # Install as system service, auto-starts at login (launchd / systemd / Task Scheduler)
ocx codex-shim install # On-demand: auto-starts proxy whenever codex runs
ocx stop # Stop proxy, restore native Codex config
ocx uninstall # Full uninstallAfter ocx stop, plain codex works exactly as it did before — zero residue.
Remote Access
Binds to 127.0.0.1 by default. To expose on LAN, set a token:
export OPENCODEX_API_AUTH_TOKEN="your-secret-token"
ocx startClients must include x-opencodex-api-key: your-secret-token in every request. Token comparison uses constant time to prevent timing attacks.
Summary
opencodex breaks the “Codex only runs OpenAI” lock-in. The onboarding cost is near zero — OAuth login with one command, API key paste-and-go, local models with just a baseUrl. For engineers already using Codex CLI or Claude Code daily, installing it means you can pick the best model for each task instead of being tied to a single provider.
MIT licensed, independent community project, not affiliated with OpenAI or Anthropic.
If you feel that this article has been helpful to you, your appreciation would be greatly welcomed.
Sponsor