Skip to main content

Local LiteLLM proxy for routing Claude Code to OpenCode Go.

Project description

oc-cc-proxy

oc-cc-proxy runs a local LiteLLM Proxy that lets Claude Code send Anthropic Messages API requests to OpenCode Go's OpenAI-compatible endpoint.

The proxy listens on http://127.0.0.1:4000 by default and routes all Claude Code model names through LiteLLM wildcard passthrough to https://opencode.ai/zen/go/v1/chat/completions.

Setup

  1. Install dependencies:

    uv sync
    
  2. Configure the OpenCode Go API key:

    cp .env.example .env
    
  3. Edit .env and set OPENCODE_GO_API_KEY.

  4. Start the proxy:

    uv run oc-cc-proxy
    

The proxy fails before accepting requests if OPENCODE_GO_API_KEY is missing.

Claude Code Settings

Add equivalent environment values to your Claude Code user-scope settings.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:4000",
    "ANTHROPIC_API_KEY": "not-a-real-anthropic-key",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro"
  }
}

ANTHROPIC_API_KEY only needs to be non-empty for the local proxy path. OpenCode Go authentication uses OPENCODE_GO_API_KEY on the proxy process.

Validation

With the proxy running, validate non-streaming text, wildcard model passthrough, streaming terminal events, tool definitions, tool results, and streamed tool requests:

uv run oc-cc-proxy-validate --model deepseek-v4-pro

Expected successful output starts each check with ok:. Any dropped, malformed, or ignored tool-call behavior should be treated as a blocking compatibility issue before describing the proxy as Claude Code-ready.

Project-local checks:

uv run pytest
uv run ruff check .

Debugging

Enable LiteLLM verbose logging and local request-shape diagnostics:

uv run oc-cc-proxy --debug

Debug helpers redact sensitive headers such as Authorization, x-api-key, and api-key. Avoid pasting raw upstream logs publicly unless you have checked them for secrets.

To inspect the generated LiteLLM config path without starting the server:

uv run oc-cc-proxy --print-config --config /tmp/oc-cc-proxy-litellm.yaml

Configuration

  • OPENCODE_GO_API_KEY: required OpenCode Go API key.
  • OC_PROXY_HOST: optional host override, defaults to 127.0.0.1.
  • OC_PROXY_PORT: optional port override, defaults to 4000.

The generated LiteLLM route uses:

model_list:
  - model_name: "*"
    litellm_params:
      model: "openai/*"
      api_base: "https://opencode.ai/zen/go/v1"

Current Limitations

  • Tool-use compatibility must be validated against a live OpenCode Go account and target model before claiming a model is known-good for Claude Code.
  • deepseek-v4-pro is the current known-good validation target for text, streaming, wildcard routing, tool calls, streamed tool-call metadata, and tool_result follow-up turns.
  • DeepSeek V4 requires its returned reasoning metadata to be replayed on assistant tool-call history. The proxy installs a LiteLLM callback that converts Anthropic thinking blocks back into upstream reasoning_content before tool_result follow-up turns.
  • Anthropic-specific features such as prompt caching, extended thinking, and any endpoints beyond /v1/messages are not claimed as supported unless separately validated.
  • Invalid Claude Code model names are forwarded to OpenCode Go by design because wildcard model passthrough keeps Claude Code settings as the source of truth.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oc_cc_proxy-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oc_cc_proxy-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file oc_cc_proxy-0.1.0.tar.gz.

File metadata

  • Download URL: oc_cc_proxy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oc_cc_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f93e9407654cc2a50cd593a35d320ca05c9c440f077e3e33127dd2518812ffa9
MD5 5fefe3ecfbaa9d215fa56cf1998a1f8e
BLAKE2b-256 3b4c6404f079863daeb4c00072cf7e8a2b20a267fa081faa1cd1800620c36720

See more details on using hashes here.

File details

Details for the file oc_cc_proxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oc_cc_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oc_cc_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ae41de3ef1b10de17ed107542e5cd3227b5c599ef88403edd9e207439856235
MD5 c1426773430d24a3083b9d9b0eba261f
BLAKE2b-256 4800a358ee578d1f3ad6a1085d9740b806eefd901aba0a5ed771d8ad52672dd6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page