import OpenAI from 'openai'; const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY }); const stream = await client.chat.completions.create({ model: 'gpt-4o', messages: [ { role: 'system', content: 'You are concise.' }, { role: 'user', content: 'Explain vector embeddings in two sentences.' }, ], temperature: 0.3, max_tokens: 300, stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ''); }