OpenRouter client with idapt
Found this helpful? Share it:
Found this helpful? Share it:
Set up OpenRouter client against idapt's compatible APIs with the steps below. This article and the AI Gateway quickstarts lander render the same shared steps, so they never drift.
OpenRouter client with idapt
Change one URL: OpenRouter request shapes, provider routing, and model fallbacks keep working.
const 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.
body: 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.
body: 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.
Related articles
API keys and scopes
Create a key, choose its scopes, pin it to an API version, rotate it, and cap what it can spend.
Rate limits and errors
Every error shape the API returns, what each rate limit is, and how to handle a wall in code.
Cap what an API key spends
Give every Gateway API key a lifetime, monthly, or daily USD cap, and what a capped-out key returns.
OpenRouter-compatible API
Point OpenRouter client code at idapt: same wire shape, provider routing, model fallbacks, and key management included.
Switch from OpenRouter
Swap the OpenRouter base URL for idapt's. Provider routing, model fallbacks, and key management work the same way.
curl with idapt
curl examples for idapt's three compatible APIs: OpenAI chat completions, Anthropic messages, and OpenRouter completions with one key.
OpenAI SDK (JS) with idapt
Point the official OpenAI Node SDK at idapt's compatible API: a three-line change routes 200+ models through your existing code.
Anthropic SDK with idapt
Point the Anthropic SDK (JS or Python) at idapt's Anthropic-compatible API and keep your Messages API code unchanged.
Was this helpful?