baseURL to the SnapGen OpenAI-compatible endpoint.
stream: true and use for await to read each chunk.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use SnapGen with the official OpenAI JavaScript SDK.
npm install openai
baseURL to the SnapGen OpenAI-compatible endpoint.
const OpenAI = require("openai");
async function main() {
const client = new OpenAI({
apiKey: "sk-xxxx",
baseURL: "https://api.snapgen.org/v1",
});
const response = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [
{ role: "user", content: "Give me one API reliability tip." },
],
});
console.log(response.choices[0].message.content);
}
main();
stream: true and use for await to read each chunk.
const OpenAI = require("openai");
async function main() {
const client = new OpenAI({
apiKey: "sk-xxxx",
baseURL: "https://api.snapgen.org/v1",
});
const stream = await client.chat.completions.create({
model: "gpt-5.4-mini",
messages: [{ role: "user", content: "Say hello in three words." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
}
main();