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 the OpenAI package from npm.
npm install openaiOr with your preferred package manager:
pnpm add openai
yarn add openai
bun add openaiCreate a client with the Qubax baseURLand your apiKey. Your key starts with qbx_live_.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.qubax.ai/v1",
apiKey: process.env.QUBAX_API_KEY, // qbx_live_...
});QUBAX_API_KEY or OPENAI_API_KEY.A standard non-streaming chat completion request.
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);Stream tokens as they are generated by setting stream: true.
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();