新一代 AI 网关,采用 OpenAI 兼容协议
[](https://github.com/labring/aiproxy/releases) [](https://github.com/labring/aiproxy/blob/main/LICENSE) [](https://github.com/labring/aiproxy/blob/main/core/go.mod) [](https://github.com/labring/aiproxy/actions) [English](./README.md) | [简体中文](./README.zh.md)AI Proxy 是一个强大的、生产就绪的 AI 网关,提供智能请求路由、全面监控和无缝多租户管理。基于 OpenAI、Anthropic 兼容协议构建,是需要可靠性、可扩展性和高级功能的 AI 应用的完美中间件。
<think> 标签AI Proxy 提供了一个管理面板,用于管理 AI Proxy 的配置和监控。
graph TB
Client[客户端应用] --> Gateway[AI Proxy 网关]
Gateway --> Auth[身份验证与授权]
Gateway --> Router[智能路由器]
Gateway --> Monitor[监控与分析]
Gateway --> Plugins[插件系统]
Plugins --> CachePlugin[缓存插件]
Plugins --> SearchPlugin[网络搜索插件]
Plugins --> ThinkSplitPlugin[思考模式插件]
Plugins --> StreamFakePlugin[流式伪装插件]
Router --> Provider1[OpenAI]
Router --> Provider2[Anthropic]
Router --> Provider3[Azure OpenAI]
Router --> ProviderN[其他提供商]
Gateway --> MCP[MCP 服务器]
MCP --> PublicMCP[公共 MCP]
MCP --> GroupMCP[组织 MCP]
MCP --> EmbedMCP[嵌入式 MCP]
Monitor --> Alerts[告警系统]
Monitor --> Analytics[分析仪表板]
Monitor --> Logs[审计日志]
# 使用默认配置快速启动
docker run -d \
--name aiproxy \
-p 3000:3000 \
-v $(pwd)/aiproxy:/aiproxy \
-e ADMIN_KEY=your-admin-key \
registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:latest
# 夜间构建
docker run -d \
--name aiproxy \
-p 3000:3000 \
-v $(pwd)/aiproxy:/aiproxy \
-e ADMIN_KEY=your-admin-key \
registry.cn-hangzhou.aliyuncs.com/labring/aiproxy:main
# 下载 docker-compose.yaml
curl -O https://raw.githubusercontent.com/labring/aiproxy/main/docker-compose.yaml
# 启动服务
docker-compose up -d
LISTEN=:3000 # 服务器监听地址
ADMIN_KEY=your-admin-key # 管理员 API 密钥
SQL_DSN=postgres://user:pass@host:5432/db # 主数据库
LOG_SQL_DSN=postgres://user:pass@host:5432/log_db # 日志数据库(可选)
REDIS=redis://localhost:6379 # Redis 缓存
BILLING_ENABLED=true # 启用计费功能
SAVE_ALL_LOG_DETAIL=true # 记录所有请求详情
AI Proxy 支持插件系统来扩展其功能。当前可用的插件:
缓存插件为 AI API 请求提供高性能缓存:
网络搜索插件添加实时网络搜索功能:
思考模式插件支持思考模式的内容分割:
<think>...</think> 标签reasoning_content 字段流式伪装插件解决非流式请求的超时问题:
访问 http://localhost:3000/swagger/index.html 查看完整的 API 文档和交互示例。
curl -H "Authorization: Bearer your-token" \
http://localhost:3000/v1/models
curl -X POST http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "你好!"}]
}'
# 通过 OpenAI API 格式使用 Claude 模型
curl -X POST http://localhost:3000/v1/messages \
-H "X-Api-Key: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5",
"messages": [{"role": "user", "content": "你好 Claude!"}]
}'
在 Sealos 上一键部署,享受内置模型能力: 部署到 Sealos
与 FastGPT 无缝集成,增强 AI 工作流: FastGPT 文档
通过配置以下环境变量在 Claude Code 中使用 AI Proxy:
export ANTHROPIC_BASE_URL=http://127.0.0.1:3000
export ANTHROPIC_AUTH_TOKEN=sk-xxx
export ANTHROPIC_MODEL=gpt-5
export ANTHROPIC_SMALL_FAST_MODEL=gpt-5-nano
AI Proxy 提供全面的 MCP 支持,扩展 AI 能力:
# 克隆仓库
git clone https://github.com/labring/aiproxy.git
cd aiproxy
# 构建前端(可选)
cd web && npm install -g pnpm && pnpm install && pnpm run build && cp -r dist ../core/public/dist/ && cd ..
# 构建后端
cd core && go build -o aiproxy .
# 运行
./aiproxy
我们欢迎贡献!请查看我们的贡献指南了解详情。
本项目采用 MIT 协议 - 详见 LICENSE 文件。