Defined in: packages/ai/src/types.ts:1114
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;Defined in: packages/ai/src/types.ts:1219
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 });https://developer.mozilla.org/en-US/docs/Web/API/AbortController
optional agentLoopStrategy?: AgentLoopStrategy;Defined in: packages/ai/src/types.ts:1142
optional approvals?: ReadonlyMap<string, boolean>;Defined in: packages/ai/src/types.ts:1277
Client approval decisions for this run, keyed by approval id. The engine populates this from approvals carried on the incoming messages. Harness adapters consult it to resolve ask-policy permission requests (the agent pauses on a risky action; the client re-runs with a decision recorded here). Undefined for direct adapter usage outside the chat engine.
optional capabilities?: CapabilityContext;Defined in: packages/ai/src/types.ts:1268
Middleware capability context for this run. The engine populates it with the live middleware context so harness adapters that declare requires: [SomeCapability] can read provided capabilities from inside chatStream — e.g. getSandbox(options.capabilities). Capabilities are provisioned by middleware setup before the adapter runs. Undefined for direct adapter usage outside the chat engine.
optional context?: TContext;Defined in: packages/ai/src/types.ts:1126
Runtime context provided by the caller and passed to middleware and server-side tool implementations.
optional conversationId?: string;Defined in: packages/ai/src/types.ts:1205
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.
optional lazyToolsConfig?: LazyToolsConfig;Defined in: packages/ai/src/types.ts:1153
Optional configuration for lazy-tool discovery (tools marked lazy: true). Tunes how much of each lazy tool's description appears in the discovery catalog. Optional — defaults to { includeDescription: 'none' }.
logger: InternalLogger;Defined in: packages/ai/src/types.ts:1226
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>[];Defined in: packages/ai/src/types.ts:1120
optional metadata?: Record<string, any>;Defined in: packages/ai/src/types.ts:1164
Observability metadata attached to this call. Surfaced to middleware, devtools, and the event client; values may be arbitrarily structured (objects, arrays). Adapters never forward this field onto the provider wire request.
To send provider-side request metadata, use the provider's modelOptions field instead, where the provider supports one (e.g. OpenAI's and OpenRouter's metadata are both Record<string, string>).
model: string;Defined in: packages/ai/src/types.ts:1119
optional modelOptions?: TProviderOptionsForModel;Defined in: packages/ai/src/types.ts:1165
optional outputSchema?: SchemaInput;Defined in: packages/ai/src/types.ts:1194
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, --json-schema) alongside any tools.
How the engine then takes the object depends on combinedStructuredOutputSource():
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;Defined in: packages/ai/src/types.ts:1243
Parent run ID for AG-UI protocol nested run correlation. Surfaced for observability/middleware; not consumed by the LLM call.
optional request?: Request | RequestInit;Defined in: packages/ai/src/types.ts:1166
optional resume?: RunAgentResumeItem[];Defined in: packages/ai/src/types.ts:1258
AG-UI interrupt resume responses supplied by the client on a follow-up run. A first-party generic item carries the original request in metadata.
optional runId?: string;Defined in: packages/ai/src/types.ts:1238
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 state?: unknown;Defined in: packages/ai/src/types.ts:1252
Application state mirrored in a STATE_SNAPSHOT before an interrupt terminal.
optional subagentRunId?: string;Defined in: packages/ai/src/types.ts:1249
AG-UI subagent run id when this chat runs as a child of another run. A child chat() passes ctx.subagentRunId. Middleware reads it as ctx.subagentRunId. Absent on a top-level run.
optional systemPrompts?: SystemPrompt[];Defined in: packages/ai/src/types.ts:1141
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;Defined in: packages/ai/src/types.ts:1232
Thread ID for AG-UI protocol run correlation. When provided, this will be used in RunStartedEvent and RunFinishedEvent.
optional toolExecution?: "parallel" | "sequential";Defined in: packages/ai/src/types.ts:1147
How the server tools of one model turn run. 'parallel' (the default) starts them together, and 'sequential' runs them one at a time.
optional tools?: AnyTool[];Defined in: packages/ai/src/types.ts:1121