import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.LLMGRID_API_KEY!,
baseURL: "https://api.llmgrid.ai/v1",
});
const stream = await client.chat.completions.create({
model: "gpt-4.1",
messages: [{ role: "user", content: "Stream a short explanation of RAG." }],
stream: true,
});
for await (const chunk of stream) {
const delta = chunk.choices?.[0]?.delta?.content;
if (delta) process.stdout.write(delta);
}
``