gpt-load

tbphpMIT活跃维护

自托管的 AI 网关,把多个渠道的 API 密钥和订阅账号统一接入,提供调度、故障转移、请求日志与用量统计,适合集中管理 LLM 调用。

Self-hosted AI gateway for multi-channel, multi-credential setups — API keys and subscription accounts, scheduling, failover, request logs and usage. 自托管 AI 网关:多渠道多凭据统一接入,含密钥与订阅账号、调度容错、日志与用量。

v2.0.0-rc.63发布于 2026-11-08 15:15 UTC7,204star +5 / 7 天794fork同步于 2026-11-10 05:32 UTC

怎么上手

由 README 提炼,执行前请确认
git clone --depth 1 https://github.com/tbphp/gpt-load.git
cd gpt-load
cp .env.example .env
docker compose up -d
硬件要求按 README 说明

README 未说明硬件要求;部署需 Docker 与 Docker Compose,默认仅监听回环地址

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

项目说明

由 README 自动翻译提炼

自托管 AI 网关,用单一入口统一管理多渠道、多凭据并做调度容错

自托管的 AI 网关,把多个渠道的 API 密钥和订阅账号统一接入,提供调度、故障转移、请求日志与用量统计,适合集中管理 LLM 调用。

核心能力

  • 用单一 base URL 和 AccessKey 接入上游渠道
  • 统一管理 API 密钥与 Codex、Claude 等订阅账号
  • 内置多凭据调度、权重、重试、冷却与黑名单
  • 保留 OpenAI、Anthropic、Gemini 原生客户端协议
  • 内嵌 UI 查看健康、日志、用量与成本估算

容易踩的坑

2.0 无法就地打开、导入或迁移 1.x 数据,升级前需先看迁移说明;首次启动自动生成管理密钥,需从容器内 /app/data/auth.key 读取;encryption.key 用于解密凭据,备份时须与数据库一起保存,丢失后无法恢复;订阅渠道 OAuth 回调端口固定,同一主机只能运行一个默认 Compose 实例

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

最近发版

5 个版本v2.0.0-rc.63
  1. v2.0.0-rc.63最新正式版2026-11-08 · 2026-11-08 15:15 UTC

    2.x is a rewrite and is not compatible with 1.x data, start 2.x from an empty database and a new encryption.key.


    2.x 是全新重写版本,与 1.x 数据不兼容,请以全新数据库和新的 encryption.key 部署 2.x。

    What's Changed

    Full Changelog: https://github.com/tbphp/gpt-load/compare/v2.0.0-rc.62...v2.0.0-rc.63

  2. v2.0.0-rc.622026-11-05 · 2026-11-05 05:16 UTC
    查看更新说明

    2.x is a rewrite and is not compatible with 1.x data, start 2.x from an empty database and a new encryption.key.


    2.x 是全新重写版本,与 1.x 数据不兼容,请以全新数据库和新的 encryption.key 部署 2.x。

    What's Changed

    Full Changelog: https://github.com/tbphp/gpt-load/compare/v2.0.0-rc.61...v2.0.0-rc.62

  3. v2.0.0-rc.612026-11-04 · 2026-11-04 13:22 UTC
    查看更新说明

    2.x is a rewrite and is not compatible with 1.x data, start 2.x from an empty database and a new encryption.key.


    2.x 是全新重写版本,与 1.x 数据不兼容,请以全新数据库和新的 encryption.key 部署 2.x。

    What's Changed

    Full Changelog: https://github.com/tbphp/gpt-load/compare/v2.0.0-rc.60...v2.0.0-rc.61

  4. v2.0.0-rc.602026-11-03 · 2026-11-03 09:48 UTC
    查看更新说明

    2.x is a rewrite and is not compatible with 1.x data, start 2.x from an empty database and a new encryption.key.


    2.x 是全新重写版本,与 1.x 数据不兼容,请以全新数据库和新的 encryption.key 部署 2.x。

    What's Changed

    Full Changelog: https://github.com/tbphp/gpt-load/compare/v2.0.0-rc.59...v2.0.0-rc.60

  5. v2.0.0-rc.592026-11-01 · 2026-11-01 17:22 UTC
    查看更新说明

    2.x is a rewrite and is not compatible with 1.x data, start 2.x from an empty database and a new encryption.key.


    2.x 是全新重写版本,与 1.x 数据不兼容,请以全新数据库和新的 encryption.key 部署 2.x。

    What's Changed

    Full Changelog: https://github.com/tbphp/gpt-load/compare/v2.0.0-rc.58...v2.0.0-rc.59

用户点评

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

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

    README 原文

    未翻译

    GPT-Load

    A self-hosted AI gateway for multi-channel, multi-credential setups

    API keys, subscription accounts, traffic scheduling, failure handling, request logs, and usage accounting — behind a single entry point.

    English · 中文 · 日本語 | Official Website

    Release Docker Go License


    Sponsors

    Become a sponsor

    Thanks to Modelflare for sponsoring this project! Modelflare: Full strength, stable, nothing watered down. Global SOTA models at a lower cost. Operated by US-based Havenbyte LLC, Modelflare supports GPT, Claude, Gemini, Grok, and other leading models through common compatible protocols, plus 40+ image and video models.

    Cache compensation is a highlight: selected OpenAI groups (price-first, stable, and premium) guarantee daily cache hit rates of 65%, 75%, or 85%, and if eligible requests fall short, Modelflare refunds the difference, visible on the usage dashboard after settlement.

    Special offers: a single top-up of US$20 unlocks the GPT discount group at a 0.015x price multiplier, and a single top-up of US$50 unlocks the Claude discount group at a 0.03x multiplier. Register via this exclusive link to get started.


    Why GPT-Load

    Your application only needs one base URL and one AccessKey. Providers, accounts, credentials, models, and routing policy are all configured in the management UI.

    • One gateway, native protocols — Manage official APIs, cloud platforms, model services, and compatible relays together while clients keep their OpenAI, Anthropic, or Gemini native interfaces.
    • One mechanism for API keys and subscriptions — Codex, Claude, Antigravity, Grok, and API-key channels share credential management, scheduling, and health handling.
    • Scheduling and failure isolation built in — Multi-credential scheduling, configurable weights, retries, cooldown, blacklisting, and session affinity reduce the impact of overloaded or failing credentials.
    • Observable, self-hosted, and simple to deploy — Inspect health, routes, logs, usage, and cost estimates in an embedded UI backed by SQLite, MySQL, or PostgreSQL with local credential encryption.

    Online demo

    https://demo.gpt-load.com

    Login key: gpt-load-demo

    Quick start

    [!WARNING] If you are using 1.x, read Moving from 1.x first. 2.0 cannot open, import, or migrate 1.x data in place.

    1. Start the service

    Requires Docker and Docker Compose.

    git clone --depth 1 https://github.com/tbphp/gpt-load.git
    cd gpt-load
    
    cp .env.example .env
    docker compose up -d
    

    Confirm the service is up:

    curl --fail http://127.0.0.1:3001/health
    

    The first start generates a management key. Read it and store it safely:

    docker compose exec gpt-load sh -c 'cat /app/data/auth.key'
    

    Open http://127.0.0.1:3001 and sign in to the console with that key.

    You can also set AUTH_KEY explicitly in .env before starting. By default the service listens on the loopback address only and is not exposed to the internet.

    2. Initial configuration

    Initial setup takes three steps:

    1. Add a channel — Choose an upstream service and add one or more API keys. For subscription channels, complete the OAuth flow or import credentials as prompted.
    2. Create a group — Pick a channel, then configure available models and runtime policy.
    3. Create an AccessKey — Set the groups and client protocols it may use, then give the generated AccessKey to your application.

    The Codex, Claude, and Antigravity OAuth clients use fixed callback ports. Compose publishes them on the address configured by HOST, which defaults to 127.0.0.1; setting HOST=0.0.0.0 also publishes these callback ports on all host interfaces. Because the ports are fixed by the upstream clients, only one default Compose instance can run on a host at a time.

    When working over SSH or from a remote browser, the browser's localhost may not reach GPT-Load — paste the full callback URL into the authorization dialog to finish the flow.

    Screenshots

    Groups — View channels, models, credential counts, traffic, and health in one place

    Usage statistics — Review request trends, cache hit rate, token categories, and cost estimates

    Scope

    Client protocols

    ProtocolMain entry
    OpenAI Chat CompletionsPOST /v1/chat/completions
    OpenAI Responses/v1/responses and its resource paths
    OpenAI ImagesPOST /v1/images/...
    OpenAI EmbeddingsPOST /v1/embeddings
    RerankPOST /v1/rerank
    Audio SpeechPOST /v1/audio/speech
    Mistral native/v1/ocr, /v1/audio/transcriptions
    Anthropic MessagesPOST /v1/messages
    Gemini/v1beta/models/...
    Gemini EmbeddingsPOST /v1beta/models/{model}:embedContent / :batchEmbedContents

    Built-in channels

    • Official and cloud — OpenAI, Anthropic, Gemini, xAI, Azure OpenAI, AWS Bedrock, Google Vertex AI
    • Model services — DeepSeek, Moonshot AI, SiliconFlow, Zhipu AI, Alibaba, Volcengine, OpenRouter, Cline, Groq, Cerebras, Mistral, Nebius, Parasail, Wafer, Hugging Face (Chat), Cohere (text reranking), OpenCode Go, OpenCode Zen
    • Subscription — Codex, Claude, Antigravity, Grok
    • Custom — OpenAI Compatible (any compatible relay)

    Deployment and data

    Docker Compose uses application-managed SQLite by default. Data lives in the gpt-load-data named volume and includes the database, auth.key, and encryption.key.

    [!IMPORTANT] encryption.key decrypts channel credentials. When backing up or migrating, the database and the key must be kept together. Once the key is lost or replaced, existing encrypted credentials cannot be recovered, and this version does not support master key rotation.

    Use the unified DATABASE_DSN to connect SQLite, MySQL, or PostgreSQL:

    mysql://user:[email protected]:3306/gpt_load?charset=utf8mb4&collation=utf8mb4_bin
    postgres://user:[email protected]:5432/gpt_load?sslmode=require
    

    Common operations:

    docker compose logs -f      # view logs
    docker compose pull && docker compose up -d   # update to the latest 2.x image
    docker compose stop         # stop the service
    

    The official Compose file uses ghcr.io/tbphp/gpt-load:2. Before GA, 2 tracks verified 2.0 Beta and RC releases; after GA, it tracks stable 2.x releases only. Exact image tags omit the Git tag's v prefix (for example, 2.0.0-beta.25), while 2.0-beta remains the 2.0 Beta channel. latest remains on 1.x.

    Download the build for your platform from GitHub Releases, and verify it against the bundled SHA256SUMS first:

    chmod +x ./gpt-load-linux-amd64
    
    HOST=127.0.0.1 DATA_DIR=./data ./gpt-load-linux-amd64
    

    Then open http://127.0.0.1:3001. Portable builds are provided for five targets across Linux, macOS (amd64 / arm64), and Windows; gpt-load-windows-amd64.exe keeps running in the foreground as before.

    Windows desktop users can instead download gpt-load-windows-setup.exe. After one administrator approval, Setup installs and starts a low-privilege Windows service, enables automatic startup, and creates desktop and Start Menu shortcuts to the GPT-Load management page. Setup displays the generated management key before it finishes; save it before closing the page. The protected copy remains at %ProgramData%\GPT-Load\data\auth.key. Service configuration and its .env live in %ProgramData%\GPT-Load, with persistent data in %ProgramData%\GPT-Load\data.

    Installing a newer Setup stops the service gracefully before updating it. Windows uninstall removes the program and service but preserves data. Advanced users can still manage an installed service with gpt-load-windows-amd64.exe service start|stop|restart|status.

    Environment configuration

    At startup, the application reads .env in the current directory; existing process environment variables take precedence. Unless noted otherwise, changes require restarting the process or container; see .env.example for the common configuration template.

    VariableDefaultDescription
    HOST127.0.0.1Native listening address, and the default host address for Compose's main port and OAuth callback ports; Compose always listens on 0.0.0.0 inside the container.
    PORT3001HTTP service port, must be 1–65535; Compose also uses it for the container port, host publishing, and health check.
    BIND_ADDRESSEmpty, inherits HOSTCompose only; overrides the host publishing address for the main service port without changing OAuth callback ports.
    OAUTH_CALLBACK_BIND_ADDRESSEmpty, inherits HOSTCompose only; overrides the host publishing address for the fixed OAuth callback ports 1455, 54545, and 51121.
    GRACEFUL_SHUTDOWN_TIMEOUT10Maximum time to wait for requests after a stop signal, positive integer in seconds.
    CONTAINER_STOP_GRACE_PERIOD15sDocker duration to wait before Compose force-stops the container; should be longer than GRACEFUL_SHUTDOWN_TIMEOUT.
    READ_TIMEOUT60HTTP request read timeout, positive integer in seconds.
    IDLE_TIMEOUT120HTTP keep-alive idle connection timeout, positive integer in seconds.
    DATA_DIR./dataDirectory for the managed database, auth.key, encryption.key, and runtime state; official Compose uses /app/data, while the Windows Setup service uses %ProgramData%\GPT-Load\data.
    DATABASE_DSNEmpty, uses ${DATA_DIR}/gpt-load.dbEmpty uses application-managed SQLite; non-empty values support SQLite paths or URLs, MySQL URLs, and PostgreSQL URLs, and are treated as operator-managed external databases. Container file paths must be inside a mounted directory.
    DATABASE_MAX_OPEN_CONNECTIONS10Maximum open connections for MySQL and PostgreSQL, positive integer. SQLite always uses one connection.
    DATABASE_MAX_IDLE_CONNECTIONS5Maximum idle connections for MySQL and PostgreSQL, positive integer and no greater than DATABASE_MAX_OPEN_CONNECTIONS. SQLite always uses one connection.
    AUTH_KEYEmpty, reads or generates ${DATA_DIR}/auth.keyBearer key for the management UI and /api management API, not a data-plane AccessKey.
    ENCRYPTION_KEYEmpty, reads or generates ${DATA_DIR}/encryption.keyEncrypts channel credentials; changing or losing it makes existing credentials undecryptable, so back it up with the database.
    CLIENT_IP_HEADEREmpty, uses the connection IPClient IP header, such as X-Forwarded-For or CF-Connecting-IP; missing or invalid values fall back to the connection IP. Shared by logs, AccessKey IP restrictions, and other IP consumers; supports IPv4/IPv6. Restart after changes.
    TRUSTED_PROXIESEmptyOptional comma-separated proxy IPs or CIDRs; applies only with CLIENT_IP_HEADER. Empty means trusting the selected header directly, with trust enforced by your deployment. When set, only matching connection peers may supply the header; others use their connection IP. For X-Forwarded-For, scan right to left for the first untrusted IP (leftmost if all are trusted); without a list, use the leftmost IP. Other headers accept one IP only. Restart after changes.
    HTTP_PROXYEmptyEnvironment proxy for HTTP upstream requests.
    HTTPS_PROXYEmptyEnvironment proxy for HTTPS upstream requests.
    NO_PROXYEmptyComma-separated hosts, domains, or IPs that bypass the environment proxy.
    LOG_LEVELinfoSupports panic, fatal, error, warn, warning, info, debug, and trace; invalid values warn and fall back to info.
    LOG_FORMATtextSupports text and json; any other value fails startup.
    MODELS_DEV_AUTO_SYNC_ENABLEDUnset, initial default trueWhen unset, uses the persisted management UI setting; when set, forces Models.dev auto-sync on or off and makes the same UI option read-only.

    Environment proxies apply only when no proxy is specified on the credential, group, or global settings.

    Moving from 1.x

    [!WARNING] GPT-Load 2.0 is a complete rewrite. It cannot open, import, or migrate 1.x data in place.

    Deploy 2.0 with its own database, DATA_DIR, port, and Docker volume. Cut traffic over only after verification, and keep the original 1.x deployment until the rollback window closes. Documentation for the 1.4.x maintenance line is at the official docs.

    Open-source dependencies

    Some of GPT-Load's capabilities build on these projects, with thanks:

    ProjectRoleLicense
    Bifrost CoreProvider authentication, request/response conversion, streaming, usage normalizationApache-2.0
    CLIProxyAPIOAuth and execution adapter for subscription channelsMIT
    Lobe IconsChannel brand icons in the management UIMIT

    GPT-Load owns credential storage, account selection, scheduling, retry, health, affinity, logging, and usage policy. Third-party notices are in THIRD_PARTY_NOTICES.md, full license texts in LICENSES/, and each release ships a CycloneDX SBOM covering the Go dependency graph.

    Channel icons identify their respective upstream providers. All trademarks belong to their owners; this project is not affiliated with or endorsed by them.

    Project support


    MIT License · Third-party notices · Security policy