Get Started
Examples
Concepts
Resources
Projects
Integrations
API Reference
Streaming
copy markdown
Streaming enables Interfaze to deliver responses in real time, creating a faster, more interactive experience.
Text streaming
Interfaze SDK
Vercel AI SDK
LangChain SDK
typescript
python
const stream = interfaze.chat.completions.stream({
messages: [
{ role: "user", content: "Write a short story about a robot learning to paint" }
],
});
for await (const text of stream.textDeltas()) {
process.stdout.write(text);
}
// the final completion still carries precontext and reasoning
const final = await stream.finalChatCompletion();textDeltas()yields display-ready text — the inline<precontext>and<think>side-channels are stripped out and returned structured on the final completion instead.- For the raw chunk iterator, use
create({ stream: true }). - The native LangChain integration strips the same side-channels out of streamed content. Set
showAdditionalInfo(show_additional_infoin Python) on the model to receiveprecontextwhile streaming.
Object streaming
Stream structured JSON objects as they are generated, receiving partial data incrementally rather than waiting for the full response.
Interfaze SDK
Vercel AI SDK
LangChain SDK
typescript
python
import { responseFormat } from "interfaze";
import { z } from "zod";
const storySchema = z.object({
title: z.string().describe("The title of the story"),
genre: z.string().describe("The genre of the story"),
summary: z.string().describe("A brief summary of the story"),
});
const stream = interfaze.chat.completions.stream({
messages: [
{ role: "user", content: "Write a short story about a robot learning to paint" }
],
response_format: responseFormat(z.toJSONSchema(storySchema), "story_schema"),
});
for await (const partial of stream.textDeltas()) {
process.stdout.write(partial);
}
const final = await stream.finalChatCompletion();
console.log(JSON.parse(final.choices[0]?.message.content ?? "{}"));