JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 169
  • Score
    100M100P100Q89189F
  • License MIT

Local proxy server that converts any Chat Completions / Anthropic Messages API into OpenAI Responses API so Codex and Claude Code can use any LLM.

Package Exports

  • @codeproxy/cli

Readme

@codeproxy/cli

中文版README.zh-CN.md

@codeproxy/cli is a local proxy server that converts any Chat Completions or Anthropic Messages API into the OpenAI Responses API format. It lets Codex, Claude Code, or any Responses-API client use models from DeepSeek, GLM, Kimi, and more.

Built on @codeproxy/core.

Quick Start

npx @codeproxy/cli --upstream-format openai-chat \
  --base-url https://api.deepseek.com/v1 \
  --apikey sk-your-key

Point your Responses-API client at http://127.0.0.1:8787:

curl -N http://127.0.0.1:8787/v1/responses \
  -H 'content-type: application/json' \
  -H "authorization: Bearer \$API_KEY" \
  -d '{"model":"deepseek-v4-pro","input":"Hello!","stream":true}'

With config file

npx @codeproxy/cli --config config.json

See config.example.json for a full example.

Top-level fields

Field Type Description
version string Config format version (currently "1.0")
currentUpstream string Name of the upstream to use (must match a key in upstreams)
headers object Default headers applied to all upstreams (merged with per-upstream headers; per-upstream wins)
reasoningEffort string Default reasoning effort for all upstreams: "low", "medium", "high", "xhigh"
thinking object ` null`
timeoutMs number Default upstream request timeout in milliseconds

Per-upstream fields

Field Type Description
format "anthropic" ` "openai-chat"`
baseUrl string Required. Upstream endpoint URL
apiKey string Upstream API key. Sent as Authorization: Bearer <key> (Anthropic: rewritten to x-api-key)
model string Override the model field in all incoming requests
apiVersion string Override anthropic-version header (Anthropic only)
headers object Extra HTTP headers for this upstream. Merged on top of top-level headers, per-upstream wins
timeoutMs number Request timeout for this upstream (overrides top-level timeoutMs)
dropImages boolean When true, strip image/file parts from user messages (for text-only models). Use with fallback to auto-route image requests to a vision-capable upstream
fallback string Name of another upstream to route to when dropImages: true and the request contains images
reasoningEffort string Per-upstream reasoning effort override ("low", "medium", "high", "xhigh"). Overrides top-level value
thinking object ` null`

Precedence

CLI flags > per-upstream fields > top-level fields > built-in defaults

Example: auto-fallback for text-only models

When deepseek has dropImages: true and the user sends an image, the proxy automatically routes to kimi-vision (uses Kimi K2.6):

{
  "currentUpstream": "deepseek",
  "upstreams": {
    "deepseek": {
      "baseUrl": "https://api.deepseek.com/v1",
      "apiKey": "sk-...",
      "model": "deepseek-v4-pro",
      "dropImages": true,
      "fallback": "kimi-vision"
    },
    "kimi-vision": {
      "baseUrl": "https://api.moonshot.cn/v1",
      "apiKey": "sk-...",
      "model": "kimi-k2.6",
      "headers": { "x-llm-api-key": "sk-..." }
    }
  }
}

Codex Configuration

Codex 0.128.0+ requires custom providers to speak the Responses API. @codeproxy/cli bridges this gap for any Chat Completions or Anthropic Messages upstream.

Quick setup

  1. Start the proxy:
npx @codeproxy/cli --upstream-format openai-chat \
  --base-url https://api.deepseek.com/v1 \
  --apikey sk-your-key
  1. Add a custom provider in ~/.codex/config.toml:
[model_providers.deepseek]
name = "DeepSeek"
base_url = "http://127.0.0.1:8787/v1"
wire_api = "responses"

[profiles.deepseek-pro]
model = "deepseek-v4-pro"
model_provider = "deepseek"

With reasoning effort

[model_providers.deepseek]
name = "DeepSeek"
base_url = "http://127.0.0.1:8787/v1"
wire_api = "responses"

[profiles.deepseek-pro]
model = "deepseek-v4-pro"
model_provider = "deepseek"
model_reasoning_effort = "high"

@codeproxy/cli automatically maps reasoning.effort to the upstream's native format (e.g., reasoning_effort for OpenAI Chat, thinking blocks for Anthropic).

Multiple upstreams via config file

{
  "currentUpstream": "deepseek-chat",
  "upstreams": {
    "deepseek-chat": {
      "baseUrl": "https://api.deepseek.com/v1",
      "apiKey": "sk-...",
      "model": "deepseek-v4-pro",
      "dropImages": true,
      "fallback": "kimi-vision"
    },
    "kimi-vision": {
      "baseUrl": "https://api.moonshot.cn/v1",
      "apiKey": "sk-...",
      "model": "kimi-k2.6",
      "headers": { "x-llm-api-key": "sk-..." }
    },
    "claude": {
      "format": "anthropic",
      "baseUrl": "https://api.anthropic.com/v1",
      "apiKey": "sk-ant-...",
      "model": "claude-sonnet-4-20250514"
    }
  }
}

Switch upstreams by changing currentUpstream and restarting the proxy — no Codex config changes needed.

Install

npm install -g @codeproxy/cli

CLI Options

Flag Default Description
--base-url <url> Upstream endpoint (required unless --config)
--upstream-format <fmt> inferred anthropic or openai-chat
--config <file> JSON config file
--host <host> 127.0.0.1 Bind host
-p, --port <port> 8787 Bind port
--api-version <ver> 2023-06-01 Override Anthropic version header
--apikey <key> Upstream API key
--model <name> Override model for all requests
--drop-images Strip images (text-only models)

Programmatic usage

import { createResponsesFetch, startProxy } from '@codeproxy/cli';

const proxy = await startProxy({
  upstreamFormat: 'openai-chat',
  baseUrl: 'https://api.deepseek.com/v1',
  defaultHeaders: { authorization: 'Bearer sk-...' },
});

License

MIT