OpenAI-compatible API proxy service that intelligently routes requests to multiple upstream providers based on content conditions.
MAS is a lightweight FastAPI server that receives OpenAI-compatible chat completion requests, automatically selects the best model based on configured conditions, and proxies the request to the upstream API.
Key Features:
- Smart Model Selection: Intelligently select the most suitable model based on message content
- OpenAI Compatible: Drop-in replacement for OpenAI's
/chat/completionsendpoint - Service Management CLI:
mas start/stop/status/restart/configcommands - Streaming Support: Support both streaming and non-streaming responses
./install.shmas start # Start service (default port 8000)
mas status # Check service status
mas stop # Stop service
mas restart # Restart serviceHealth Check:
curl http://localhost:8000/healthChat Completion (auto model selection):
curl -X POST http://localhost:8000/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Write a quicksort function"}],
"stream": false
}'Streaming:
curl -X POST http://localhost:8000/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'Edit ~/.mas/config.json (auto-created on first run):
{
"baseURL": "https://api.aiproxy.shop/v1",
"apiKey": "your-api-key-here",
"models": [
{
"condition": "programming, code examples, debugging",
"model": "gpt-4"
},
{
"condition": "casual chat, greetings, conversation",
"model": "gpt-3.5-turbo"
}
]
}Configuration Fields:
baseURL: Upstream API endpoint URLapiKey: Upstream API authentication keymodels: List of model configurationscondition: Natural language description of when to use this modelmodel: Model identifier
Use Custom Config File:
export MAS_CONFIG_PATH=/path/to/config.json
mas startView Current Configuration:
mas configMIT