routerbase-quickstart
v0.1.0
Published
A tiny Node.js quickstart and CLI for the RouterBase OpenAI-compatible API.
Maintainers
Readme
RouterBase Quickstart
RouterBase is an OpenAI-compatible API gateway for calling many frontier AI models through one base URL: https://routerbase.com/v1.
This package gives Node.js developers a tiny, dependency-free helper and CLI for trying RouterBase chat completions without changing their app architecture.
Why RouterBase
- One OpenAI-compatible API surface for chat, image, video, audio, and embeddings.
- Use the same
Authorization: Bearer <YOUR_API_KEY>andContent-Type: application/jsonheaders you already know. - Point compatible clients at
https://routerbase.com/v1. - Try models such as Gemini, Claude, GPT, DeepSeek, Mistral, and more from one account.
Learn more at RouterBase or read the docs at docs.routerbase.com.
Install
npm install routerbase-quickstartCLI
Set your API key:
export ROUTERBASE_API_KEY="sk-rb-..."Ask a quick question:
npx routerbase-quickstart --prompt "Write a one sentence product tagline for RouterBase"Choose a model:
npx routerbase-quickstart --model google/gemini-2.5-flash --prompt "What is 2+2?"Print the raw JSON response:
npx routerbase-quickstart --json --prompt "Return a tiny JSON object"JavaScript
import { chatCompletion } from "routerbase-quickstart";
const response = await chatCompletion({
apiKey: process.env.ROUTERBASE_API_KEY,
model: "google/gemini-2.5-flash",
messages: [
{ role: "user", content: "Write a haiku about routing AI models." }
]
});
console.log(response.choices[0].message.content);API
chatCompletion(options)
Sends a POST /chat/completions request to the RouterBase OpenAI-compatible API.
Options:
apiKey: RouterBase API key. Defaults toprocess.env.ROUTERBASE_API_KEY.baseURL: Defaults tohttps://routerbase.com/v1.model: Defaults togoogle/gemini-2.5-flash.messages: Required OpenAI-style message array.- Any other fields are forwarded to the RouterBase API body, such as
temperature,max_tokens,stream,tools, orresponse_format.
createRouterBaseClient(options)
Creates a tiny client wrapper:
import { createRouterBaseClient } from "routerbase-quickstart";
const routerbase = createRouterBaseClient({
apiKey: process.env.ROUTERBASE_API_KEY
});
const response = await routerbase.chat.completions.create({
model: "google/gemini-2.5-flash",
messages: [{ role: "user", content: "Hello RouterBase" }]
});Notes
This is a lightweight community quickstart. For full API details, model availability, pricing, and production guidance, use the official RouterBase documentation:
