cli

skill
Guvenlik Denetimi
Uyari
Health Uyari
  • No license — Repository has no license file
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Community trust — 28 GitHub stars
Code Gecti
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

@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.

README.md

@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 --base-url https://api.deepseek.com/v1 \
  --model deepseek-v4-flash \
  --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' \
  -d '{"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 or null Default thinking config for all upstreams. Anthropic format: {"type": "enabled", "budget_tokens": 16384}. Set to null to disable
timeoutMs number Default upstream request timeout in milliseconds

Per-upstream fields

Field Type Description
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
modelAliases object Rewrite only matching incoming model names. Unmapped models pass through unchanged
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
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 or null Per-upstream thinking config. Overrides top-level value. Set to null to disable

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:

{
  "currentUpstream": "deepseek",
  "upstreams": {
    "deepseek": {
      "baseUrl": "https://api.deepseek.com/v1",
      "apiKey": "sk-...",
      "model": "deepseek-v4-flash",
      "modelAliases": {
        "gpt-5.5": "deepseek-v4-flash",
        "gpt-4o": "deepseek-v4-flash"
      },
      "dropImages": true,
      "fallback": "kimi"
    },
    "kimi": {
      "baseUrl": "https://api.kimi.com/coding/v1",
      "apiKey": "sk-kimi-...",
      "model": "kimi-for-coding",
      "headers": { "user-agent": "KimiCLI/1.39.0" }
    }
  }
}

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 --base-url https://api.deepseek.com/v1 \
  --model deepseek-v4-flash \
  --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-flash"
model_provider = "deepseek"

Multiple upstreams via config file

{
  "currentUpstream": "deepseek-chat",
  "upstreams": {
    "deepseek-chat": {
      "baseUrl": "https://api.deepseek.com/v1",
      "apiKey": "sk-...",
      "model": "deepseek-v4-flash",
      "dropImages": true,
      "fallback": "kimi"
    },
    "kimi": {
      "baseUrl": "https://api.kimi.com/coding/v1",
      "apiKey": "sk-kimi-...",
      "model": "kimi-for-coding",
      "headers": { "user-agent": "KimiCLI/1.39.0" }
    },
    "claude": {
      "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

Yorumlar (0)

Sonuc bulunamadi