BETA
Documentation
Node.js Streaming
Iterate the stream with a for-await loop; the SDK turns SSE chunks into plain objects for you.
index.js
const stream = await client.chat.completions.create({
model: "gpt-5.6-sol",
messages: [{ role: "user", content: "Say this is a test" }],
stream: true,
});
for await (const chunk of stream) {
const delta = chunk.choices[0]?.delta?.content;
if (delta) process.stdout.write(delta);
}As with Python, Apily injects stream_options.include_usage automatically, so the final chunk carries token usage without any extra client-side setup.