The Zod schema type defining the expected output shape.
The array field named by StreamObjectOptions.elements; a call infers it from the name it passes.
Optional providerProvider name. When supplied without model, the default text model for
the provider is resolved automatically.
`"openai"`, `"anthropic"`, `"ollama"`
Optional modelModel identifier. Prefer the plain model name with provider set;
the combined "provider:model" string is also accepted.
`"gpt-4o"` (with `provider: 'openai'`), `"gpt-4o-mini"`
Zod schema defining the expected output shape.
Optional schemaHuman-readable name for the schema, injected into the system prompt.
`"ShoppingList"`
Optional schemaDescription of the schema, injected into the system prompt.
`"A shopping list with a person's name and items."`
Optional elementsThe name of one top-level array field of schema, whose elements
StreamObjectResult.elementStream yields one at a time as each is
completed: an element once the next one begins, and the last one once the
array's closing bracket arrives, while any field the schema puts after the
array is still streaming, or at the latest when the stream ends with text
that parses. Each is parsed by the array's element schema; an element
that fails it is skipped and counted in StreamObjectResult.skipped.
A name that is not a field of the schema holding an array (optional,
nullable or with a default included; one behind a transform, a pipe or
z.lazy() is not) throws a TypeError at the call, before any request
is sent.
`"sentences"` for `z.object({ sentences: z.array(Sentence) })`
Optional promptUser prompt.
Optional systemSystem prompt. Schema instructions are appended automatically.
Optional messagesFull conversation history.
Optional temperatureSampling temperature forwarded to the provider.
Optional maxHard cap on output tokens.
Optional effortReasoning depth forwarded to GenerateTextOptions.effort.
Optional thinkingExtended-thinking switch forwarded to GenerateTextOptions.thinking; see GenerateObjectOptions.thinking.
Optional maxNumber of retries on validation failure. Unlike generateObject, streaming retries are not currently supported (the stream is consumed once). This field is accepted for API symmetry but is unused; validation errors on the final object throw immediately.
0
Optional apiOverride the API key.
Optional baseOverride the provider base URL.
Optional abortEnds the stream when it aborts, forwarded to
GenerateTextOptions.abortSignal: the provider's stream stops, the
partial-object and element iterations end, and object rejects with the
signal's reason.
Optional requestPer-call request timeout in milliseconds, forwarded to GenerateTextOptions.requestTimeout.
Optional maxThe most requests the stream's call sends, a first and its retries together; the provider's configured count when left out. Forwarded to GenerateTextOptions.maxAttempts.
Optional onCalled after each request the stream's call sent, so a caller can settle the attempts it paid for.
Optional serviceOpenAI service tier, forwarded to GenerateTextOptions.serviceTier and sent as service_tier verbatim on
the streamed request. No default: OpenAI then serves the request at the project's configured tier. Other
providers ignore it.
Optional customProvider-specific top-level request fields, forwarded to GenerateTextOptions.customModelParams and spread onto the streamed request body with the same rules as there: a fallback leg gets them minus the fields only another vendor accepts.
Options for a streamObject call.
Shares the same shape as GenerateObjectOptions from generateObject. At minimum,
schemaand eitherpromptormessagesmust be supplied.Example