03 — Documentation
JavaScript
Use Fuzzy AI from Node.js or the browser with the official OpenAI SDK.
Install
npm install openai
Chat completion
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "{API}/v1",
apiKey: "nxr_live_YOUR_API_KEY",
});
const response = await client.chat.completions.create({
model: "provider/model-id",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
Streaming
const stream = await client.chat.completions.create({
model: "provider/model-id",
messages: [{ role: "user", content: "Tell me a story." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}