Providers
OpenRouter (OpenAI-compatible endpoint)
OpenRouter uses the OpenAI SDK shape with a different baseURL and key -- the wrap is identical to the direct OpenAI recipe.
← All recipes
import { Klaro, retries, budget } from "@klaroshield/sdk";
import OpenAI from "openai";
const openrouter = new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: "https://openrouter.ai/api/v1",
});
const klaro = new Klaro()
.use(retries({ max: 3 }))
.use(budget({ maxMonthlyUsd: 50 }));
const chat = klaro.wrap(
openrouter.chat.completions.create.bind(openrouter.chat.completions)
);Checked against the shipped @klaroshield/sdk API. Full docs at klaro.services/klaroshield/docs.