|
1 | | -# opencodex (ocx) |
| 1 | +# opencodex (`ocx`) |
2 | 2 |
|
3 | | -Universal provider proxy for [OpenAI Codex](https://openai.com/codex) — use **any LLM** with Codex CLI, App, and SDK. |
| 3 | +**Universal provider proxy for [OpenAI Codex](https://openai.com/codex) — use any LLM with Codex CLI, App, and SDK.** |
4 | 4 |
|
5 | | -Codex only speaks the Responses API (`/v1/responses`). opencodex sits between Codex and your LLM provider, translating protocols on the fly. |
| 5 | +📖 **[Full documentation →](https://lidge-jun.github.io/opencodex/)** |
| 6 | + |
| 7 | +Codex only speaks the Responses API (`/v1/responses`). opencodex sits between Codex and your LLM |
| 8 | +provider, translating the protocol on the fly — streaming, tool calls, reasoning, and images included |
| 9 | +— in both directions. |
6 | 10 |
|
7 | 11 | ``` |
8 | | -Codex CLI/App/SDK → /v1/responses → opencodex → Any Provider |
9 | | - ↓ |
10 | | - Anthropic · Google · OpenRouter |
11 | | - Groq · Ollama · Azure · OpenAI |
| 12 | +Codex CLI / App / SDK ──/v1/responses──▶ opencodex ──▶ Any provider |
| 13 | + │ |
| 14 | + Anthropic · Google · xAI · Kimi · Ollama Cloud · Groq |
| 15 | + OpenRouter · Azure · DeepSeek · GLM · …and OpenAI itself |
12 | 16 | ``` |
13 | 17 |
|
14 | | -## Quick Start |
| 18 | +## Quick start |
15 | 19 |
|
16 | 20 | ```bash |
17 | 21 | # Install |
18 | | -bun install -g opencodex |
| 22 | +bun install -g opencodex # or: npm install -g opencodex |
19 | 23 |
|
20 | | -# Interactive setup (creates config + injects into Codex) |
| 24 | +# Interactive setup (writes config + injects into Codex) |
21 | 25 | ocx init |
22 | 26 |
|
23 | 27 | # Start the proxy |
24 | 28 | ocx start |
25 | 29 |
|
26 | | -# Use Codex normally — it routes through opencodex |
27 | | -codex "Write a hello world in Python" |
| 30 | +# Use Codex normally — it now routes through opencodex |
| 31 | +codex "Write a hello world in Rust" |
28 | 32 | ``` |
29 | 33 |
|
30 | | -## Supported Providers |
| 34 | +Target a specific routed model with the `provider/model` form: |
31 | 35 |
|
32 | | -| Provider | Adapter | Protocol | |
33 | | -|----------|---------|----------| |
34 | | -| OpenAI | `openai-responses` | Responses API (passthrough) | |
35 | | -| Anthropic | `anthropic` | Messages API | |
36 | | -| Google Gemini | `google` | Generative AI REST | |
37 | | -| Azure OpenAI | `azure-openai` | Responses API + Azure auth | |
38 | | -| OpenCode Go | `openai-chat` | Chat Completions | |
39 | | -| OpenRouter | `openai-chat` | Chat Completions | |
40 | | -| Groq | `openai-chat` | Chat Completions | |
41 | | -| Ollama | `openai-chat` | Chat Completions | |
42 | | -| LM Studio | `openai-chat` | Chat Completions | |
43 | | -| vLLM | `openai-chat` | Chat Completions | |
44 | | -| Any OpenAI-compatible | `openai-chat` | Chat Completions | |
| 36 | +```bash |
| 37 | +codex -m "anthropic/claude-opus-4-8" "Explain this stack trace" |
| 38 | +codex -m "ollama-cloud/glm-5.2" "Write a SQL migration" |
| 39 | +``` |
45 | 40 |
|
46 | | -## CLI Commands |
| 41 | +## Highlights |
| 42 | + |
| 43 | +- **Five adapters** cover Anthropic Messages, Google Gemini, Azure, the OpenAI Responses passthrough, |
| 44 | + and **every OpenAI-compatible Chat Completions** endpoint. |
| 45 | +- **OAuth, API key, or ChatGPT forward.** Log in with your xAI / Anthropic / Kimi account (tokens |
| 46 | + auto-refresh), forward your `codex login`, or paste a key (`${ENV_VARS}` supported). An 18-provider |
| 47 | + API-key catalog (incl. **Ollama Cloud**) is built in. |
| 48 | +- **Drops into Codex.** Injects a `[model_providers.opencodex]` table into `~/.codex/config.toml` and |
| 49 | + merges routed models into Codex's catalog and subagent picker — fully reversible. |
| 50 | +- **Sidecars.** Give non-OpenAI models real **web search** and **image understanding** via a |
| 51 | + `gpt-5.4-mini` over your ChatGPT login. |
| 52 | +- **Web dashboard** for providers, OAuth login, model selection, and request logs. |
| 53 | + |
| 54 | +## Providers & adapters |
| 55 | + |
| 56 | +| Provider | Adapter | Auth | |
| 57 | +|---|---|---| |
| 58 | +| OpenAI (ChatGPT login) | `openai-responses` | forward (no key) | |
| 59 | +| OpenAI (API key) | `openai-responses` | key | |
| 60 | +| Anthropic Claude | `anthropic` | oauth / key | |
| 61 | +| xAI Grok | `openai-chat` | oauth / key | |
| 62 | +| Kimi (Moonshot) | `openai-chat` | oauth / key | |
| 63 | +| Google Gemini | `google` | key | |
| 64 | +| Azure OpenAI | `azure` | key | |
| 65 | +| Ollama Cloud + 17-provider catalog | `openai-chat` | key | |
| 66 | +| Ollama / vLLM / LM Studio (local) | `openai-chat` | key (usually blank) | |
| 67 | +| Any OpenAI-compatible endpoint | `openai-chat` | key | |
| 68 | + |
| 69 | +## CLI |
47 | 70 |
|
48 | 71 | ```bash |
49 | | -ocx init # Interactive setup |
50 | | -ocx start [--port 10100] # Start proxy |
51 | | -ocx stop # Stop proxy |
52 | | -ocx status # Check proxy status |
53 | | -ocx gui # Open web dashboard |
| 72 | +ocx init # interactive setup |
| 73 | +ocx start [--port 10100] # start the proxy |
| 74 | +ocx stop # stop + restore native Codex |
| 75 | +ocx restore # restore without stopping (alias: ocx eject) |
| 76 | +ocx sync # refresh models + re-inject into Codex |
| 77 | +ocx status # is the proxy running? |
| 78 | +ocx login <xai|anthropic|kimi> # OAuth login |
| 79 | +ocx logout <provider> # remove a stored login |
| 80 | +ocx gui # open the web dashboard |
| 81 | +ocx service <install|start|stop|status|uninstall> # run as a background service |
54 | 82 | ``` |
55 | 83 |
|
56 | 84 | ## Configuration |
57 | 85 |
|
58 | | -Config lives at `~/.opencodex/config.json`: |
| 86 | +Config lives at `~/.opencodex/config.json`. Minimal example: |
59 | 87 |
|
60 | 88 | ```json |
61 | 89 | { |
62 | 90 | "port": 10100, |
| 91 | + "defaultProvider": "anthropic", |
63 | 92 | "providers": { |
64 | 93 | "anthropic": { |
65 | 94 | "adapter": "anthropic", |
66 | 95 | "baseUrl": "https://api.anthropic.com", |
67 | | - "apiKey": "sk-ant-...", |
68 | | - "defaultModel": "claude-sonnet-4-20250514" |
| 96 | + "authMode": "oauth", |
| 97 | + "defaultModel": "claude-sonnet-4-6" |
69 | 98 | }, |
70 | | - "opencode-go": { |
| 99 | + "ollama-cloud": { |
71 | 100 | "adapter": "openai-chat", |
72 | | - "baseUrl": "https://opencode.ai/zen/go/v1", |
73 | | - "apiKey": "sk-...", |
74 | | - "defaultModel": "kimi-k2.5" |
| 101 | + "baseUrl": "https://ollama.com/v1", |
| 102 | + "apiKey": "${OLLAMA_API_KEY}", |
| 103 | + "defaultModel": "glm-5.2" |
75 | 104 | } |
76 | | - }, |
77 | | - "defaultProvider": "anthropic" |
| 105 | + } |
78 | 106 | } |
79 | 107 | ``` |
80 | 108 |
|
81 | | -`ocx init` automatically adds to your Codex config: |
82 | | - |
83 | | -```toml |
84 | | -# ~/.codex/config.toml |
85 | | -model_provider = "opencodex" |
86 | | - |
87 | | -[model_providers.opencodex] |
88 | | -base_url = "http://localhost:10100/v1" |
89 | | -wire_api = "responses" |
90 | | -``` |
91 | | - |
92 | | -## Model Routing |
93 | | - |
94 | | -opencodex automatically routes models to the right provider: |
| 109 | +See the **[Configuration reference](https://lidge-jun.github.io/opencodex/reference/configuration/)** |
| 110 | +for every field. |
95 | 111 |
|
96 | | -- `claude-*` → `anthropic` adapter |
97 | | -- `gpt-*`, `o1-*`, `o3-*` → `openai` adapter |
98 | | -- `gemini-*` → `google` adapter |
99 | | -- Other models → default provider |
| 112 | +## Documentation |
100 | 113 |
|
101 | | -## Web Dashboard |
102 | | - |
103 | | -```bash |
104 | | -# Start proxy first |
105 | | -ocx start |
106 | | - |
107 | | -# In another terminal, start the GUI dev server |
108 | | -cd gui && bun dev |
109 | | -``` |
110 | | - |
111 | | -Dashboard features: |
112 | | -- Real-time proxy status and uptime |
113 | | -- Provider management (add/edit/remove) |
114 | | -- Request log viewer with auto-refresh |
115 | | - |
116 | | -## Architecture |
117 | | - |
118 | | -``` |
119 | | -src/ |
120 | | -├── cli.ts # CLI entry (ocx command) |
121 | | -├── server.ts # Bun.serve + routing + management API |
122 | | -├── router.ts # Model → provider routing |
123 | | -├── config.ts # Config management + PID |
124 | | -├── bridge.ts # AdapterEvent → Responses SSE |
125 | | -├── init.ts # Interactive setup |
126 | | -├── codex-inject.ts # Codex config.toml injection |
127 | | -├── types.ts # Core types |
128 | | -├── responses/ |
129 | | -│ ├── parser.ts # Responses API → internal context |
130 | | -│ └── schema.ts # Zod validation schemas |
131 | | -└── adapters/ |
132 | | - ├── base.ts # Adapter interface |
133 | | - ├── openai-chat.ts # Chat Completions (Tier 1) |
134 | | - ├── anthropic.ts # Anthropic Messages |
135 | | - ├── google.ts # Google Generative AI |
136 | | - ├── azure.ts # Azure OpenAI |
137 | | - └── openai-responses.ts # Passthrough |
138 | | -``` |
| 114 | +The full developer documentation — architecture, every adapter, the request lifecycle, the sidecars, |
| 115 | +Codex integration, and the CLI/config reference — is an Astro site under [`docs-site/`](./docs-site) |
| 116 | +and published to **[lidge-jun.github.io/opencodex](https://lidge-jun.github.io/opencodex/)**. |
139 | 117 |
|
140 | 118 | ## Development |
141 | 119 |
|
142 | 120 | ```bash |
143 | | -git clone https://github.com/user/opencodex.git |
| 121 | +git clone https://github.com/lidge-jun/opencodex.git |
144 | 122 | cd opencodex |
145 | 123 | bun install |
146 | | -bun run dev # Start proxy in dev mode |
| 124 | +bun run dev # start the proxy in dev mode |
| 125 | +bun x tsc --noEmit # typecheck |
147 | 126 | ``` |
148 | 127 |
|
| 128 | +See **[Contributing](https://lidge-jun.github.io/opencodex/contributing/)**. |
| 129 | + |
149 | 130 | ## License |
150 | 131 |
|
151 | 132 | MIT |
0 commit comments