Skip to content

LLM Proxy

A self-hosted LLM gateway with OpenAI, Anthropic, and Cohere-compatible endpoints, routing, budgets, and an admin console.

LLM Proxy is a self-hosted gateway for LLM APIs. Point an existing OpenAI or Anthropic SDK at it, or a Cohere SDK at the rerank endpoint. The proxy sends each request to the upstream that serves the requested model and translates the response back. Fallback, cost-aware routing, budgets, request logging, and the admin console are built in, and configuration changes do not require a restart.

Usage dashboard

How it works ​

text
Client                     LLM Proxy                                Upstream
OpenAI / Anthropic /  ──▶  authenticate, check allowlists & budgets
Cohere rerank              route: mapping, retries, fallback,   ──▶ provider API
                           circuit breaker
                      ◀──  translate back to the client's protocol

A request can enter as OpenAI Chat Completions and leave as Anthropic Messages, or be forwarded unchanged when both sides use the same protocol. Core Concepts explains the terms.

Protocol translation ​

ProtocolEndpoint
OpenAI Chat CompletionsPOST /v1/chat/completions
OpenAI ResponsesPOST /v1/responses (retrieve, delete, cancel, input items, compact, SSE and WebSocket)
Anthropic MessagesPOST /v1/messages (+ POST /v1/messages/count_tokens)
Cohere-compatible rerankPOST /v1/rerank (alias POST /v2/rerank)
EvaluationPOST /v1/systemone · POST /v1/decisions
OpenAI-compatible utilities/v1/embeddings · /v1/images/generations · /v1/images/edits · /v1/audio/speech · /v1/audio/transcriptions · /v1/audio/translations · /v1/models

The full route list, auth column, and provider capability matrix are in the Endpoint Index.

Smart routing and resilience ​

  • Send auto, fast, or best to let the proxy pick a configured model locally (without calling an LLM) based on complexity, cost, and capability. An optional routing judge handles ambiguous first turns.
  • Cost-aware selection uses the ECONOMY, BALANCED, and PREMIUM tiers and adapts based on real request outcomes.
  • Failed requests retry on the same provider, then fall back to the next provider in the chain. A circuit breaker skips providers that keep failing.
  • Keepalive heartbeats keep slow non-streaming requests alive behind CDNs. Requests abandoned by the client are cancelled and logged as 499.
  • Attach stdio or HTTP MCP servers once, and every MCP client can reach them at /servers/<name>/mcp with the same API keys, budgets, rate limits, and logs as model traffic. Per-key allowlists and a deny-by-default policy limit process execution and outbound requests.
  • web_search calls from any client are answered through your SearXNG or Ollama backend and returned in the client's format, including Anthropic.

Cost control and billing ​

  • Set prices per model for input, output, cached input, audio, and image tokens, or sync them with one click from models.dev.
  • Configure daily, weekly, or monthly USD budgets per API key, plus an account budget that covers all keys owned by a member.
  • Token usage tracks input, output, and cache hits, and the dashboard estimates savings from cached reads.

Observability ​

  • Request logs record TTFT, duration, tokens, cost, status, retries, and fallbacks.
  • Usage analytics show trends, provider and model breakdowns, cache efficiency, average latency, and throughput.
  • Audit events are hash-chained, and the console can verify their integrity.
  • Tracing supports Langfuse, any OTLP collector (Tempo, Jaeger, Phoenix, Grafana), or LangSmith, configured per account or server-wide.

Security ​

  • Teams use admin and viewer roles. Users can have model allowlists, account budgets, and rate limits. Invitations, passkeys, TOTP two-factor, and OIDC are supported.
  • API keys can carry model allowlists, MCP allowlists, requests-per-minute limits, an expiry date, and spend tracking.
  • Abuse protection includes sliding-window rate limiting (memory or Redis), login lockout, HSTS, request-size limits, and trusted-proxy-aware client IP resolution.
  • The JWT secret and API-key encryption key are generated and stored on first run.

Documentation map ​

SectionWhat is inside
Getting StartedInstall, first-run setup, connect an SDK or coding agent, concepts
DeploymentDocker Compose, databases, reverse proxy, upgrades
Admin ConsoleEvery dashboard screen and server setting, explained
API ReferenceEndpoints, auth, streaming, tools, routing, errors, OpenAPI
GuidesCost control, monitoring, security hardening
ReferenceEnvironment variables, FAQ

License ​

MIT. See LICENSE.

MIT licensed