Migration Guide
Migrate from OpenRouter, Portkey, or direct provider APIs in minutes.
From OpenAI direct
If you're calling OpenAI directly, add two lines:
import OpenAI from "openai";
const client = new OpenAI({
+ baseURL: "https://api.brainstormrouter.com/v1",
+ apiKey: "br_live_...",
});
const response = await client.chat.completions.create({
- model: "gpt-4o",
+ model: "openai/gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});
What you gain: Cost tracking, fallback routing, rate limit protection, caching, and persistent memory — all without changing your application logic.
From Anthropic direct
- import Anthropic from "@anthropic-ai/sdk";
+ import OpenAI from "openai";
- const client = new Anthropic({ apiKey: "sk-ant-..." });
+ const client = new OpenAI({
+ baseURL: "https://api.brainstormrouter.com/v1",
+ apiKey: "br_live_...",
+ });
- const response = await client.messages.create({
+ const response = await client.chat.completions.create({
- model: "claude-sonnet-4-5",
+ model: "anthropic/claude-sonnet-4-5",
- max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
From OpenRouter
OpenRouter and BrainstormRouter both use the OpenAI SDK. Just change the URL and key:
const client = new OpenAI({
- baseURL: "https://openrouter.ai/api/v1",
- apiKey: "sk-or-v1-...",
+ baseURL: "https://api.brainstormrouter.com/v1",
+ apiKey: "br_live_...",
});
Model names are identical — anthropic/claude-sonnet-4-5 works on both.
What BrainstormRouter adds over OpenRouter:
- Persistent agent memory (RMM)
- Prompt management with A/B testing
- Guardrail pipeline (PII, jailbreak, custom)
- Observability broadcasting (webhook, OTLP, Datadog)
- Governance and compliance dashboards
- MCP gateway for external tool access
From Portkey
- import Portkey from "portkey-ai";
+ import OpenAI from "openai";
- const client = new Portkey({
- apiKey: "...",
- virtualKey: "...",
- });
+ const client = new OpenAI({
+ baseURL: "https://api.brainstormrouter.com/v1",
+ apiKey: "br_live_...",
+ });
What BrainstormRouter adds over Portkey:
- Built-in persistent memory (no external vector DB needed)
- Autonomous agent engine (The Soul)
- Sleep-time memory refinement
- Governance audit trails with compliance scanning
Using the BrainstormRouter SDK
For full access to BrainstormRouter-specific features (memory, guardrails, governance), use the official SDK:
import BrainstormRouter from "brainstormrouter";
const client = new BrainstormRouter({ apiKey: "br_live_..." });
// Standard completions still work
await client.chat.completions.create({ ... });
// Plus BrainstormRouter-specific APIs
await client.memory.append("User prefers dark mode", { block: "human" });
await client.guardrails.test("Check this content for PII");
const summary = await client.governance.summary();
Environment variables
| BrainstormRouter | OpenRouter | Portkey | OpenAI |
|---|---|---|---|
BRAINSTORMROUTER_API_KEY | OPENROUTER_API_KEY | PORTKEY_API_KEY | OPENAI_API_KEY |
The SDK reads BRAINSTORMROUTER_API_KEY automatically.