cc proxy to oc go
Find a file
2026-05-05 10:13:15 +02:00
cmd/ocgo Prepare automated releases 2026-05-05 10:13:15 +02:00
scripts Prepare automated releases 2026-05-05 10:13:15 +02:00
.gitignore Prepare automated releases 2026-05-05 10:13:15 +02:00
go.mod Prepare automated releases 2026-05-05 10:13:15 +02:00
go.sum Prepare automated releases 2026-05-05 10:13:15 +02:00
LICENSE Prepare automated releases 2026-05-05 10:13:15 +02:00
Makefile Prepare automated releases 2026-05-05 10:13:15 +02:00
README.md Prepare automated releases 2026-05-05 10:13:15 +02:00

ocgo

ocgo is a small Go CLI that lets Claude Code run against an OpenCode Go subscription. It starts a local Anthropic-compatible proxy, translates Claude Code's Anthropic Messages API requests to OpenCode Go's OpenAI-compatible chat completions endpoint, and launches claude with the right environment variables.

Features

  • Save and reuse your OpenCode Go API key.
  • List known OpenCode Go model IDs.
  • Run Claude Code through OpenCode Go with one command.
  • Start, stop, and inspect a local proxy server.
  • Supports streaming text responses and basic tool-call translation.

Requirements

  • Go 1.22 or newer.
  • A valid OpenCode Go API key.
  • Claude Code installed and available as claude in your PATH when using ocgo launch claude.

Installation

Homebrew installation is coming soon.

# TODO: replace with the published Homebrew tap/formula
brew install ocgo

Configuration

Run setup and paste your OpenCode Go API key when prompted:

ocgo setup

Or pass the key directly:

ocgo setup --api-key sk-opencode-your-key

Configuration is saved to:

~/.config/ocgo/config.json

You can also provide the key at runtime with an environment variable:

export OCGO_API_KEY=sk-opencode-your-key

By default, the local proxy listens on 127.0.0.1:3456.

Usage

List available models

ocgo list

Aliases are also available:

ocgo ls
ocgo models

Launch Claude Code

Start Claude Code through the local proxy:

ocgo launch claude

Use a specific OpenCode Go model:

ocgo launch claude --model kimi-k2.6

Pass arguments through to Claude Code after --:

ocgo launch claude --model kimi-k2.6 -- -p "How does this repository work?"

Allow Claude Code to skip permission prompts:

ocgo launch claude --yes

When ocgo launch claude starts Claude Code, it sets:

ANTHROPIC_BASE_URL=http://127.0.0.1:3456
ANTHROPIC_AUTH_TOKEN=unused

When --model is provided, it also sets:

ANTHROPIC_MODEL=<model>
ANTHROPIC_SMALL_FAST_MODEL=<model>

If Claude Code requests a Claude model name or does not provide a model, ocgo defaults the upstream OpenCode Go model to kimi-k2.6.

Proxy commands

Run the proxy in the foreground:

ocgo serve

Run it in the background:

ocgo serve --background
# or
ocgo serve -b

Check whether the proxy is running:

ocgo status

Stop the background proxy:

ocgo stop

Proxy runtime files are stored in:

~/.config/ocgo/ocgo.pid
~/.config/ocgo/ocgo.log

Development

Set up a local development environment

Clone the repository and enter the project directory:

git clone <repository-url>
cd ocgo-cc

Install Go 1.22 or newer, then download dependencies:

go mod download

Build the binary:

make build

The binary is written to:

bin/ocgo

Optionally install it to ~/go/bin:

make install

Make sure the install location is in your PATH:

export PATH="$HOME/go/bin:$PATH"

Configure an OpenCode Go API key for local testing:

bin/ocgo setup
# or, if installed:
ocgo setup

Run the CLI without building:

make run

Run tests:

make test

Remove built binaries:

make clean

Release

This project includes a plain Bash release script, no GoReleaser required. It uses the GitHub CLI to create the GitHub release and update a Homebrew tap formula.

Requirements:

brew install gh
gh auth login

Release a new version:

make release TAG=v0.1.0

By default, releases are published to emanuelcasco/ocgo and the Homebrew formula is pushed to emanuelcasco/homebrew-tap. You can override those with GITHUB_REPOSITORY=owner/repo and HOMEBREW_TAP_REPO=owner/homebrew-tap.

The script builds macOS/Linux amd64 and arm64 archives, uploads them to GitHub Releases, and commits Formula/ocgo.rb to the tap repo.

How it works

ocgo exposes a local subset of the Anthropic API used by Claude Code:

  • GET /health
  • POST /v1/messages
  • POST /v1/messages/count_tokens

Requests sent to /v1/messages are converted into OpenAI-compatible chat completion requests and forwarded to:

https://opencode.ai/zen/go/v1/chat/completions

Responses are converted back into Anthropic-compatible responses for Claude Code.

Limitations

ocgo is intentionally lightweight. Token counting currently returns 0, and Anthropic/OpenAI compatibility is focused on the request and response shapes needed by Claude Code rather than full API parity.

License

MIT. See LICENSE.