Codex CLI is Powerful, But You Can't Use It
OpenAI's Codex CLI is one of the most powerful terminal AI coding assistants—automatically reading code, modifying code, running tests, fixing bugs, all within a closed terminal loop.
But there's a fatal barrier: it only recognizes OpenAI's Responses API.
This means you must have an OpenAI API Key, must use GPT-4o / o3 models, and must endure US billing. Developers in China? Sorry, without an API Key you can only watch.
Until codex-proxy came along.
codex-proxy: Local Protocol Translator
codex-proxy does something simple—starts a local proxy that translates Codex CLI's Responses API requests into a format your model provider can understand:
- Chat Completions compatible: DeepSeek, Qwen, Moonshot, Ollama, vLLM, LocalAI…
- Anthropic Messages compatible: Claude, Baichuan, etc.
Install with one command, configure two environment variables, any model can drive Codex CLI.
Codex CLI → /v1/responses → codex-proxy → /v1/chat/completions → DeepSeek / Claude / ...
2 Minutes to Get Started
1. Install
npm install -g @lininn/codex-proxy
2. Configure Provider
codex-proxy --web
Browser automatically opens the configuration page, fill in three things:
| Field | Description |
|---|---|
| Base URL | Upstream API address, e.g., https://api.deepseek.com/v1 |
| API Key | Your DeepSeek / Claude / other provider's Key |
| Default Model | Model name, e.g., deepseek-chat, claude-sonnet-4-5 |
Save, restart the proxy. Web page supports dark mode, API key is masked, configuration is stored locally in ~/.codexproxy/config.json, no data is uploaded.
3. Start Proxy + Connect Codex CLI
# Start proxy (background run)
codex-proxy start
# Point Codex CLI to local proxy
export OPENAI_BASE_URL=http://127.0.0.1:8080/v1
export OPENAI_API_KEY=local-placeholder
# Start Codex CLI
codex
Done. Now every request from Codex CLI goes through your model.
Popular Scenarios
Scenario 1: Drive Codex CLI with DeepSeek, Cost Reduced by 90%
DeepSeek API pricing is about 1/10 of GPT-4o. Configuration as follows:
{
"port": 8080,
"defaultProvider": "deepseek",
"providers": [
{
"providerType": "chat",
"name": "deepseek",
"baseUrl": "https://api.deepseek.com/v1",
"apiKey": "YOUR_DEEPSEEK_KEY",
"defaultModel": "deepseek-chat"
}
]
}
Effect: Codex CLI fully functional—auto programming, file operations, command execution—monthly API cost may be less than a cup of coffee.
Scenario 2: Drive Codex CLI with Claude
Claude's coding ability is on par with GPT-4o, and even better in some scenarios:
{
"providerType": "anthropic",
"name": "claude",
"baseUrl": "https://api.anthropic.com/v1",
"apiKey": "YOUR_ANTHROPIC_KEY",
"defaultModel": "claude-sonnet-4-5"
}
codex-proxy automatically translates the Responses protocol to the Anthropic Messages protocol, including streaming output and Tool Use.
Scenario 3: Local Models, Zero Cost
Run local models with Ollama / vLLM, completely offline:
{
"providerType": "chat",
"name": "ollama",
"baseUrl": "http://127.0.0.1:11434/v1",
"apiKey": "ollama",
"defaultModel": "qwen2.5-coder:32b"
}
Zero API cost, zero data leakage. Ideal for enterprise intranet scenarios.
Scenario 4: Multiple Providers Freely Switchable
Configure multiple providers, switch with one click on the web page:
{
"providers": [
{ "providerType": "chat", "name": "deepseek", "baseUrl": "https://api.deepseek.com/v1", "apiKey": "sk-xxx", "defaultModel": "deepseek-chat" },
{ "providerType": "anthropic", "name": "claude", "baseUrl": "https://api.anthropic.com/v1", "apiKey": "sk-xxx", "defaultModel": "claude-sonnet-4-5" },
{ "providerType": "chat", "name": "moonshot", "baseUrl": "https://api.moonshot.cn/v1", "apiKey": "sk-xxx", "defaultModel": "moonshot-v1-128k" },
{ "providerType": "chat", "name": "ollama", "baseUrl": "http://127.0.0.1:11434/v1", "apiKey": "ollama", "defaultModel": "qwen2.5-coder:32b" }
]
}
Use DeepSeek for coding, Claude for complex architecture, Ollama when offline—the same Codex CLI, switch brains anytime.
Technical Highlights
Not just simple request forwarding, but complete protocol translation:
| Capability | Description |
|---|---|
| Request Translation | Responses → Chat Completions / Anthropic Messages |
| Response Translation | Bidirectional conversion, including Tool Use (function_call) |
| Streaming Support | SSE events translated frame by frame, real-time output without lag |
| Image Support | input_image correctly converted between the two protocols |
| System Prompt | instructions / developer role correctly mapped |
Core translation logic is about 500 lines of TypeScript, zero external AI dependencies, pure field mapping + protocol conversion, stable and predictable.
Quick Command Reference
codex-proxy start # Start in background
codex-proxy start -p 8080 # Specify port
codex-proxy stop # Stop
codex-proxy restart # Restart (reload config)
codex-proxy --web # Open web config page
codex-proxy config # View config file path
Security Notes
- Proxy only listens on
127.0.0.1, not exposed to the internet - API Key is stored locally in
~/.codexproxy/config.json, not uploaded to any server - Web config page masks API Key
- Custom config directory via
CODEXPROXY_HOME
Why Did This Become Popular?
- Strong pain point: Codex CLI only recognizes OpenAI, Chinese developers are locked out
- Simple solution: one
npm install, two environment variables, done in 2 minutes - Very low cost: DeepSeek price is 1/10 of GPT-4o, even zero cost with local models
- Wide coverage: Chat Completions + Anthropic Messages two major protocols, covering almost all mainstream models
- Excellent privacy: pure local proxy, Key never leaves the machine, enterprise can deploy on intranet
Quick Start
# 1. Install
npm install -g @lininn/codex-proxy
# 2. Configure
codex-proxy --web
# 3. Start
codex-proxy start
# 4. Use
export OPENAI_BASE_URL=http://127.0.0.1:8080/v1
export OPENAI_API_KEY=local-placeholder
codex
GitHub: lininn/codex-proxy npm: @lininn/codex-proxy
If you're also using Codex CLI but limited by OpenAI API, codex-proxy is the key. Star it, let more people see it.
暂无评论。