Node.js SDK

Qubax is fully OpenAI-compatible, so you can use the official openainpm package for Node.js, Bun, Deno, and the browser. Set the base URL and API key, then call the SDK exactly as you would against OpenAI.

Install

Install the OpenAI package from npm.

Shell
npm install openai

Or with your preferred package manager:

Shell
pnpm add openai
yarn add openai
bun add openai

Configure

Create a client with the Qubax baseURLand your apiKey. Your key starts with qbx_live_.

JavaScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.qubax.ai/v1",
  apiKey: process.env.QUBAX_API_KEY, // qbx_live_...
});
ℹ️
Never hardcode your API key. Load it from an environment variable such as QUBAX_API_KEY or OPENAI_API_KEY.

Chat completion

A standard non-streaming chat completion request.

JavaScript
import OpenAI from "openai";

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

const response = await client.chat.completions.create({
  model: "gpt-5",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Explain quantum entanglement in one sentence." },
  ],
});

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

Streaming

Stream tokens as they are generated by setting stream: true.

JavaScript
import OpenAI from "openai";

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

const stream = await client.chat.completions.create({
  model: "gpt-5",
  messages: [{ role: "user", content: "Write a haiku about the ocean." }],
  stream: true,
});

for await (const chunk of stream) {
  const delta = chunk.choices[0]?.delta?.content;
  if (delta) process.stdout.write(delta);
}
console.log();
💡
The same SDK works in edge runtimes, Cloudflare Workers, and the browser. Qubax accepts CORS requests, so serverless and client-side apps both connect cleanly.