Migration Guide
Migrate from 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-5",
+ model: "anthropic/claude-sonnet-5",
- max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
Using the BrainstormRouter SDK
For full access to BrainstormRouter-specific features (memory, guardrails, governance), use the official SDK:
npm install brainstormrouter
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 | OpenAI |
|---|---|
BRAINSTORMROUTER_API_KEY | OPENAI_API_KEY |
The SDK reads BRAINSTORMROUTER_API_KEY automatically.