Skip to content

liwei/commandcode-proxy

Repository files navigation

commandcode-proxy

CI

Warning

Deprecated — superseded by the Go rewrite, commandcode-proxy-go. The Go port ships as a single static binary (no Python, virtualenv, or dependencies to install) with the same OpenAI + Anthropic surfaces and verified behavior parity. New deployments should use it; this repository still works but is no longer actively developed.

An OpenAI Chat Completions- and Anthropic Messages-compatible proxy for the Command Code API. Run it locally, point any OpenAI- or Anthropic-compatible client (Hermes Agent, the openai/anthropic SDKs, Claude Code, curl, …) at it, and use your Command Code subscription's models.

It is a Python port of the translation logic in the community pi-commandcode-provider extension — but instead of plugging into one agent, it exposes standard OpenAI and Anthropic endpoints that any tool can consume.

Unofficial and community-maintained. Not affiliated with Command Code. It forwards requests to the public Command Code API using your own key.

Why a proxy (and not just point at Command Code's OpenAI endpoint)?

Command Code exposes two surfaces:

Surface Protocol Plan required
/provider/v1/chat/completions OpenAI-compatible Provider tier (paid add-on)
/alpha/generate Custom (Vercel-AI-SDK stream) Your normal subscription (Go / Pro / …)

If you only point an OpenAI client at /provider/v1, a non-Provider key gets upgrade_required. The Command Code CLI (and the pi extension) actually use the custom /alpha/generate endpoint, which your subscription does cover. This proxy speaks /alpha/generate upstream and OpenAI downstream — so your existing plan works from any OpenAI-compatible tool.

What it does

  • POST /v1/chat/completions — streaming and non-streaming, with tool calling and reasoning (reasoning_content) passthrough.
  • POST /v1/messages — an Anthropic Messages-compatible surface, so Claude Code and the Anthropic SDK can drive Command Code too.
  • GET /v1/models — proxies Command Code's live model catalog.
  • GET /health, plus a minimal status + request-log dashboard at GET /admin.

Translation highlights (see commandcode_proxy/translate.py):

  • System/developer turns → Command Code params.system.
  • OpenAI tools → Command Code input_schema tools; tool_calls / tool results → typed tool-call / tool-result parts (with dangling-call pruning, matching the upstream extension).
  • Upstream text-delta / reasoning-delta / tool-call / finish events → OpenAI chat.completion.chunk deltas; finish.totalUsage → OpenAI usage.
  • Transient (isRetryable) upstream errors before the first token are retried.

Documentation

  • Install & usage — install/run, Docker, the systemd service, the /admin dashboard, authentication, model aliases, and connecting Hermes / the OpenAI SDK / Claude Code, plus tests.
  • Architecture — design rationale and key decisions.

Limitations

  • Text in, text/tools/reasoning out. Multimodal (image) inputs are flattened to their text parts — the upstream extension is text-only too. Adding image parts is a future enhancement.
  • Model availability follows your plan. A model in /v1/models can still return 402 MODEL_NOT_IN_PLAN if your subscription doesn't include it.
  • No browser /login flow (the extension's OAuth callback server). Each caller passes its own key in the Authorization header instead.
  • Pricing/cost accounting is left to the client; the proxy passes through Command Code's token usage.

Credits

Translation logic ported from patlux/pi-commandcode-provider (MIT). Licensed under MIT — see LICENSE.

About

OpenAI-compatible API proxy for Command Code — use your Command Code subscription from any OpenAI client (Hermes, opencode, the OpenAI SDK).

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors