ferro-labs /ai-gateway
Unified AI Gateway for 30+ LLMs (OpenAI, Anthropic, Bedrock, Azure etc) with Caching, Guardrails, A/B test & cost controls. Go-native Fastest & Scalable AI Gateway LiteLLM & Kong AI Gateway alternative.
★ 301⑂ 39👁 6⑃ 315● 141▤ 74
+0
日增长
301
stars
39
forks
6
watchers
315
prs
141
issues
74
releases
README
English | 中文
Ferro Labs AI 网关
开源、OpenAI 兼容的 LLM 网关
Go 语言编写的高性能 AI 网关。通过单一 OpenAI 兼容 API,将 LLM 请求路由至 30 个提供商。
📖 文档: docs.ferrolabs.ai
🔀 30 个提供商、2,500+ 个模型 —— 统一 API
⚡ 1,000 并发用户下 13,925 RPS(v1.0.0 基准测试)
📦 单一静态二进制文件,无需外部服务,32 MB 基础内存
---
快速开始
从安装到第一个响应,不到两分钟。
| 平台 / 工具 | 安装方式 |
|:---|:---|
| macOS、Linux | curl -fsSL https://get.ferrolabs.ai \| sh |
| Windows | irm https://get.ferrolabs.ai/install.ps1 \| iex |
| Homebrew | brew install ferro-labs/tap/ferrogw |
| Scoop | 先 scoop bucket add ferrolabs https://github.com/ferro-labs/homebrew-tap 然后 scoop install ferrogw |
| npm | npm install -g ferrogw |
| Python | uv tool install ferrogw |
| Docker | docker run -p 8080:8080 ghcr.io/ferro-labs/ai-gateway:latest |
| Go | go install github.com/ferro-labs/ai-gateway/cmd/ferrogw@latest —— 从源码构建,不含控制台 |
| Debian、RPM、Alpine | 发布页面 提供 .deb、.rpm 与 .apk 软件包 |
然后从零跑通第一个请求:
bash
export OPENAI_API_KEY=sk-your-key ferrogw init 会检测到它,并写入对应的目标
ferrogw init 生成 config.yaml,并打印你的主密钥
export GATEWAY_CONFIG=./config.yaml 只有设置了它,服务端才会读取配置文件
export MASTER_KEY=fgw_your-master-key ferrogw init 打印出来的那个密钥
ferrogw serve 在 :8080 启动服务
ferrogw init 只会打印一次主密钥,并且不会把它写入磁盘 —— 请你自己保存,
放进 .env 文件或密钥管理服务中。
Docker 会自己运行服务端,因此不会有 ferrogw init 来打印主密钥 —— 请自行选定一个。
按变量名传入这两个变量,密钥的值就不会出现在命令行上(否则 ps 就能看到):
bash
export OPENAI_API_KEY=sk-your-key
export MASTER_KEY=fgw-any-strong-secret-you-choose
docker run -p 8080:8080 -e OPENAI_API_KEY -e MASTER_KEY ghcr.io/ferro-labs/ai-gateway:latest
按变量名传入只能让密钥的值不出现在进程参数里 —— 它们仍然可以从容器环境和
docker inspect 中读到,因此生产环境请使用 Docker secrets 或平台提供的密钥存储。
第一个请求
bash
export MASTER_KEY=fgw_your-master-key ferrogw init 打印出来的那个密钥;在哪个 shell 里跑 curl,就在哪个 shell 里导出
curl http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer $MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello from Ferro Labs AI Gateway"}]
}' | jq
每个版本都使用 keyless cosign 签名,并附带 SPDX SBOM ——
校验步骤见 SECURITY.md。
---
为什么选择 Ferro Labs AI 网关
不同 AI 网关的差异主要体现在高负载下的吞吐量、延迟与内存占用上。Ferro Labs AI 网关从头用 Go 编写,为真实场景的吞吐量而生 —— 单一二进制文件,以可预期的延迟和极低的资源占用路由 LLM 请求。
| 特性 | Ferro Labs | LiteLLM | Bifrost | Kong AI |
|:-----------------|:------------|:--------|:-----------|:------------|
| 语言 | Go | Python | Go | Go/Lua |
| 单一二进制文件 | ✅ | ❌ | ✅ | ❌ |
| 提供商数量 | 30 | 100+ | 20+ | 10+ |
| MCP 支持 | ✅ | ❌ | ✅ | ❌ |
| 响应缓存 | ✅ | ✅ | ✅ | ❌(付费) |
| 护栏 | ✅ | ✅ | ❌ | ❌(付费) |
| 开源许可证 | Apache 2.0 | MIT | Apache 2.0 | Apache 2.0 |
| 托管云服务 | 即将推出 | ✅ | ✅ | ✅ |
---
功能特性
| 能力 | 作用 | 参考 |
|:---|:---|:---|
| 🔀 路由 | 8 种策略 —— 单一、回退、负载均衡、最低延迟、成本优化、基于内容、A/B 测试、条件路由Top issues
#360mcp: migrate to the official Go MCP SDK3 comments · 2026-07-21#361mcp: restart a crashed stdio server with backoff2 comments · 2026-07-21#208feat(plugin): streaming-aware stage + optional StreamInspector (additive)2 comments · 2026-06-18#358mcp: a Streamable HTTP server that dies after initialization is never detected1 comments · 2026-07-21#245feat(providers): add NeuralWatt energy-efficient inference provider1 comments · 2026-06-28#244feat(strategies/cost): add CapabilityAggregator to prevent opaque-cost misrouting in CostOptimized1 comments · 2026-06-28#451Plugin pattern: external source-rights evidence before MCP tool execution0 comments · 2026-10-06#427Dashboard: move admin session token from sessionStorage to an HttpOnly cookie0 comments · 2026-09-03
Discussions
#179Which framework integration should AI Gateway prioritize next?0 comments · 2026-06-02#178What cookbook recipes should AI Gateway publish next?3 comments · 2026-06-02#177Which observability bridge should AI Gateway ship first?0 comments · 2026-06-02#176RFC: v1.5 Plugin SDK for AI Gateway1 comments · 2026-06-02#42Welcome to ai-gateway Discussions!0 comments · 2026-03-12
Latest release
v1.6.1 v1.6.1 2026-11-15[1.6.1] — 2026-11-15 Security fixes for v1.6.1. No API, configuration, or dashboard sign-in changes. Building the gateway, or a module that imports it, now needs Go 1.26.11 or later. Security - Go 1.26.10 → 1.26.11 fixes GO-2026-6859 (CVE-2026-97054): an HTTP/1 server using MaxBytesReader could panic when an over-limit body read raced with a response-header write. CI, release builds and the Docker build use the patched toolchain. - OpenTelemetry v1.45.0 → v1.47.0 fixes GHSA-q7gw-24fr-5p69: strings containing Unicode replacement characters could bypass attribute length limits. The