AI Gateway & Cost Protection
If you build an AI tool on ButtrBase and give users access to an LLM, a single malicious user can run up a massive OpenAI bill.
ButtrBase includes a built-in AI Gateway layer to protect your margins. Instead of calling OpenAI or Anthropic directly, configure gateway policy via the management API and route inference calls through the gateway.
---
Management API
PUT /api/ops/ai-gateway-config
Set the default AI provider and monthly spend cap.
curl -X PUT https://api.buttrbase.com/api/ops/ai-gateway-config \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{"provider":"anthropic","budget_usd":500}'
Providers: openai · anthropic · azure · google · cohere
Response: {"ok":true}
---
PUT /api/ops/ai-routing-config
Configure smart SLM/LLM routing with optional auto-escalation.
curl -X PUT https://api.buttrbase.com/api/ops/ai-routing-config \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{"slm":"claude-haiku-3","llm":"claude-sonnet-4-5","auto_escalate":true}'
Response: {"ok":true}
---
GET /api/billing/metering/meters
List billing meters (API calls, AI tokens, storage, etc.).
curl https://api.buttrbase.com/api/billing/metering/meters \
-H "Authorization: Bearer "
{
"data": [
{"id":"m_api_calls","name":"API Calls","event_name":"api.call","unit":"request","status":"active"},
{"id":"m_ai_tokens","name":"AI Tokens","event_name":"ai.tokens","unit":"token","status":"active"}
]
}
---
GET /api/ops/mcp-servers
List MCP (Model Context Protocol) servers registered with your app.
curl https://api.buttrbase.com/api/ops/mcp-servers \
-H "Authorization: Bearer "
{"data":[{"id":"mcp_1","name":"Database MCP","status":"active","install_command":"npx @buttrbase/mcp-db"}]}
---
> Implementation note:* Gateway and routing config are stored in *Dragonfly (HSET) for sub-millisecond reads on the hot inference path — changes take effect immediately without a redeploy.