TypeScript SDK Overview

Get started with @therouter/sdk in Node.js and edge runtimes.

Installation

npm
npm install @therouter/sdk

Initialization

client.ts
import { TheRouter.ai } from "@therouter/sdk";

export const client = new TheRouter.ai({
  apiKey: process.env.THEROUTER_API_KEY!,
  baseURL: "https://api.therouter.ai/v1",
});
NameTypeRequiredDescription
apiKey
stringRequiredAPI key from THEROUTER_API_KEY.
baseURL
stringDefaults to https://api.therouter.ai/v1.
timeout
integerRequest timeout in milliseconds.

Basic Usage

Responses API
const response = await client.responses.create({
  model: "openai/gpt-4o-mini",
  input: "Summarize the daily incident report in 3 bullets.",
});

console.log(response.output_text);
Environment variables
Store your key in THEROUTER_API_KEY and avoid hardcoding credentials in source files.