OpenRouter client with idapt
Change one URL: OpenRouter request shapes, provider routing, and model fallbacks keep working.
- 1
Point it at idapt
tsconst reply = await fetch("https://idapt.app/api/openrouter/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.IDAPT_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "z-ai/glm-5.2", messages: [{ role: "user", content: "Three facts about ravens." }], }), }).then((r) => r.json());OpenRouter client libraries are plain HTTP clients: point theirs, or any fetch call, at the idapt path.
- 2
Streaming
tsbody: JSON.stringify({ model: "z-ai/glm-5.2", models: ["z-ai/glm-5.2", "qwen/qwen3.7-max"], // ordered fallback provider: { sort: "price", allow_fallbacks: true }, messages: [{ role: "user", content: "Stream a haiku." }], stream: true, })models[] is an ordered fallback list; provider routing and suffixes ride on top of the OpenAI shape. Responses carry usage.cost.
- 3
Going further
tsbody: JSON.stringify({ model: "z-ai/glm-5.2:nitro", // speed-priority routing suffix messages: [{ role: "user", content: "Three facts about ravens." }], })Suffixes (:nitro, :floor, :online, :free, :thinking, :extended) change routing; key, credits, and keys endpoints manage keys with USD caps.
GOOD TO KNOW
API keys and scopesOpenAI-compatible API referenceOpenRouter-compatible API referenceRate limits and errorsSwitch from OpenRouter