The script
Save as luv13-example.mjs:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.luv13.ai/v1",
apiKey: process.env.LUV13_API_KEY,
});
for await (const model of client.models.list()) console.log(model.id);
try {
const reply = await client.chat.completions.create({
model: "luv13/glm-5.3-flash",
messages: [{ role: "user", content: "ping" }],
});
console.log(reply.choices[0].message.content);
} catch (err) {
if (err instanceof OpenAI.APIError) console.error(`HTTP ${err.status}:`, err.error);
else throw err;
}npm install openai
export LUV13_API_KEY=sk-luv13-...
node luv13-example.mjsWithout a valid key, err.error is {"code":401,"message":"unauthorized","type":"invalid_auth"}. For the SDKs in general, see Using the OpenAI SDKs.
