Skip to content

About

Command Code API 反代代理,兼容 OpenAI 与 Anthropic 接口 | Reverse proxy exposing Command Code API as OpenAI- and Anthropic-compatible endpoints

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

101 Commits

Folders and files

Repository files navigation

commandcode-proxy

Small Rust proxy for the Command Code API.

Run

cargo run --release

The server listens on 0.0.0.0:3050 by default. Configuration comes from environment variables; there is no config file.

Variable Default
HOST 0.0.0.0
PORT 3050
CC_API_BASE https://api.commandcode.ai
CC_API_ALLOWED_HOSTS api.commandcode.ai
PROJECT_SLUG cc-proxy
CMD_ZDR false
CC_MAX_BODY_MB 100
CC_REQUEST_TIMEOUT_SECS 120
CC_CLI_VERSION 0.18.10
RUST_LOG unset

The upstream URL must use HTTPS and its host must be in CC_API_ALLOWED_HOSTS. Local and private IP addresses are rejected. Redirects are disabled.

Requests need a user_... key in either Authorization: Bearer ... or x-api-key.

Endpoints

GET  /health
GET  /v1/models
POST /v1/chat/completions
POST /v1/messages
POST /v1/messages/count_tokens

/v1/chat/completions accepts OpenAI-shaped requests. /v1/messages accepts Anthropic-shaped requests and converts them before sending them upstream. Upstream newline-delimited events are converted to OpenAI or Anthropic streaming responses. Non-streaming requests return a single JSON response.

Unknown paths return 404. Unsupported methods return 405.

Docker

docker build -t commandcode-proxy .
docker run --rm -p 3050:3050 commandcode-proxy

The image is built in rust:alpine and runs on alpine:latest as an unprivileged user. The GitHub Actions workflow publishes the image to GHCR on main and version tags.

Docker Compose

Example compose.yaml:

services:
  commandcode-proxy:
    image: ghcr.io/ai-trash/commandcode-proxy:latest
    ports:
      - "3050:3050"
    environment:
      CC_API_BASE: https://api.commandcode.ai
      CC_API_ALLOWED_HOSTS: api.commandcode.ai
      PROJECT_SLUG: cc-proxy
      CMD_ZDR: "false"
      CC_CLI_VERSION: 0.18.10
    restart: unless-stopped

Save it as compose.yaml, then run:

docker compose up -d
curl http://127.0.0.1:3050/health

Authentication is supplied by each client request using Authorization: Bearer user_... or x-api-key; do not put an API key in the Compose file.

About

Command Code API 反代代理,兼容 OpenAI 与 Anthropic 接口 | Reverse proxy exposing Command Code API as OpenAI- and Anthropic-compatible endpoints

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages