Skip to main content

Interface: StreamObjectOptions<T>

Defined in: packages/agentos/src/api/streamObject.ts:49

Options for a streamObject call.

Shares the same shape as GenerateObjectOptions from generateObject. At minimum, schema and either prompt or messages must be supplied.

Example

const opts: StreamObjectOptions<typeof mySchema> = {
schema: z.object({ name: z.string(), items: z.array(z.string()) }),
prompt: 'List 3 fruits with a person name',
};

Type Parameters

T

T extends ZodType

The Zod schema type defining the expected output shape.

Properties

apiKey?

optional apiKey: string

Defined in: packages/agentos/src/api/streamObject.ts:109

Override the API key.


baseUrl?

optional baseUrl: string

Defined in: packages/agentos/src/api/streamObject.ts:112

Override the provider base URL.


maxRetries?

optional maxRetries: number

Defined in: packages/agentos/src/api/streamObject.ts:106

Number 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.

Default

0

maxTokens?

optional maxTokens: number

Defined in: packages/agentos/src/api/streamObject.ts:96

Hard cap on output tokens.


messages?

optional messages: Message[]

Defined in: packages/agentos/src/api/streamObject.ts:90

Full conversation history.


model?

optional model: string

Defined in: packages/agentos/src/api/streamObject.ts:64

Model identifier. Prefer the plain model name with provider set; the combined "provider:model" string is also accepted.

Example

`"gpt-4o"` (with `provider: 'openai'`), `"gpt-4o-mini"`

prompt?

optional prompt: string

Defined in: packages/agentos/src/api/streamObject.ts:84

User prompt.


provider?

optional provider: string

Defined in: packages/agentos/src/api/streamObject.ts:56

Provider name. When supplied without model, the default text model for the provider is resolved automatically.

Example

`"openai"`, `"anthropic"`, `"ollama"`

schema

schema: T

Defined in: packages/agentos/src/api/streamObject.ts:67

Zod schema defining the expected output shape.


schemaDescription?

optional schemaDescription: string

Defined in: packages/agentos/src/api/streamObject.ts:81

Description of the schema, injected into the system prompt.

Example

`"A shopping list with a person's name and items."`

schemaName?

optional schemaName: string

Defined in: packages/agentos/src/api/streamObject.ts:74

Human-readable name for the schema, injected into the system prompt.

Example

`"ShoppingList"`

system?

optional system: string

Defined in: packages/agentos/src/api/streamObject.ts:87

System prompt. Schema instructions are appended automatically.


temperature?

optional temperature: number

Defined in: packages/agentos/src/api/streamObject.ts:93

Sampling temperature forwarded to the provider.