Loading application instructions (TypeScript)

Load trusted instructions in your application and include the relevant text in the messages you send. The verified OpenAI-compatible client does not have a TheRouter skills-loader API; never treat untrusted text as a privileged instruction.

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 openai

Set 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 completion = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [{ role: "user", content: "Hello!" }],
  max_tokens: 32,
});
console.log(completion.choices[0]?.message.content);

Related resources

Help & contact