JavaScript SDK
Use the official OpenAI Node SDK and point it at ScaleMax. Model IDs come from the models and pricing page, and every request field is listed in Chat Completions.
Set SCALEMAX_BASE_URL to https://api.scalemax.pro/v1 for API credit or https://api.scalemax.pro/token/v1 for an API-token key. This is the OpenAI-compatible route; native Claude apps use their origin-only setup instead.
bash
# API-credit key:
export SCALEMAX_BASE_URL="https://api.scalemax.pro/v1"
# API-token key:
# export SCALEMAX_BASE_URL="https://api.scalemax.pro/token/v1"powershell
# API-credit key:
$env:SCALEMAX_BASE_URL = "https://api.scalemax.pro/v1"
# API-token key:
# $env:SCALEMAX_BASE_URL = "https://api.scalemax.pro/token/v1"Install
bash
npm install openaipowershell
npm.cmd install openaiWindows PowerShell blocks npm’s .ps1 launchers by default (“running scripts is disabled on this system”), so these commands use the .cmd launcher: npx.cmd, npm.cmd, scalemax.cmd. In Command Prompt you can leave out .cmd.
Basic chat
client.ts
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.SCALEMAX_API_KEY,
baseURL: process.env.SCALEMAX_BASE_URL,
});
const response = await client.chat.completions.create({
model: "YOUR_AUTHENTICATED_MODEL_ID",
messages: [{ role: "user", content: "Write a haiku about fast inference." }],
});
console.log(response.choices[0]?.message?.content);Streaming
stream.ts
const stream = await client.chat.completions.create({
model: "YOUR_AUTHENTICATED_MODEL_ID",
messages: [{ role: "user", content: "Stream a short greeting." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Server-sent-event framing and safe disconnect handling are covered in Streaming. The same flow in other languages: Python, cURL.