@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 wellNot suitable
Node.js backends, serverless, CLI toolsBrowser (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 doHow you do it
Chat with models (OpenAI protocol)rb.openai().chat.completions.create(...)
Chat with models (Anthropic protocol)rb.anthropic().messages.create(...)
Generate embeddingsrb.openai().embeddings.create(...)
Generate imagesrb.image(...).json()
Stream image generationrb.image(...).stream()
List and search modelsrb.models(...)
Get model detailsrb.modelEndpoint(...)
Rerank documentsrb.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);

Next steps

InstallationInitializationChat and streaming