# LLM Gateway (theopenco)

> One OpenAI-compatible API to route, manage, and track LLM requests across providers

- Category: Evaluation & Production Ops / Gateways & Routing
- Language: TypeScript
- Licence: AGPL-3.0
- Repository: https://github.com/theopenco/llmgateway
- Website: https://llmgateway.io/
- Canonical page: https://ai-tldr.dev/tools/llm-gateway-theopenco/

## In short

LLM Gateway (theopenco) is One OpenAI-compatible API to route, manage, and track LLM requests across providers. Instead of integrating each provider separately, you send requests to one endpoint that speaks the OpenAI API format and forwards them to OpenAI, Anthropic, Google Vertex AI, and others. It sits in the Gateways & Routing category of the Evaluation & Production Ops tools and is open-source, written in TypeScript and licensed AGPL-3.0.

## Overview

LLM Gateway is an open-source API gateway that sits between your applications and multiple LLM providers. Instead of integrating each provider separately, you send requests to one endpoint that speaks the OpenAI API format and forwards them to OpenAI, Anthropic, Google Vertex AI, and others.

It is aimed at teams that call several LLM providers and want a single place to manage API keys, watch token usage and costs, and compare model performance. Because the interface matches the OpenAI format, existing OpenAI client code can point at the gateway with minimal changes.

As an LLM gateway/proxy, it adds a routing and observability layer to your stack. You can run the hosted version at llmgateway.io or self-host the unified Docker image for full control over your data and configuration.

## What it does

- OpenAI-compatible API so existing OpenAI clients work with little change
- Routes requests across multiple providers including OpenAI, Anthropic, and Google Vertex AI
- Central management of provider API keys in one place
- Usage analytics for requests, tokens, response times, and costs
- Performance monitoring to compare models on speed and cost-effectiveness
- Self-host with the unified Docker image or use the hosted service

## Getting started

You can use the hosted service at llmgateway.io or self-host with Docker. The quickest path is to get an API key and call the gateway's OpenAI-compatible chat completions endpoint.

1. Call the hosted API

   Get an API key from llmgateway.io, then send a chat completion request to the gateway. The endpoint follows the OpenAI format, so you pass a model and a messages array.

```bash
curl -X POST https://api.llmgateway.io/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
  -d '{
  "model": "gpt-4o",
  "messages": [
    {"role": "user", "content": "Hello, how are you?"}
  ]
}'
```

2. Self-host with Docker

   Generate the required secrets and run the unified container script. Use Docker-managed named volumes for Postgres and Redis rather than bind-mounting a host directory.

```bash
export LLM_GATEWAY_SECRET="$(openssl rand -base64 32 | tr -d '\n')"
export GATEWAY_API_KEY_HASH_SECRET="$(openssl rand -base64 32 | tr -d '\n')"
./scripts/run-unified-container.sh
```

3. Or run a one-off container

   If you prefer a single docker run, create named volumes first and pass the auth secrets as environment variables.

```bash
docker volume create llmgateway_postgres
docker volume create llmgateway_redis

docker run -d \
  --name llmgateway \
  --restart unless-stopped \
  -p 3002:3002 -p 3003:3003 -p 3005:3005 \
  -p 3006:3006 -p 4001:4001 -p 4002:4002 \
  -v llmgateway_postgres:/var/lib/postgresql/data \
  -v llmgateway_redis:/var/lib/redis \
  -e AUTH_SECRET="$LLM_GATEWAY_SECRET" \
  -e GATEWAY_API_KEY_HASH_SECRET="$GATEWAY_API_KEY_HASH_SECRET" \
  ghcr.io/theopenco/llmgateway-unified:latest
```

## When to use it

- Route an app across OpenAI, Anthropic, and Google through one endpoint without writing per-provider integrations
- Track token usage and spend across all LLM calls in a single dashboard
- Manage and rotate provider API keys centrally instead of spreading them across services
- Compare models on latency and cost to decide which to use in production
