oc-go-cc  by samueltuyizere

LLM API proxy enabling Claude Code to use OpenCode Go models

Created 1 month ago
504 stars

Top 61.3% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a Go CLI proxy (oc-go-cc) that enables users of Anthropic's Claude Code to leverage affordable open-source coding models available through an OpenCode Go subscription. It acts as an intermediary, transparently translating API requests between the Anthropic and OpenAI formats, allowing Claude Code to interact with cost-effective models without any modifications to the client application.

How It Works

The oc-go-cc proxy intercepts Anthropic API requests originating from Claude Code. It then transforms these requests into the OpenAI Chat Completions format, which is compatible with OpenCode Go's endpoints. After receiving a response from OpenCode Go, the proxy converts it back into the Anthropic format before returning it to Claude Code. This process is designed to be seamless, with features like intelligent model routing based on request context, fallback chains for model failures, and a circuit breaker mechanism to maintain reliability.

Quick Start & Requirements

  • Installation:
    • macOS/Linux: brew tap samueltuyizere/tap && brew install oc-go-cc
    • Source: git clone the repository, then make build.
    • Binary: Download pre-compiled binaries from the project's Releases page.
  • Prerequisites:
    • An active OpenCode Go subscription and API key.
    • Go 1.21+ (required only for building from source).
  • Setup:
    1. Initialize configuration: oc-go-cc init
    2. Set API key: export OC_GO_CC_API_KEY=sk-opencode-your-key-here
    3. Start the proxy: oc-go-cc serve
    4. Configure Claude Code: export ANTHROPIC_BASE_URL=http://127.0.0.1:3456 and export ANTHROPIC_AUTH_TOKEN=unused.
  • Links: Releases page (implied by README).

Highlighted Details

  • Transparent Proxying: Seamlessly translates between Anthropic and OpenAI API formats.
  • Intelligent Model Routing: Automatically selects appropriate models based on request context (e.g., long context, thinking, background tasks).
  • Resilience Features: Implements fallback chains for model failures and circuit breakers to skip unhealthy models.
  • Real-time Streaming: Supports full Server-Sent Events (SSE) streaming with in-flight format transformation.
  • Tool Use Translation: Handles conversions between Anthropic's tool_use and OpenAI's function calling.
  • Accurate Token Counting: Utilizes tiktoken for precise token counting and context threshold detection.
  • Background Operation & Auto-start: Can run as a detached daemon and be configured to start automatically on login (macOS launchd support).

Licensing & Compatibility

  • License: MIT.
  • Compatibility: The MIT license permits commercial use and integration with closed-source applications without significant restrictions.

Limitations & Caveats

The project requires an OpenCode Go subscription and API key to function. While the proxy handles various request types and model fallbacks, its effectiveness is dependent on the availability and performance of the underlying OpenCode Go models. The README indicates version v0.1.0 in an example, suggesting it may be in early development.

Health Check
Last Commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
27
Issues (30d)
23
Star History
478 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.