llmgateway

theopenco活跃维护

统一 API 接入多家大模型服务商,集中路由、管理并分析 LLM 请求,省去逐个对接和维护密钥的麻烦。

Route, manage, and analyze your LLM requests across multiple providers with a unified API interface.

v1.25.0发布于 2026-11-09 09:15 UTC1,735star +5 / 7 天201fork同步于 2026-11-10 17:49 UTC

怎么上手

由 README 提炼,执行前请确认
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
硬件要求按 README 说明

README 未说明硬件要求,仅给出 Docker 部署方式,未提及 GPU 或显存需求

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

开源 LLM API 网关,统一接口路由多家模型厂商并统计用量与成本

统一 API 接入多家大模型服务商,集中路由、管理并分析 LLM 请求,省去逐个对接和维护密钥的麻烦。

核心能力

  • 兼容 OpenAI API 格式,迁移时无需改调用代码
  • 在网关集中管理多家厂商的 API Key
  • 追踪请求数、token 用量、响应时间与费用
  • 对比不同模型的表现与性价比
  • 支持 Docker 自托管或使用官方托管服务

容易踩的坑

PostgreSQL 数据目录必须用 Docker 命名卷,不能直接绑定挂载宿主机目录,否则初始化可能因权限失败;自托管需自行生成 AUTH_SECRET 与 GATEWAY_API_KEY_HASH_SECRET 两个密钥;ee/ 目录下的企业功能需单独商业授权,多组织管理还需白标许可

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.25.0
  1. v1.25.0最新正式版2026-11-09 · 2026-11-09 09:15 UTC

    What's Changed

  2. v1.24.02026-11-02 · 2026-11-02 09:15 UTC
    查看更新说明

    What's Changed

  3. v1.23.02026-10-26 · 2026-10-26 09:26 UTC
    查看更新说明

    What's Changed

  4. v1.22.02026-10-19 · 2026-10-19 09:25 UTC
    查看更新说明

    What's Changed

  5. v1.21.02026-10-12 · 2026-10-12 09:33 UTC
    查看更新说明

    What's Changed

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    LLM Gateway

    LLM Gateway is an open-source API gateway for Large Language Models (LLMs). It acts as a middleware between your applications and various LLM providers, allowing you to:

    • Route requests to multiple LLM providers (OpenAI, Anthropic, Google Vertex AI, and others)
    • Manage API keys for different providers in one place
    • Track token usage and costs across all your LLM interactions
    • Analyze performance metrics to optimize your LLM usage

    Features

    • Unified API Interface: Compatible with the OpenAI API format for seamless migration
    • Usage Analytics: Track requests, tokens used, response times, and costs
    • Multi-provider Support: Connect to various LLM providers through a single gateway
    • Performance Monitoring: Compare different models' performance and cost-effectiveness

    Getting Started

    You can use LLM Gateway in two ways:

    • Hosted Version: For immediate use without setup, visit llmgateway.io to create an account and get an API key.
    • Self-Hosted: Deploy LLM Gateway on your own infrastructure for complete control over your data and configuration.

    Self-Hosted With Docker

    Use Docker-managed volumes for the unified image. Do not bind-mount a host directory directly to /var/lib/postgresql/data, because PostgreSQL initialization inside the container needs to set permissions on that directory and that can fail depending on the host filesystem and ownership.

    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
    

    If you prefer a one-off docker run, use named volumes instead of ~/some-host-dir:

    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 3007:3007 \
      -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
    

    Using LLM Gateway API

    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?"}
      ]
    }'
    

    Development Setup

    1. Install dependencies and set up the development environment:

      pnpm i && pnpm run setup
      

      This will install all dependencies, start Docker services, sync the database schema, and seed initial data.

      Note for WSL2 users: Ensure Docker Desktop is running with WSL integration enabled.

    2. Start development servers:

      pnpm dev
      
    3. Build for production:

      pnpm build
      

    Folder Structure

    • apps/ui: Next.js dashboard frontend
    • apps/playground: Lounge — consumer AI chat app (Next.js)
    • apps/code: Next.js Dev Plans + coding tools landing & dashboard
    • apps/airside: Airside — self-serve provider portal (Next.js)
    • apps/api: Hono backend
    • apps/gateway: API gateway for routing LLM requests
    • apps/docs: Documentation site
    • ee/admin: Internal admin dashboard
    • packages/db: Drizzle ORM schema and migrations
    • packages/models: Model and provider definitions
    • packages/shared: Shared types and utilities

    Adding a provider

    We do not accept pull requests that add new providers. Inference providers onboard through Airside, our self-serve provider portal, where you register and manage your model listings.

    License

    LLMGateway is available under a dual license:

    • Open Source: Core functionality is licensed under AGPLv3 - see the LICENSE file for details.
    • Enterprise: Commercial features in the ee/ directory require an Enterprise license; multi-organization administration requires a white-label license. See ee/LICENSE for details.

    Enterprise features include:

    • Advanced billing and subscription management
    • Full request and response payload retention (Retain All Data); other plans are metadata only
    • Custom provider key configurations
    • Team and organization management
    • Priority support
    • And more to be defined

    For enterprise licensing, please contact us at [email protected]