@router-brain/sdk is the official Node.js / TypeScript client for the Router Brain gateway. It gives you access to LLM chat, image generation, model discovery, and more — through a single API key.
What you can build
Chat applications — with streaming, function calling, and embeddings
Image generation — with both sync and async workflows
Model discovery — search and compare available models programmatically
Relevance ranking — rerank documents against a query for RAG pipelines
Where it works
Works well
Not suitable
Node.js backends, serverless, CLI tools
Browser (never expose your API key in client-side code)
TypeScript projects (full type support)
Environments without Node.js 18+
Core capabilities
What you want to do
How you do it
Chat with models (OpenAI protocol)
rb.openai().chat.completions.create(...)
Chat with models (Anthropic protocol)
rb.anthropic().messages.create(...)
Generate embeddings
rb.openai().embeddings.create(...)
Generate images
rb.image(...).json()
Stream image generation
rb.image(...).stream()
List and search models
rb.models(...)
Get model details
rb.modelEndpoint(...)
Rerank documents
rb.rerank(...)
Quick start
import { RouterBrain } from '@router-brain/sdk';
const rb = new RouterBrain('sk-your-api-key');
// Your first chat
const res = await rb.openai().chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(res.choices[0].message.content);