Models and providers (TypeScript)
Use the model catalog and models.list to discover available model IDs. The OpenAI client does not expose the former client.providers.list or provider-health management methods for TheRouter.
This guide uses the official OpenAI client with TheRouter; it is not a TheRouter-owned SDK. The therouter and @therouter/sdk packages previously named here are not currently published in the public package registries.
Install and run
bash
npm install openaiSet THEROUTER_API_KEY on your server, then run:
typescript
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.THEROUTER_API_KEY, baseURL: "https://api.therouter.ai/v1" });
const models = await client.models.list();
for (const model of models.data) console.log(model.id);