ocgo is a small Go CLI for using your OpenCode Go subscription from Claude Code or Codex CLI in one command — no manual proxy setup required.
🤖 Claude Code support. 🧠 Codex CLI support. ⚡ Local compatibility proxy.
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.
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
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.
ocgo list
Aliases are also available:
ocgo ls
ocgo models
ocgo can route model names used by Claude Code or Codex to OpenCode Go models. Mappings are empty by default; add only the routes you want. The mapping is stored in:
~/.config/ocgo/model-mapping.json
Show the current mapping for a tool:
ocgo mapping claude show
ocgo mapping codex show
Get, set, or remove one mapping:
ocgo mapping claude get claude-sonnet-4-5
ocgo mapping claude set claude-sonnet-4-5 kimi-k2.6
ocgo mapping claude unset claude-sonnet-4-5
ocgo mapping codex set gpt-5 deepseek-v4-pro
ocgo mapping codex rm gpt-5
Open the mapping file in $EDITOR:
ocgo mapping claude open
ocgo mapping codex open
Exact mappings take precedence. For Claude, family mappings such as claude-sonnet can also match versioned names such as claude-sonnet-4-5 when no exact entry exists.
Claude Code primarily shows Claude/Anthropic models in its /model picker. It can show a single custom model in some launch modes, but ocgo cannot reliably inject the full OpenCode Go model catalog into Claude Code's picker.
For Claude Code, mappings are useful to make Claude's usual aliases or model names resolve to the OpenCode Go models you prefer, without switching models every session:
ocgo mapping claude set claude-sonnet kimi-k2.6
ocgo mapping claude set claude-opus deepseek-v4-pro
ocgo mapping claude show
With the claude-sonnet family mapping above, requests for versioned Sonnet names also route to the same target unless an exact mapping exists:
claude-sonnet-4-5 -> kimi-k2.6
When launching Claude, ocgo prints the active mapping and exports Claude's default model environment variables only for configured routes.
Codex is different: ocgo can already provide a model catalog to Codex through ~/.codex/ocgo-models.json, so OpenCode Go models can appear directly in Codex's model selection UI.
For Codex, mappings are mostly useful for compatibility with prompts, scripts, tools, or existing config that still request original Codex/OpenAI model names. For example:
ocgo mapping codex set gpt-5.5 deepseek-v4-pro
Then a request for gpt-5.5 is routed to deepseek-v4-pro. Mapped aliases are also included in the generated Codex model catalog so they can appear alongside OpenCode Go model IDs.
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, ocgo routes the request through ocgo mapping claude. Unmapped model names pass through unchanged. ocgo launch claude prints the active mapping before starting Claude Code.
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 the ocgo-launch Codex profile. For newer Codex versions it writes ~/.codex/ocgo-launch.config.toml; for compatibility with older Codex versions it also writes legacy profile sections 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.
Codex model names can be routed through ocgo mapping codex. Mapped Codex aliases are included in the generated ~/.codex/ocgo-models.json catalog so they can appear alongside OpenCode Go models.
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
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
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.
ocgo exposes a local compatibility API used by Claude Code and Codex CLI:
GET /healthPOST /v1/messagesPOST /v1/messages/count_tokensPOST /v1/chat/completionsPOST /v1/responsesRequests 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.
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.
MIT. See LICENSE.