Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# claude-code-proxy

Claude Code, powered by **OpenAI Codex**, **Kimi**, **Grok**, or **Cursor
Agent**.
Claude Code, powered by **OpenAI Codex**, **Kimi**, **Grok**, **OpenCode Go**,
or **Cursor Agent**.

Docs: <https://claude-code-proxy.raine.dev>

Expand Down Expand Up @@ -88,6 +88,7 @@ The opt-in Images API returns base64 image data and consumes the signed-in accou
| Codex | ChatGPT Plus or Pro | Registered `gpt-*` models and `-fast` variants |
| Kimi | kimi.com with Kimi Code access | `kimi-for-coding` and aliases |
| Grok | grok.com | Registered Grok models |
| OpenCode Go | OpenCode Go subscription | Non-conflicting IDs and `opencode-go/<model-id>` |
| Cursor Agent | Cursor account | Cursor aliases and `cursor:<model-id>` prefixes |

Run `claude-code-proxy models` for the current catalog or
Expand Down
3 changes: 2 additions & 1 deletion docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
integrations: [
starlight({
title: 'claude-code-proxy',
description: 'Run Claude Code with Codex, Kimi, Grok, or Cursor Agent.',
description: 'Run Claude Code with Codex, Kimi, Grok, OpenCode Go, or Cursor Agent.',
plugins: [starlightLlmsTxt()],
favicon: '/favicon.svg',
head: [
Expand Down Expand Up @@ -47,6 +47,7 @@ export default defineConfig({
{ label: 'Codex', slug: 'providers/codex' },
{ label: 'Kimi', slug: 'providers/kimi' },
{ label: 'Grok', slug: 'providers/grok' },
{ label: 'OpenCode Go', slug: 'providers/opencode-go' },
{ label: 'Cursor Agent', slug: 'providers/cursor-agent' },
],
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Getting started
description: Install claude-code-proxy, authenticate with Codex, start the server, and open one working Claude Code session.
---

This path gets one Codex-backed Claude Code session working. See [Choosing a provider](/providers/choosing-a-provider/) for Kimi, Grok, and Cursor Agent.
This path gets one Codex-backed Claude Code session working. See [Choosing a provider](/providers/choosing-a-provider/) for Kimi, Grok, OpenCode Go, and Cursor Agent.

## 1. Install

Expand Down
8 changes: 4 additions & 4 deletions docs/src/content/docs/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ claude-code-proxy exposes Anthropic Messages and optional OpenAI-compatible rout
<div class="route-arrow" aria-hidden="true">→</div>
<div class="route-node"><strong>Proxy pipeline</strong><span>route model<br/>refresh auth<br/>translate events</span></div>
<div class="route-arrow" aria-hidden="true">→</div>
<div class="route-node provider-stack"><code>Codex Responses</code><code>Kimi Chat Completions</code><code>Grok Responses</code><code>Cursor Connect</code></div>
<div class="route-node provider-stack"><code>Codex Responses</code><code>Kimi Chat Completions</code><code>Grok Responses</code><code>OpenCode Chat / Messages / Responses</code><code>Cursor Connect</code></div>
</div>

## Anthropic requests
Expand All @@ -25,17 +25,17 @@ claude-code-proxy exposes Anthropic Messages and optional OpenAI-compatible rout

## OpenAI-compatible requests

Enable the OpenAI routes to use `/v1/chat/completions` or `/v1/responses`. The `model` field chooses Codex, Kimi, Grok, or Cursor in the same way it does on `/v1/messages`.
Enable the OpenAI routes to use `/v1/chat/completions` or `/v1/responses`. The `model` field chooses Codex, Kimi, Grok, OpenCode Go, or Cursor in the same way it does on `/v1/messages`.

Codex Responses requests go directly to the native Codex API. The proxy translates other OpenAI requests to the selected provider and returns either Chat Completions or Responses output. Streaming and non-streaming requests use the same translation rules, and unsupported fields return an error instead of being ignored.

## Authentication boundary

Each provider login belongs to claude-code-proxy. The proxy does not read native Codex, Grok, or Cursor Agent credentials. Credentials live in the platform credential store described in [Files and storage](/reference/files-and-storage/). Incoming `ANTHROPIC_AUTH_TOKEN` values are accepted for client compatibility and are not used as upstream credentials.
Each provider login belongs to claude-code-proxy. The proxy does not read native Codex, Grok, or Cursor Agent credentials. Credentials live in the platform credential store described in [Files and storage](/reference/files-and-storage/). OpenCode Go instead uses the configured subscription API key. Incoming `ANTHROPIC_AUTH_TOKEN` values are accepted for client compatibility and are not used as upstream credentials.

## Routing boundary

Routing happens per request, not per server process or API surface. Codex IDs, Kimi IDs, Grok IDs, Cursor prefixes, and configured Anthropic-style aliases can share one listener across `/v1/messages`, `/v1/chat/completions`, and `/v1/responses`. Unknown model IDs return HTTP 400 with the supported catalog.
Routing happens per request, not per server process or API surface. Codex IDs, Kimi IDs, Grok IDs, OpenCode Go IDs, Cursor prefixes, and configured Anthropic-style aliases can share one listener across `/v1/messages`, `/v1/chat/completions`, and `/v1/responses`. Unknown model IDs return HTTP 400 with the supported catalog.

## Session state

Expand Down
8 changes: 4 additions & 4 deletions docs/src/content/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: What is claude-code-proxy?
description: Run Claude Code with Codex, Kimi, Grok, or Cursor Agent through one local Anthropic-compatible proxy.
description: Run Claude Code with Codex, Kimi, Grok, OpenCode Go, or Cursor Agent through one local Anthropic-compatible proxy.
---

<div class="hero-copy">
claude-code-proxy lets you use Claude Code with Codex, Kimi, Grok, or Cursor Agent. Start one local app, choose a model, and keep working in the Claude Code interface you already know.
claude-code-proxy lets you use Claude Code with Codex, Kimi, Grok, OpenCode Go, or Cursor Agent. Start one local app, choose a model, and keep working in the Claude Code interface you already know.
</div>

<div class="route-rail" aria-label="Claude Code connects through the proxy to a supported provider">
Expand All @@ -21,7 +21,7 @@ claude-code-proxy lets you use Claude Code with Codex, Kimi, Grok, or Cursor Age
<div class="route-connector" aria-hidden="true"><span>→</span></div>
<div class="route-node route-providers">
<span class="route-kicker">Supported providers</span>
<div class="provider-stack"><span>Codex</span><span>Kimi</span><span>Grok</span><span>Cursor Agent</span></div>
<div class="provider-stack"><span>Codex</span><span>Kimi</span><span>Grok</span><span>OpenCode Go</span><span>Cursor Agent</span></div>
</div>
</div>

Expand All @@ -30,7 +30,7 @@ claude-code-proxy lets you use Claude Code with Codex, Kimi, Grok, or Cursor Age
- **Keep the Claude Code experience.** Skills, tools, hooks, subagents, IDE integrations, and the terminal interface stay on the client side.
- **Use subscription-backed providers.** Authenticate with supported consumer accounts instead of putting provider API keys into Claude Code.
- **Switch providers by model.** A single proxy process routes every request from its model ID.
- **Use Claude Code normally.** Tools, images, streaming responses, and reasoning work across supported providers.
- **Use Claude Code normally.** Tools and streaming are translated across providers; images and reasoning depend on the selected provider and model.
- **See what is happening.** The monitor TUI shows sessions, requests, errors, models, token use, and throughput. Structured logs and optional traffic captures support deeper diagnosis.

![Claude Code running through claude-code-proxy](/claude-code-screenshot.webp)
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/providers/choosing-a-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ One `serve` process supports every provider. Choose based on the account you hav
| [Codex](/providers/codex/) | ChatGPT Plus or Pro | OpenAI Responses over WebSocket or HTTP SSE | Named Codex catalog, `-fast` variants | Function tools, image input, hosted web search, reasoning summaries, optional native Responses route |
| [Kimi](/providers/kimi/) | kimi.com with Kimi Code access | OpenAI-style chat completions | `kimi-for-coding` and aliases | Function tools, reasoning, image and video input |
| [Grok](/providers/grok/) | grok.com | Responses API | `grok-composer-2.5-fast`, `grok-4.5` | Function tools, reasoning, web search, X search, citations |
| [OpenCode Go](/providers/opencode-go/) | OpenCode Go subscription | OpenAI-compatible Chat Completions, OpenAI Responses, or Anthropic-compatible Messages | Non-conflicting bare IDs and `opencode-go/<model-id>` forms | Curated models tested and benchmarked for coding-agent use |
| [Cursor Agent](/providers/cursor-agent/) | Cursor account | HTTP/2 Connect stream | Cursor modes and `cursor:<model-id>` prefixes | Dynamic model catalog, effort variants, images, plan and ask modes, session continuation |

## Practical guidance

- Start with **Codex** when you have a ChatGPT subscription and want the most developed Claude Code translation path.
- Choose **Kimi** for the Kimi Code model and multimodal coding input.
- Choose **Grok** for Grok models and hosted web or X search.
- Choose **OpenCode Go** when you have a Go subscription and want its documented model catalog in Claude Code.
- Choose **Cursor Agent** when you want Cursor's model catalog and agent modes. It depends on an installed Cursor Agent bundle for protobuf schemas.

## Shared behavior
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/providers/codex.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ While the native request is active, the monitor shows `compacting`. Structured l

## OpenAI-compatible APIs

`CCP_CODEX_RESPONSES_API=1` enables both `POST /v1/responses` and `POST /v1/chat/completions`. The setting is under Codex configuration, but the routes also accept Kimi, Grok, and Cursor models.
`CCP_CODEX_RESPONSES_API=1` enables both `POST /v1/responses` and `POST /v1/chat/completions`. The setting is under Codex configuration, but the routes also accept Kimi, Grok, OpenCode Go, and Cursor models.

The Responses route preserves native JSON or SSE response bodies for registered Codex models. The Chat Completions route translates standard text messages, reasoning effort, JSON object or JSON Schema output, and buffered or streaming responses. Its omitted reasoning effort defaults to `medium`; the proxy-wide Codex effort override still takes precedence.

Expand Down
62 changes: 62 additions & 0 deletions docs/src/content/docs/providers/opencode-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: OpenCode Go
description: Configure an OpenCode Go API key, model routing, streaming, tools, and provider overrides.
---

OpenCode Go uses the API at `https://opencode.ai/zen/go/v1`. Its catalog spans
OpenAI-compatible chat completions, Anthropic-compatible messages, and OpenAI
Responses; the proxy selects the wire protocol for each registered model. The
registered mapping follows the [official OpenCode Go endpoint table](https://opencode.ai/docs/go/#endpoints).

## Account and authentication

Subscribe to OpenCode Go, copy your API key, and provide it to the proxy:

```sh
export OPENCODE_API_KEY=YOUR_OPENCODE_GO_API_KEY
claude-code-proxy serve
```

`CCP_OPENCODE_API_KEY` takes precedence over `OPENCODE_API_KEY`. The
`opencode.apiKey` configuration key is also supported. The proxy does not
implement an OpenCode login flow.

## Models

Run `claude-code-proxy models` for the statically registered catalog based on
OpenCode's documented endpoint table. Every registered model has a
provider-qualified form. Bare IDs are also accepted when they do not belong to
another provider:

```sh
ANTHROPIC_MODEL=opencode-go/glm-5.2 \
ANTHROPIC_SMALL_FAST_MODEL=opencode-go/glm-5.2 \
claude --model opencode-go/glm-5.2
```

The bare IDs `gpt-5.6-luna`, `grok-4.5`, `kimi-k3`, and `kimi-k2.6` remain
owned by the existing Codex, Grok, or Kimi providers. Prefix those IDs with
`opencode-go/` to select the OpenCode Go version.

## Tools and streaming

Claude function definitions, tool choices, tool calls, and tool results are
translated for chat-completions models. Tool-call argument fragments are
streamed incrementally and reassembled into Anthropic `tool_use` blocks.
Upstream tool behavior remains model-dependent.

Models served through the Anthropic-compatible endpoint retain their native
messages stream. GPT 5.6 Luna uses OpenCode Go's Responses endpoint and is
translated to the same Anthropic event stream as other providers. The proxy
handles `/v1/messages/count_tokens` locally and does not send that request to
OpenCode Go.

## Configuration

- `CCP_OPENCODE_API_KEY`, `OPENCODE_API_KEY`, or `opencode.apiKey` supplies the key.
- `CCP_OPENCODE_BASE_URL` or `opencode.baseUrl` changes the API base URL.

OpenCode Go may expose additional model IDs through `/models`, but the proxy
registers only models whose wire protocol is documented. Unknown IDs are
rejected locally. Access or usage-limit errors for registered models are
surfaced from OpenCode.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ claude-code-proxy targets Claude Code's practical Anthropic API usage rather tha

## OpenAI API scope

- `CCP_CODEX_RESPONSES_API=1` enables `/v1/chat/completions` and `/v1/responses` for Codex, Kimi, Grok, and Cursor models.
- Codex Responses requests use native passthrough. Requests for the other providers support text, reasoning, function tools, tool results, token limits, usage, streaming, aliases, and `[1m]` model hints.
- `CCP_CODEX_RESPONSES_API=1` enables `/v1/chat/completions` and `/v1/responses` for Codex, Kimi, Grok, OpenCode Go, and Cursor models.
- Codex Responses requests use native passthrough. Requests for the other providers support their mapped subsets of text, reasoning, function tools, tool results, token limits, usage, streaming, aliases, and `[1m]` model hints; exact support depends on the selected provider and model.
- Unsupported non-null request fields return an error instead of being ignored.
- Grok search calls appear as Responses `web_search_call` items. Chat Completions returns the citations without a separate search item.
- Cursor tool bridging supports `Read`, `Write`, and `Bash`. It requires streaming and a stable session ID.
Expand Down
12 changes: 12 additions & 0 deletions docs/src/content/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ These settings configure the proxy process. Claude Code client settings such as
"baseUrl": "https://cli-chat-proxy.grok.com/v1",
"clientVersion": "0.2.93"
},
"opencode": {
"apiKey": "YOUR_OPENCODE_GO_API_KEY",
"baseUrl": "https://opencode.ai/zen/go/v1"
},
"cursor": {
"baseUrl": "https://api2.cursor.sh",
"clientVersion": "0.48.5",
Expand Down Expand Up @@ -130,6 +134,14 @@ Proxy URLs may use `http`, `https`, `socks4`, `socks4a`, `socks5`, or `socks5h`.
| `CCP_GROK_CLIENT_VERSION` | `grok.clientVersion` | `0.2.93` | Changes the Grok client version header. |
| `CCP_GROK_TOOL_IMAGE` | none | `omit` | Selects `omit`, `reattach`, `inline`, or `reject` image handling. |

## OpenCode Go

| Environment | Config key | Default | Purpose |
| --- | --- | --- | --- |
| `CCP_OPENCODE_API_KEY` | `opencode.apiKey` | unset | OpenCode Go API key; takes precedence over `OPENCODE_API_KEY` and config. |
| `OPENCODE_API_KEY` | `opencode.apiKey` | unset | Fallback API-key variable accepted by the proxy when the CCP-specific variable is unset. |
| `CCP_OPENCODE_BASE_URL` | `opencode.baseUrl` | `https://opencode.ai/zen/go/v1` | Changes the OpenCode Go API base URL. |

## Cursor Agent

| Environment | Config key | Default | Purpose |
Expand Down
9 changes: 8 additions & 1 deletion docs/src/content/docs/reference/files-and-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ On macOS, Codex and Cursor use Keychain services:

Kimi and Grok use `<configuration-root>/<provider>/auth.json` on every platform. Codex and Cursor use the same file layout on Linux and Windows. File-backed credentials are written with restrictive permissions where supported.

When `CCP_CONFIG_DIR` is set, every provider uses `<CCP_CONFIG_DIR>/<provider>/auth.json`, including Codex and Cursor on macOS. `CCP_CURSOR_AUTH_TOKEN` bypasses Cursor's local credential store for that process.
When `CCP_CONFIG_DIR` is set, file-backed provider credentials use
`<CCP_CONFIG_DIR>/<provider>/auth.json`, including Codex and Cursor on macOS.
`CCP_CURSOR_AUTH_TOKEN` bypasses Cursor's local credential store for that
process.

OpenCode Go is the exception: it reads its API key from
`CCP_OPENCODE_API_KEY`, `OPENCODE_API_KEY`, or `opencode.apiKey` in
`config.json` and does not create a provider auth store.

The proxy owns these credentials independently of native Codex, Grok, and Cursor Agent stores.

Expand Down
12 changes: 6 additions & 6 deletions docs/src/content/docs/reference/http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: HTTP API
description: Local routes for health checks, Anthropic Messages, token counts, model discovery, OpenAI-compatible requests, and Codex images.
---

The server exposes the Anthropic and OpenAI routes supported by the proxy. Each route uses the stored login for the model's provider.
The server exposes the Anthropic and OpenAI routes supported by the proxy. Each route uses the configured provider credential for the selected model.

<div class="security-callout">
<strong>No client authentication.</strong> The listener accepts requests without validating `Authorization` or `x-api-key`. Loopback is the default. Protect every non-loopback listener with a firewall or authenticating reverse proxy.
Expand Down Expand Up @@ -37,7 +37,7 @@ Accepts the same basic Anthropic request shape and returns:
{"input_tokens":1234}
```

Codex tokenizes text locally with `o200k_base` and adds estimates for images, encrypted reasoning, and protocol framing. Kimi and Grok use local text heuristics, while Cursor estimates the rendered prompt from its character length. Counts support Claude Code compaction behavior and are estimates rather than provider billing values.
Codex tokenizes text locally with `o200k_base` and adds estimates for images, encrypted reasoning, and protocol framing. Kimi, Grok, and OpenCode Go use local text heuristics, while Cursor estimates the rendered prompt from its character length. Counts support Claude Code compaction behavior and are estimates rather than provider billing values.

## `GET /v1/models`

Expand All @@ -64,15 +64,15 @@ Claude Code gateway discovery filters IDs according to its own model rules. See

## `POST /v1/chat/completions`

Enable this route with `CCP_CODEX_RESPONSES_API=1` or `codex.responsesApi: true`. The `model` field selects Codex, Kimi, Grok, or Cursor. The proxy ignores incoming bearer credentials and uses the stored login for that provider.
Enable this route with `CCP_CODEX_RESPONSES_API=1` or `codex.responsesApi: true`. The `model` field selects Codex, Kimi, Grok, OpenCode Go, or Cursor. The proxy ignores incoming bearer credentials and uses the configured provider credential.

```sh
curl http://127.0.0.1:18765/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"kimi-k2.6","messages":[{"role":"user","content":"Hello"}]}'
```

For Kimi, Grok, and Cursor, the route accepts:
For Kimi, Grok, OpenCode Go, and Cursor, the route accepts:

- `system`, `developer`, `user`, `assistant`, and `tool` messages
- text, supported user images, function calls, and tool results
Expand Down Expand Up @@ -116,15 +116,15 @@ The Images API is an internal ChatGPT Codex integration, not the public OpenAI P

## `POST /v1/responses`

Enable this route with `CCP_CODEX_RESPONSES_API=1` or `codex.responsesApi: true`. The `model` field selects Codex, Kimi, Grok, or Cursor.
Enable this route with `CCP_CODEX_RESPONSES_API=1` or `codex.responsesApi: true`. The `model` field selects Codex, Kimi, Grok, OpenCode Go, or Cursor.

```sh
curl http://127.0.0.1:18765/v1/responses \
-H 'Content-Type: application/json' \
-d '{"model":"grok-4.5","input":"Hello"}'
```

Codex models use native Responses passthrough, including native JSON and SSE output. For Kimi, Grok, and Cursor, the route accepts:
Codex models use native Responses passthrough, including native JSON and SSE output. For Kimi, Grok, OpenCode Go, and Cursor, the route accepts:

- string input or message items
- `instructions`
Expand Down
Loading