Interface StreamObjectResult<T>

The result object returned immediately by streamObject.

Consumers iterate partialObjectStream for incremental partial objects, or await the promise properties for the final validated result.

interface StreamObjectResult<T> {
    partialObjectStream: AsyncIterable<DeepPartial<T>, any, any>;
    object: Promise<T>;
    text: Promise<string>;
    usage: Promise<TokenUsage>;
}

Type Parameters

  • T

    The inferred type from the Zod schema.

Properties

partialObjectStream: AsyncIterable<DeepPartial<T>, any, any>

Async iterable yielding partial objects as the LLM builds the JSON response token by token. Each yielded value has the same shape as T but with all fields optional (DeepPartial).

Example

for await (const partial of result.partialObjectStream) {
console.log('partial:', partial);
}
object: Promise<T>

Resolves to the final Zod-validated object when the stream completes.

Throws

When the final JSON fails validation.

text: Promise<string>

Resolves to the raw text when the stream completes.

usage: Promise<TokenUsage>

Resolves to aggregated token usage when the stream completes.