Back to blog

Fusion API Node.js example (OpenRouter)

Call the OpenRouter Fusion API from Node.js / TypeScript: the openai SDK, streaming, a custom panel, and a raw fetch example — copy-paste ready.

Jun 15, 2026FusionAPIFusionAPI
Fusion API Node.js example (OpenRouter)

The Fusion API is OpenAI-compatible, so in Node.js you can use the official openai package or a plain fetch. (See also how to call the Fusion API and the Python version.)

Install

npm install openai

Minimal example

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://openrouter.ai/api/v1",
  apiKey: process.env.OPENROUTER_API_KEY,
});

const res = await client.chat.completions.create({
  model: "openrouter/fusion",
  messages: [
    { role: "user", content: "Is creatine worth taking? What does the evidence say?" },
  ],
});

console.log(res.choices[0].message.content);

Streaming

const stream = await client.chat.completions.create({
  model: "openrouter/fusion",
  messages: [{ role: "user", content: "..." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Custom panel + judge

const res = await client.chat.completions.create({
  model: "openrouter/fusion",
  messages: [{ role: "user", content: "..." }],
  // @ts-expect-error — plugins is an OpenRouter extension
  plugins: [{
    id: "fusion",
    model: "google/gemini-3-flash-preview",       // judge
    analysis_models: [                              // panel
      "google/gemini-3-flash-preview",
      "moonshotai/kimi-k2.6",
      "deepseek/deepseek-v4-pro",
    ],
  }],
});

Raw fetch (no SDK)

const r = await fetch("https://openrouter.ai/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "openrouter/fusion",
    messages: [{ role: "user", content: "..." }],
  }),
});
const data = await r.json();
console.log(data.choices[0].message.content);

Estimate the cost of any panel before you ship with the Fusion cost calculator, or try a call live in the Playground. Using an AI IDE or framework? See Fusion in Cursor, Cline, LangChain & Vercel AI SDK.