Stream a model response
Consume OpenAI-compatible streaming output from a hosted OpenPond model.
Stream a model response
Set stream: true on a chat-completions request and consume incremental
choices. Keep cancellation under your application's request lifecycle and
handle a partial response as a partial response.
ts
const stream = await openai.chat.completions.create({
model: "openpond-chat",
stream: true,
messages: [{ role: "user", content: "Explain streaming in one paragraph." }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}The selected model and endpoint determine supported request options. Verify the current model response rather than assuming all OpenAI features are available.
Next: Tool calling.