Stream chat responses
Show a chat reply as it is generated.
Set stream: true for incremental text. Use the SDK file helpers for images, documents, and audio; see Multimodal for the original upload, OCR, history, and schema guidance. Streaming cannot be combined with tools, attachments, or audio input.
import AddisAI from "addisai";
const addis = new AddisAI();
const stream = await addis.chat.completions.create({
messages: [{ role: "user", content: "Tell me a short story." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0].delta.content ?? "");
}from addisai import AddisAI
addis = AddisAI()
stream = addis.chat.completions.create(
messages=[{"role": "user", "content": "Tell me a short story."}],
stream=True,
)
for chunk in stream:
print(chunk["choices"][0]["delta"].get("content", ""), end="")Edit on GitHub
Last updated on