Skip to content

emanuelcasco/ocgo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ocgo

ocgo is a small Go CLI that lets Claude Code and Codex CLI run against an OpenCode Go subscription. It starts a local compatibility proxy, translates Claude Code's Anthropic Messages API requests when needed, exposes OpenAI-compatible endpoints for Codex, and launches tools with the right configuration.

# 1. Setup your OpenCode API key
ocgo setup

# 2. Start coding!
ocgo launch claude --model kimi-k2.6
ocgo launch codex --model kimi-k2.6

Use your OpenCode Go subscription from Claude Code or Codex CLI in one command — no manual proxy setup required.

Features

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

Requirements

  • Go 1.22 or newer.
  • A valid OpenCode Go API key.
  • Claude Code or Codex CLI installed and available.

Installation

Install with Homebrew:

brew install emanuelcasco/tap/ocgo

Or tap the repository first:

brew tap emanuelcasco/tap
brew install ocgo

Build from source:

git clone https://github.com/emanuelcasco/ocgo.git
cd ocgo
make install

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.

Launch Codex CLI

Start Codex CLI through the local proxy:

ocgo launch codex

Use a specific OpenCode Go model:

ocgo launch codex --model kimi-k2.6

Pass arguments through to Codex after --:

ocgo launch codex --model kimi-k2.6 -- --sandbox workspace-write

Configure Codex without launching it:

ocgo launch codex --config

When ocgo launch codex runs, it writes or updates this profile in ~/.codex/config.toml:

[profiles.ocgo-launch]
openai_base_url = "http://127.0.0.1:3456/v1/"
forced_login_method = "api"
model_provider = "ocgo-launch"
model_catalog_json = "/Users/you/.codex/ocgo-models.json"

[model_providers.ocgo-launch]
name = "OpenCode Go"
base_url = "http://127.0.0.1:3456/v1/"
wire_api = "responses"

It then launches:

codex --profile ocgo-launch -m <model>

The Codex process receives OPENAI_API_KEY=ocgo; the local proxy injects your real OpenCode Go API key upstream. ocgo also writes ~/.codex/ocgo-models.json so Codex has metadata for OpenCode Go model IDs such as deepseek-v4-pro.

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 compatibility API used by Claude Code and Codex CLI:

  • GET /health
  • POST /v1/messages
  • POST /v1/messages/count_tokens
  • POST /v1/chat/completions
  • POST /v1/responses

Requests sent to /v1/messages are converted from Anthropic Messages format into OpenAI-compatible chat completion requests.

Requests sent to /v1/chat/completions are passed through as OpenAI-compatible chat completion requests while ocgo injects the configured OpenCode Go API key.

Requests sent to /v1/responses use a lightweight OpenAI Responses API adapter for Codex CLI. The adapter converts common Responses input, tool definitions, and streaming text events to and from chat completions.

All upstream requests are forwarded to:

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

Claude Code responses are converted back into Anthropic-compatible responses. Codex responses are returned in OpenAI-compatible Chat Completions or Responses API shapes depending on the requested endpoint.

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 and Codex CLI rather than full API parity. The /v1/responses adapter is minimal and targets text/tool workflows used by Codex; it is not a complete OpenAI Responses API implementation.

License

MIT. See LICENSE.

About

OCGO Provides an Ollama-style CLI for running Claude Code through an OpenCode Go subscription via a local Anthropic-compatible proxy.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors