|
|
hai 2 semanas | |
|---|---|---|
| .github | hai 1 mes | |
| core | hai 2 semanas | |
| docs | hai 6 meses | |
| mcp-servers | hai 1 mes | |
| openapi-mcp | hai 1 mes | |
| scripts | hai 3 meses | |
| web | hai 4 meses | |
| .gitignore | hai 6 meses | |
| .golangci.yml | hai 1 mes | |
| Dockerfile | hai 1 mes | |
| LICENSE | hai 9 meses | |
| README.md | hai 1 mes | |
| README.zh.md | hai 1 mes | |
| config.example.yaml | hai 1 mes | |
| config.md | hai 1 mes | |
| docker-compose.yaml | hai 4 meses | |
| go.work | hai 2 meses | |
| go.work.sum | hai 1 mes |
Next-generation AI gateway with OpenAI-compatible protocol
[](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 is a powerful, production-ready AI gateway that provides intelligent request routing, comprehensive monitoring, and seamless multi-tenant management. Built with OpenAI-compatible, Anthropic and Gemini protocols, it serves as the perfect middleware for AI applications requiring reliability, scalability, and advanced features.
<think> tagsAI Proxy provides a management panel for managing AI Proxy's configuration and monitoring.
graph TB
Client[Client Applications] --> Gateway[AI Proxy Gateway]
Gateway --> Auth[Authentication & Authorization]
Gateway --> Router[Intelligent Router]
Gateway --> Monitor[Monitoring & Analytics]
Gateway --> Plugins[Plugin System]
Plugins --> CachePlugin[Cache Plugin]
Plugins --> SearchPlugin[Web Search Plugin]
Plugins --> ThinkSplitPlugin[Think Split Plugin]
Plugins --> StreamFakePlugin[Stream Fake Plugin]
Router --> Provider1[OpenAI]
Router --> Provider2[Anthropic]
Router --> Provider3[Azure OpenAI]
Router --> ProviderN[Other Providers]
Gateway --> MCP[MCP Servers]
MCP --> PublicMCP[Public MCP]
MCP --> GroupMCP[Organization MCP]
MCP --> EmbedMCP[Embedded MCP]
Monitor --> Alerts[Alert System]
Monitor --> Analytics[Analytics Dashboard]
Monitor --> Logs[Audit Logs]
# Quick start with default configuration
docker run -d \
--name aiproxy \
-p 3000:3000 \
-v $(pwd)/aiproxy:/aiproxy \
-e ADMIN_KEY=your-admin-key \
ghcr.io/labring/aiproxy:latest
# Nightly build
docker run -d \
--name aiproxy \
-p 3000:3000 \
-v $(pwd)/aiproxy:/aiproxy \
-e ADMIN_KEY=your-admin-key \
ghcr.io/labring/aiproxy:main
# Download docker-compose.yaml
curl -O https://raw.githubusercontent.com/labring/aiproxy/main/docker-compose.yaml
# Start services
docker-compose up -d
LISTEN=:3000 # Server listen address
ADMIN_KEY=your-admin-key # Admin API key
SQL_DSN=postgres://user:pass@host:5432/db # Primary database
LOG_SQL_DSN=postgres://user:pass@host:5432/log_db # Log database (optional)
REDIS=redis://localhost:6379 # Redis for caching
BILLING_ENABLED=true # Enable billing features
SAVE_ALL_LOG_DETAIL=true # Log all request details
AI Proxy supports a plugin system that extends its functionality. Currently available plugins:
The Cache Plugin provides high-performance caching for AI API requests:
View Cache Plugin Documentation
The Web Search Plugin adds real-time web search capabilities:
View Web Search Plugin Documentation
The Think Split Plugin supports content splitting for reasoning models:
<think>...</think> tags in responsesreasoning_content fieldView Think Split Plugin Documentation
The Stream Fake Plugin solves timeout issues with non-streaming requests:
View Stream Fake Plugin Documentation
Visit http://localhost:3000/swagger/index.html for the complete API documentation with interactive examples.
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": "Hello!"}]
}'
# Use Claude models through OpenAI API format
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": "Hello Claude!"}]
}'
Deploy instantly on Sealos with built-in model capabilities: Deploy to Sealos
Seamlessly integrate with FastGPT for enhanced AI workflows: FastGPT Documentation
Use AI Proxy with Claude Code by configuring these environment variables:
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
Use AI Proxy with Gemini CLI by configuring these environment variables:
export GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:3000
export GEMINI_API_KEY=sk-xxx
Alternatively, you can use the /auth command in the Gemini CLI to output the GEMINI_API_KEY.
Use AI Proxy with Codex by configuring ~/.codex/config.toml:
# Recall that in TOML, root keys must be listed before tables.
model = "gpt-4o"
model_provider = "aiproxy"
[model_providers.aiproxy]
# Name of the provider that will be displayed in the Codex UI.
name = "AIProxy"
# The path `/chat/completions` will be amended to this URL to make the POST
# request for the chat completions.
base_url = "http://127.0.0.1:3000/v1"
# If `env_key` is set, identifies an environment variable that must be set when
# using Codex with this provider. The value of the environment variable must be
# non-empty and will be used in the `Bearer TOKEN` HTTP header for the POST request.
env_key = "AIPROXY_API_KEY"
# Valid values for wire_api are "chat" and "responses". Defaults to "chat" if omitted.
wire_api = "chat"
Protocol Conversion Support:
AI Proxy provides comprehensive MCP support for extending AI capabilities:
# Clone repository
git clone https://github.com/labring/aiproxy.git
cd aiproxy
# Build frontend (optional)
cd web && npm install -g pnpm && pnpm install && pnpm run build && cp -r dist ../core/public/dist/ && cd ..
# Build backend
cd core && go build -o aiproxy .
# Run
./aiproxy
We welcome contributions! Please see our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.