mstfknn/llm-router — GitHub Repository Preview
Developer Tools ★ — Go

mstfknn/llm-router

by @mstfknn ·

Stars
Forks
0 Issues
Go Language

llm-router is a minimal, zero-dependency LLM routing proxy written in Go that intelligently directs API requests based on the model specified in the request body. It was built to solve a key limitation in Claude Code's agent team feature, which natively supports only Claude models. With llm-router, developers can route subagent requests to alternative models like Gemini, Qwen, or LLaMA via Ollama, Bifrost, or vLLM — without additional subscriptions. The routing logic is straightforward: requests targeting Claude models (claude-*, anthropic/*) are forwarded to the Anthropic API, while all other model identifiers are sent to a configurable downstream provider. The proxy passes authentication headers transparently and supports case-insensitive model matching, model prefixes like gemini/ and qwen2.5-coder, and path prefix configurations for complex upstream setups. Security features include a 100MB request body limit, HTTP timeouts, RFC 7230 hop-by-hop header filtering, token bucket rate limiting at 100 requests per second with burst of 20, and credential sanitization in logs. Observability is built in with /health and /metrics endpoints. The proxy compiles to a single binary with zero external Go dependencies, making deployment simple — run it natively or via Docker. It was created as an independent alternative to LiteLLM following its March 2026 PyPI supply chain incident.

Author avatar for @mstfknn
@mstfknn Project maintainer on GitHub
View Profile
View on GitHub
git clone https://github.com/mstfknn/llm-router.git

Quick Start Example

bash
# Build and run
make build
./llm-router

# Or with Docker
docker build -t llm-router .
docker run -p 4000:4000 \
  -e DOWNSTREAM_URL=http://your-ollama:11434 \
  llm-router

# Configure Claude Code (.claude/settings.json)
# to use proxy and route subagents to Gemini:
{
  "env": {
    "ANTHROPIC_BASE_URL": "http://localhost:4000",
    "CLAUDE_CODE_SUBAGENT_MODEL": "gemini/gemini-2.0-flash"
  },
  "model": "opus"
}

Tags

#go#llm#proxy#claude-code#routing#ai-gateway

Related Projects