Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy
Rust
set default user-agent for codex to claude-code-proxy/<version>
Raine Virtad92fa5fd5dd0
diff --git a/README.md b/README.mdindex 4b3bcb4..5f21c55 100644--- a/README.md+++ b/README.md@@ -429,21 +429,21 @@ The proxy speaks enough of the Anthropic API for Claude Code:Settings are environment variables on the proxy process, not a config file.-| Variable | Default | Purpose |-| ----------------- | -------------------------------- | -------------------------------------------------- |-| `PORT` | `18765` | Proxy listen port |-| `XDG_STATE_HOME` | `~/.local/state` | Base dir for `proxy.log` |-| `CCP_LOG_STDERR` | unset | Also mirror log lines to stderr |-| `CCP_LOG_VERBOSE` | unset | Log full request/response bodies + every SSE event |-| `KIMI_OAUTH_HOST` | `https://auth.kimi.com` | Override Kimi's OAuth host (debugging only) |-| `KIMI_BASE_URL` | `https://api.kimi.com/coding/v1` | Override Kimi's API base URL |-| `CCP_CODEX_MODEL` | unset | Force all Codex requests to this model (`gpt-5.2`, `gpt-5.3-codex`, `gpt-5.4`, `gpt-5.4-mini`) |-| `CCP_CODEX_EFFORT`| unset | Force all Codex requests to this reasoning effort (`none`, `low`, `medium`, `high`, `xhigh`) |-| `CCP_CODEX_ORIGINATOR` | `claude-code-proxy` | Override the `originator` header sent to Codex |-| `CCP_CODEX_USER_AGENT` | unset | Override the `User-Agent` header sent to Codex (not sent by default) |-| `CCP_KIMI_USER_AGENT` | `KimiCLI/1.37.0` | Override the `User-Agent` header sent to Kimi |-| `CCP_ORIGINATOR` | `claude-code-proxy` | Fallback for `CCP_CODEX_ORIGINATOR` |-| `CCP_USER_AGENT` | unset | Fallback for `CCP_CODEX_USER_AGENT` and `CCP_KIMI_USER_AGENT` |+| Variable | Default | Purpose |+| ---------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------- |+| `PORT` | `18765` | Proxy listen port |+| `XDG_STATE_HOME` | `~/.local/state` | Base dir for `proxy.log` |+| `CCP_LOG_STDERR` | unset | Also mirror log lines to stderr |+| `CCP_LOG_VERBOSE` | unset | Log full request/response bodies + every SSE event |+| `KIMI_OAUTH_HOST` | `https://auth.kimi.com` | Override Kimi's OAuth host (debugging only) |+| `KIMI_BASE_URL` | `https://api.kimi.com/coding/v1` | Override Kimi's API base URL |+| `CCP_CODEX_MODEL` | unset | Force all Codex requests to this model (`gpt-5.2`, `gpt-5.3-codex`, `gpt-5.4`, `gpt-5.4-mini`) |+| `CCP_CODEX_EFFORT` | unset | Force all Codex requests to this reasoning effort (`none`, `low`, `medium`, `high`, `xhigh`) |+| `CCP_CODEX_ORIGINATOR` | `claude-code-proxy` | Override the `originator` header sent to Codex |+| `CCP_CODEX_USER_AGENT` | `claude-code-proxy/<version>` | Override the `User-Agent` header sent to Codex |+| `CCP_KIMI_USER_AGENT` | `KimiCLI/1.37.0` | Override the `User-Agent` header sent to Kimi |+| `CCP_ORIGINATOR` | `claude-code-proxy` | Fallback for `CCP_CODEX_ORIGINATOR` |+| `CCP_USER_AGENT` | unset | Fallback for `CCP_CODEX_USER_AGENT` and `CCP_KIMI_USER_AGENT` |### Filesdiff --git a/src/providers/codex/client.ts b/src/providers/codex/client.tsindex 52542fa..6fbe767 100644--- a/src/providers/codex/client.ts+++ b/src/providers/codex/client.ts@@ -1,4 +1,6 @@import { CODEX_API_ENDPOINT, ORIGINATOR as ORIGINATOR_DEFAULT } from "./auth/constants.ts"+declare const BUILD_VERSION: string | undefined+const PROXY_VERSION = typeof BUILD_VERSION === "string" ? BUILD_VERSION : "dev"import { forceRefresh, getAuth } from "./auth/manager.ts"import type { Logger } from "../../log.ts"import type { RequestContext } from "../types.ts"@@ -65,7 +67,7 @@ async function doFetch(originator: process.env.CCP_CODEX_ORIGINATOR ?? process.env.CCP_ORIGINATOR ?? ORIGINATOR_DEFAULT,"openai-beta": "responses=experimental",})- const userAgent = process.env.CCP_CODEX_USER_AGENT ?? process.env.CCP_USER_AGENT+ const userAgent = process.env.CCP_CODEX_USER_AGENT ?? process.env.CCP_USER_AGENT ?? `claude-code-proxy/${PROXY_VERSION}`if (userAgent) headers.set("User-Agent", userAgent)if (accountId) headers.set("ChatGPT-Account-Id", accountId)if (sessionId) {