Butter sits between your application and AI providers, offering a unified OpenAI-compatible API with multi-provider routing, automatic failover, and sub-50μs overhead. Written in Go.
Everything you need to route AI traffic with confidence.
Drop-in replacement for any OpenAI SDK client. Just change the base URL.
Route models to 10 providers — OpenAI, Anthropic, AWS Bedrock, Gemini, OpenRouter, Groq, Mistral, Together.ai, Fireworks, Perplexity — with priority or round-robin strategies.
Full streaming support with immediate per-chunk flush via SSE relay.
Configurable retry-on status codes with exponential backoff across providers.
Weighted random key selection with per-key model allowlists.
Ordered hook chains (pre/post HTTP, pre/post LLM) with fail-open design. Built-in plugins for rate limiting, logging, metrics, and tracing. External plugins via WASM sandbox.
Built-in token bucket rate limiter with global or per-IP modes. Plugins can short-circuit requests before they reach providers.
Built-in metrics plugin powered by OTel SDK — request totals, latency histograms, and error counters exposed at /metrics.
In-memory LRU or Redis cache with TTL for deterministic requests (temperature=0, non-streaming). Reduces costs and latency for repeated queries.
Load external .wasm plugins via Extism/wazero — pure Go, no CGo, full sandbox isolation. Write plugins in Go, Rust, TypeScript, Python, and more.
Built-in OpenTelemetry tracing plugin with OTLP HTTP export. Zero overhead when unconfigured.
Routing and key configuration reloads automatically on file change — no restart, no dropped connections.
Vend btr_ tokens for usage tracking and attribution. Per-key request and token counters with optional require_key enforcement.
WASM plugin scanning for ~60 injection patterns across 7 categories with Unicode bypass detection. Block, log, or tag modes.
Full /v1/embeddings and /v1/models endpoints for SDK compatibility. Embeddings route through the same failover logic as chat.
Per-provider credential_mode — stored injects managed keys; passthrough forwards the client's own auth headers unchanged.
Azure OpenAI, Vertex AI, and more to match full Bifrost coverage.
Up and running in under a minute.
Download the latest binary from GitHub Releases, or build from source:
git clone https://github.com/temikus/butter.git
cd butter
go build -o pkg/bin/butter ./cmd/butter/
cp config.example.yaml config.yaml
export OPENAI_API_KEY="sk-..."
export OPENROUTER_API_KEY="sk-or-v1-..."
./pkg/bin/butter -config config.yaml
# {"level":"INFO","msg":"butter listening","address":":8080"}
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Say hello!"}]
}'
Works with any OpenAI-compatible client. Just change the base URL.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="unused", # Butter uses its own configured keys
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "http://localhost:8080/v1",
apiKey: "unused",
});
const completion = await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(completion.choices[0].message.content);
Minimal layers, maximum throughput.
Engineered for negligible overhead.
| Metric | Target |
|---|---|
| Per-request overhead (no plugins) | <50μs |
| Per-request overhead (built-in plugins) | <100μs |
| Per-request overhead (1 WASM plugin) | <150μs |
| Streaming TTFB overhead | <1ms |
| Memory at idle | <30MB |