Defined in: packages/ai/src/types.ts:792
Options passed into the SDK and further piped to the AI provider.
TProviderOptionsSuperset extends Record<string, any> = Record<string, any>
TProviderOptionsForModel = TProviderOptionsSuperset
TContext = unknown
optional abortController: AbortController;optional abortController: AbortController;Defined in: packages/ai/src/types.ts:883
AbortController for request cancellation.
Allows you to cancel an in-progress request using an AbortController. Useful for implementing timeouts or user-initiated cancellations.
const abortController = new AbortController();
setTimeout(() => abortController.abort(), 5000); // Cancel after 5 seconds
await chat({ ..., abortController });const abortController = new AbortController();
setTimeout(() => abortController.abort(), 5000); // Cancel after 5 seconds
await chat({ ..., abortController });https://developer.mozilla.org/en-US/docs/Web/API/AbortController
optional agentLoopStrategy: AgentLoopStrategy;optional agentLoopStrategy: AgentLoopStrategy;Defined in: packages/ai/src/types.ts:820
optional context: TContext;optional context: TContext;Defined in: packages/ai/src/types.ts:804
Runtime context provided by the caller and passed to middleware and server-side tool implementations.
optional conversationId: string;optional conversationId: string;Defined in: packages/ai/src/types.ts:869
Use threadId instead. conversationId is the legacy pre-AG-UI name for the same concept (a stable per-conversation identifier used to correlate client/server devtools events). When conversationId is omitted, the runtime falls back to threadId automatically, so most callers can simply pass threadId (or rely on chatParamsFromRequest, which surfaces it on params).
Will be removed in a future major release.
logger: InternalLogger;logger: InternalLogger;Defined in: packages/ai/src/types.ts:890
Internal logger threaded from the chat entry point. Adapter implementations must call logger.request() before SDK calls, logger.provider() for each chunk received, and logger.errors() in catch blocks.
messages: ModelMessage<
| string
| ContentPart<unknown, unknown, unknown, unknown, unknown>[]
| null>[];messages: ModelMessage<
| string
| ContentPart<unknown, unknown, unknown, unknown, unknown>[]
| null>[];Defined in: packages/ai/src/types.ts:798
optional metadata: Record<string, any>;optional metadata: Record<string, any>;Defined in: packages/ai/src/types.ts:831
Additional metadata to attach to the request. Can be used for tracking, debugging, or passing custom information. Structure and constraints vary by provider.
Provider usage:
model: string;model: string;Defined in: packages/ai/src/types.ts:797
optional modelOptions: TProviderOptionsForModel;optional modelOptions: TProviderOptionsForModel;Defined in: packages/ai/src/types.ts:832
optional outputSchema: SchemaInput;optional outputSchema: SchemaInput;Defined in: packages/ai/src/types.ts:858
Schema for structured output.
Two distinct use sites:
User-facing (activity layer): accepts any SchemaInput ā Zod, ArkType, Valibot, or a raw JSON Schema. The activity layer converts to JSON Schema before handing off.
Adapter-facing (chatStream call): the engine populates this with a pre-converted JSON Schema only when the adapter declared supportsCombinedToolsAndSchema(modelOptions) === true. The adapter should then wire the schema into the upstream request (e.g. response_format: { type: 'json_schema', ... }, text.format, output_format) alongside any tools. The model's natural final turn carries the schema-constrained JSON text and the engine harvests it from the agent loop without a separate finalization round-trip.
Adapters that did NOT declare the capability never see this field populated ā the engine instead invokes structuredOutput / structuredOutputStream after the agent loop.
optional parentRunId: string;optional parentRunId: string;Defined in: packages/ai/src/types.ts:907
Parent run ID for AG-UI protocol nested run correlation. Surfaced for observability/middleware; not consumed by the LLM call.
optional request: Request | RequestInit;optional request: Request | RequestInit;Defined in: packages/ai/src/types.ts:833
optional runId: string;optional runId: string;Defined in: packages/ai/src/types.ts:902
Run ID for AG-UI protocol run correlation. When provided, this will be used in RunStartedEvent and RunFinishedEvent. If not provided, a unique ID will be generated.
optional systemPrompts: SystemPrompt[];optional systemPrompts: SystemPrompt[];Defined in: packages/ai/src/types.ts:819
System prompts to include with the request.
Accepts plain strings (the common case) or { content, metadata } objects that let providers attach typed metadata (e.g. Anthropic cache_control for prompt caching) per prompt. At the chat call site the adapter narrows metadata's type via ~types['systemPromptMetadata'] ā providers that don't declare one default to never, which makes the field carry no meaningful value (TypeScript will only accept undefined there). Provider-foreign metadata that reaches an adapter via JS / as any is silently dropped, never written to the wire.
SystemPrompt
optional threadId: string;optional threadId: string;Defined in: packages/ai/src/types.ts:896
Thread ID for AG-UI protocol run correlation. When provided, this will be used in RunStartedEvent and RunFinishedEvent.
optional tools: AnyTool[];optional tools: AnyTool[];Defined in: packages/ai/src/types.ts:799