Skip to main content
idapt
HomeAI ModelsExploreResourcesPricing
Sign inUse for Free
HomeDevelopersAI Gateway quickstartsOpenRouter client
OpenRouter SDK

OpenRouter client with idapt

Change one URL: OpenRouter request shapes, provider routing, and model fallbacks keep working.

  1. 1

    Point it at idapt

    ts
    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.

  2. 2

    Streaming

    ts
    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.

  3. 3

    Going further

    ts
    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.

GOOD TO KNOW

API keys and scopesOpenAI-compatible API referenceOpenRouter-compatible API referenceRate limits and errorsSwitch from OpenRouter

MORE QUICKSTARTS

curl

curl

OpenAI SDK (JS)

Anthropic SDK

  • Home
  • Pricing
  • AI Models
  • Skills
  • Image models
  • Voice models
  • Video models
  • Rankings
  • Multi-Model Chat
  • Agents
  • Computers
  • Drive
  • Automations
  • AI Gateway
  • All features →
  • Blog
  • About
  • Comparisons
  • Benchmarks
  • Model Match
  • Demos
  • Help center
  • FAQ
  • Privacy
  • Support
  • Developers
  • Quickstarts
  • API reference
  • API pricing
  • CLI
  • MCP
  • Migrate
  • Downloads
  • Desktop
© idapt[email protected]TermsPrivacy PolicyLegal noticeReport content
X (Twitter)Discord