Streaming generation options including the Zod schema, prompt/messages, and optional provider/model overrides.
A StreamObjectResult with partialObjectStream, object,
text, and usage properties.
import { z } from 'zod';
import { streamObject } from '@framers/agentos';
const result = streamObject({
model: 'openai:gpt-4o',
schema: z.object({ name: z.string(), hobbies: z.array(z.string()) }),
prompt: 'Create a profile for a fictional character.',
});
for await (const partial of result.partialObjectStream) {
console.log('partial:', partial);
}
const final = await result.object;
console.log('final:', final);
Streams a structured object by incrementally parsing JSON as the LLM produces tokens, then validates the final result against a Zod schema.
Returns immediately with a StreamObjectResult containing async iterables and promises. The underlying LLM call begins lazily when a consumer starts iterating
partialObjectStreamor awaits a promise.