TypeScript SDK Overview
Get started with @therouter/sdk in Node.js and edge runtimes.
Installation
npm
npm install @therouter/sdkInitialization
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",
});| Name | Type | Required | Description |
|---|---|---|---|
apiKey | string | Required | API key from THEROUTER_API_KEY. |
baseURL | string | Defaults to https://api.therouter.ai/v1. | |
timeout | integer | Request 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.