A Claude Code proxy that translates protocols and compresses tool output


Claude Code speaks one protocol: Anthropic Messages. If all your requests go to api.anthropic.com, everything works, and you pay Anthropic’s prices. The trouble starts when you want a different backend, like GLM or Kimi. Claude Code has no built-in support for OpenAI Chat or Gemini. The protocol is fixed.

Simple reverse proxies can forward requests and swap API keys, but that is about all they do. They do not translate between protocols, and they do not compress tool output, which is usually the largest part of a coding agent’s token bill. They also cannot fail over when a provider goes down.

YoloRouter is a single Go binary. It supports four protocols natively: Anthropic Messages, OpenAI Chat, OpenAI Responses, and Gemini, translated through a shared intermediate representation. Claude Code talks to YoloRouter over Messages. YoloRouter forwards the request to an Anthropic-compatible provider as-is, or translates it to OpenAI Chat when the backend only offers an OpenAI-compatible endpoint. The response is converted back to Anthropic streaming format, so Claude Code renders it the same way it renders a direct response from Claude.

The comparison

YoloRouter Simple proxy Direct to Anthropic
Protocol translation Yes, between all four protocols Passthrough only Native
Works with GLM / Kimi / Qwen Yes, with translation when needed No No
Tool-output compression Yes, compresses test output, diffs, grep results No No
Key rotation and failover Automatic on 401/429 and 5xx Usually a single key Single key
Deployment Single binary, one-line install Python process or Docker None

Where direct Anthropic still wins

Direct access has three clear advantages.

Latency. A direct connection is one network hop. A proxy adds another hop, which matters for latency-sensitive workloads.

Official support. Anthropic supports its own API end to end, so there is a single party responsible when something breaks. With a proxy in the middle, you maintain that layer yourself.

Zero maintenance. There is nothing to install or update. A proxy is a component you have to keep running.

If none of these matter to you, continue reading.

When to self-host YoloRouter

The most direct reason is to use Claude Code with domestic Chinese models. GLM and Qwen now offer endpoints that speak the Anthropic protocol natively, so YoloRouter passes the request through without translation, and still applies tool-output compression and key rotation on top. For models that only offer OpenAI-compatible endpoints, like Kimi and DeepSeek, YoloRouter translates Messages to OpenAI Chat on the fly. Either way, switching models with /model inside Claude Code works.

Token cost is another reason. Claude Code produces large tool outputs, such as full test logs, multi-file diffs, and repo-wide grep results. YoloRouter compresses them, collapsing passing tests, stripping blob hashes from diffs, and deduplicating grep matches. It only touches the latest tool round, so earlier messages stay byte-identical and prompt caches keep hitting.

Key rotation and failover matter when a team shares several API keys. YoloRouter rotates keys on 401/429 responses and fails over to the next provider on errors, before Claude Code sees a failure.

If you want to run everything on your own infrastructure, YoloRouter runs as a single binary. Every request is logged with the model, token count, and cost. Nothing leaves your network except the upstream calls you configured.

Install and configure

Installation is one command:

curl -fsSL https://get.yolorouter.com/install.sh | bash

Then point Claude Code at your instance:

export ANTHROPIC_BASE_URL="http://localhost:8080"
export ANTHROPIC_AUTH_TOKEN="your-yolorouter-api-key"
export ANTHROPIC_MODEL="glm-5.2"

See the Claude Code guide for adding providers, configuring models, and troubleshooting.