Research Project This is a free AI research project. No warranties, SLAs, or company associations. Learn more
Developer Portal

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 completion
  • br_memory_store — Persistent agent memory
  • br_get_leaderboard — Model performance rankings
  • br_replay_decisions — Review routing decisions
  • View all 65 tools →

AI Discovery

Machine-readable manifests so AI agents and coding assistants can find BrainstormRouter automatically.

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 KeyAuthorization: Bearer br_live_...SDKs, scripts, automation
Supabase JWTAuthorization: Bearer eyJ...Dashboard, browser-based UIs
Agent JWTAuthorization: Bearer <signed JWT>CAF agent identity, CSR exchange
mTLSX-Amzn-Mtls-ClientcertMesh agents, zero-trust
SCIMAuthorization: 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
autoThompson Sampling (UCB1 + Gaussian posterior)General workloads — learns optimal model per task type
auto:fastLowest p50 latencyReal-time UX, streaming interfaces
auto:floorCheapest model above quality thresholdBulk processing, classification, triage
auto:bestHighest quality regardless of costCritical 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-RequestedWhat you asked for (auto, gpt-4o, etc.)
X-BR-Model-ResolvedWhat was actually used
X-BR-ProviderProvider that served the request
X-BR-Route-StrategyRouting strategy used
X-BR-Estimated-CostPre-execution cost estimate (USD)
X-BR-Actual-CostActual cost after execution
X-BR-EfficiencyEstimated / actual cost ratio
X-BR-Cache-StatusHIT, MISS, or BYPASS
X-BR-Guardian-Statusok, warning, or blocked
X-BR-Guardian-Overhead-MsGuardian processing time (target <5ms p95)
X-BR-Request-IdUnique request ID for audit trail
X-BR-Tenant-IdYour 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.