Build with BrainstormRouter
OpenAI & Anthropic-compatible API, TypeScript & Python SDKs, MCP server, and full machine-readable discovery. One base URL swap — zero code changes.
TypeScript SDK
Drop-in OpenAI replacement. Works with LangChain, Vercel AI, CrewAI.
npm install brainstormrouter
import BrainstormRouter from "brainstormrouter";
const client = new BrainstormRouter({
apiKey: "brk_..."
});
const res = await client.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Hello" }],
});
Python SDK
Drop-in OpenAI replacement. Works with LangChain, LlamaIndex, CrewAI.
pip install brainstormrouter
from brainstormrouter import BrainstormRouter
client = BrainstormRouter(api_key="brk_...")
res = client.chat.completions.create(
model="auto",
messages=[{"role": "user",
"content": "Hello"}],
)
REST API OpenAI & Anthropic-compatible
Use any HTTP client. Same /v1/chat/completions contract as OpenAI.
curl -X POST https://api.brainstormrouter.com/v1/chat/completions \
-H "Authorization: Bearer brk_..." \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [{"role":"user","content":"Hello"}],
"stream": true
}'
MCP Server
Connect from Claude Desktop, Cursor, Windsurf, or any MCP client.
Endpoint:
POST https://api.brainstormrouter.com/v1/mcp/connect
Transport: Streamable HTTP
Auth: Bearer API key
65 tools available — routing, memory, security, governance, budget, and more.
br_route_completion— Route a chat completionbr_memory_store— Persistent agent memorybr_get_leaderboard— Model performance rankingsbr_replay_decisions— Review routing decisions- View all 65 tools →
AI Discovery
Machine-readable manifests so AI agents and coding assistants can find BrainstormRouter automatically.
GET /v1/discovery— Live capability discovery (call first after auth)- llms.txt — Concise AI-readable site map
- llms-full.txt — Complete API reference (all routes)
- ai-plugin.json — OpenAI plugin manifest
- agents.json — Agent capability discovery
- openapi.json — OpenAPI 3.1 spec
Integrations
BrainstormRouter is a drop-in swap for any OpenAI or Anthropic-compatible tool.
Authentication
Create an API key from the dashboard or via the API:
# Create a key
curl -X POST https://api.brainstormrouter.com/v1/api-keys \
-H "Authorization: Bearer brk_existing_key" \
-H "Content-Type: application/json" \
-d '{"name": "my-agent", "permissions": ["completions", "memory.read"]}'
# Use it
curl https://api.brainstormrouter.com/v1/models \
-H "Authorization: Bearer brk_new_key"
BrainstormRouter also supports Supabase JWT (dashboard), Agent JWT (CAF), mTLS (mesh agents), and SCIM bearer tokens (identity providers).
5 Authentication Methods
| Method | Header | Use Case |
|---|---|---|
| API Key | Authorization: Bearer br_live_... | SDKs, scripts, automation |
| Supabase JWT | Authorization: Bearer eyJ... | Dashboard, browser-based UIs |
| Agent JWT | Authorization: Bearer <signed JWT> | CAF agent identity, CSR exchange |
| mTLS | X-Amzn-Mtls-Clientcert | Mesh agents, zero-trust |
| SCIM | Authorization: Bearer <SCIM token> | Identity providers (Okta, Azure AD) |
Auto-Routing Variants
Set model to one of these values and the router picks the optimal endpoint:
| MODEL VALUE | STRATEGY | USE CASE |
|---|---|---|
auto | Thompson Sampling (UCB1 + Gaussian posterior) | General workloads — learns optimal model per task type |
auto:fast | Lowest p50 latency | Real-time UX, streaming interfaces |
auto:floor | Cheapest model above quality threshold | Bulk processing, classification, triage |
auto:best | Highest quality regardless of cost | Critical reasoning, code review, legal |
Prometheus test data: Thompson sampling routes simple tasks to DeepSeek at $0.000005/req and complex tasks to Claude Opus at $0.000156/req — a 31x cost difference, chosen automatically.
Intelligence Headers
Every response includes machine-readable headers describing what happened:
| HEADER | VALUE |
|---|---|
X-BR-Model-Requested | What you asked for (auto, gpt-4o, etc.) |
X-BR-Model-Resolved | What was actually used |
X-BR-Provider | Provider that served the request |
X-BR-Route-Strategy | Routing strategy used |
X-BR-Estimated-Cost | Pre-execution cost estimate (USD) |
X-BR-Actual-Cost | Actual cost after execution |
X-BR-Efficiency | Estimated / actual cost ratio |
X-BR-Cache-Status | HIT, MISS, or BYPASS |
X-BR-Guardian-Status | ok, warning, or blocked |
X-BR-Guardian-Overhead-Ms | Guardian processing time (target <5ms p95) |
X-BR-Request-Id | Unique request ID for audit trail |
X-BR-Tenant-Id | Your tenant ID |
Error Recovery
Every error response includes a machine-actionable recovery field:
{
"error": {
"type": "budget_exceeded",
"message": "Daily budget limit of $5.00 reached",
"recovery": {
"action": "wait_or_upgrade",
"retry_after": "2026-03-18T00:00:00Z",
"alternative": "Use auto:floor for lower-cost routing",
"dashboard_url": "https://brainstormrouter.com/dashboard"
}
}
}
Agents can programmatically read the recovery field to decide their next action without human intervention.