Small Rust proxy for the Command Code API.
cargo run --releaseThe 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.
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 build -t commandcode-proxy .
docker run --rm -p 3050:3050 commandcode-proxyThe 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.
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-stoppedSave it as compose.yaml, then run:
docker compose up -d
curl http://127.0.0.1:3050/healthAuthentication is supplied by each client request using Authorization: Bearer user_... or x-api-key; do not put an API key in the Compose file.