ApiLux

OpenAI SDK

Use the official OpenAI SDK (Node.js or Python) with ApiLux. Two lines of configuration.

Step 1 — Install the SDK and set your key

Node.js
npm install openai
Python
pip install openai
Windows PowerShell
$env:APILUX_API_KEY = "apl_YOUR_API_KEY"

Step 2 — Point the SDK at ApiLux

Only two things change versus a normal OpenAI setup: baseURL and apiKey. The rest of the SDK stays the same.

Node.js
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.APILUX_API_KEY,
  baseURL: "https://apilux.net/api/v1",
});

const r = await client.chat.completions.create({
  model: "MODEL_ID",
  messages: [{ role: "user", content: "Xin chao" }],
});
console.log(r.choices[0]?.message?.content);
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["APILUX_API_KEY"],
    base_url="https://apilux.net/api/v1",
)

r = client.chat.completions.create(
    model="MODEL_ID",
    messages=[{"role": "user", "content": "Xin chao"}],
)
print(r.choices[0].message.content)

Step 3 — Streaming

stream=True returns an OpenAI-compatible SSE stream whose final chunk carries usage. That is what makes Cursor, OpenCode and VS Code extensions work: they stream by default and mostly cannot turn it off.

Node.js
const stream = await client.chat.completions.create({
  model: "MODEL_ID",
  messages: [{ role: "user", content: "Xin chao" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Disconnecting mid-stream is still billed for what was already generated — the provider already did that work.

Configuration summary

ItemValue
Base URLhttps://apilux.net/api/v1
Key variableAPILUX_API_KEY
Modelfrom GET /models
Wire protocolchat.completions (no streaming)

The full error table lives in the connection test guide.