Node.js
Norlen is OpenAI-compatible, so the official openai SDK in Node.js works by pointing baseURL at Norlen.
npm install openaiConfiguration
Section titled “Configuration”import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.norlen.io/v1", apiKey: process.env.NORLEN_API_KEY,});const resp = await client.chat.completions.create({ model: "qwen3.6-35b", messages: [{ role: "user", content: "Hello, Norlen!" }],});console.log(resp.choices[0].message.content);Streaming
Section titled “Streaming”const stream = await client.chat.completions.create({ model: "qwen3.6-35b", messages: [{ role: "user", content: "Count to five." }], stream: true,});for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? "");}Embeddings
Section titled “Embeddings”const resp = await client.embeddings.create({ model: "qwen3-embedding", input: ["first text", "second text"],});console.log(resp.data[0].embedding.slice(0, 5));Images
Section titled “Images”Image generation uses a different base URL (app.norlen.io/api/v1) and does not go through the SDK — use fetch:
const r = await fetch("https://app.norlen.io/api/v1/images/generations", { method: "POST", headers: { Authorization: `Bearer ${process.env.NORLEN_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "qwen-image", prompt: "A lighthouse at dawn", size: "1024x1024" }),});const { data } = await r.json();const buffer = Buffer.from(data[0].b64_json, "base64");await import("node:fs/promises").then((fs) => fs.writeFile("imagem.png", buffer));