Class References
Function References
- text
- textOptions
- combineStrategies
- convertMessagesToModelMessages
- convertZodToJsonSchema
- createReplayStream
- embedding
- generateMessageId
- maxIterations
- messages
- modelMessageToUIMessage
- modelMessagesToUIMessages
- normalizeToUIMessage
- parsePartialJSON
- summarize
- toServerSentEventsStream
- toServerSentEventsResponse
- toolDefinition
- uiMessageToModelMessages
- realtimeToken
- untilFinishReason
Interface References
- AIAdapter
- AIAdapterConfig
- AgentLoopState
- AudioPart
- AudioVisualization
- BaseStreamChunk
- TextCompletionChunk
- TextOptions
- ChunkRecording
- ChunkStrategy
- ClientTool
- ContentPartSource
- ContentStreamChunk
- DefaultMessageMetadataByModality
- DocumentPart
- DoneStreamChunk
- EmbeddingOptions
- EmbeddingResult
- ErrorStreamChunk
- ImagePart
- InternalToolCallState
- JSONParser
- ModelMessage
- ProcessorResult
- ProcessorState
- RealtimeAdapter
- RealtimeClientOptions
- RealtimeConnection
- RealtimeMessage
- RealtimeSessionConfig
- RealtimeToken
- RealtimeTokenAdapter
- RealtimeTokenOptions
- ResponseFormat
- ServerTool
- StreamProcessorEvents
- StreamProcessorHandlers
- StreamProcessorOptions
- SummarizationOptions
- SummarizationResult
- TextPart
- ThinkingPart
- ThinkingStreamChunk
- Tool
- ToolCall
- ToolCallPart
- ToolCallStreamChunk
- ToolConfig
- ToolDefinition
- ToolDefinitionConfig
- ToolDefinitionInstance
- ToolInputAvailableStreamChunk
- ToolResultPart
- ToolResultStreamChunk
- UIMessage
- VideoPart
Type Alias References
- AgentLoopStrategy
- AnyClientTool
- TextStreamOptionsForModel
- TextStreamOptionsUnion
- ConstrainedContent
- ConstrainedModelMessage
- ContentPart
- ContentPartForModalities
- ExtractModalitiesForModel
- ExtractModelsFromAdapter
- InferToolInput
- InferToolName
- InferToolOutput
- MessagePart
- RealtimeEvent
- RealtimeMessagePart
- RealtimeMode
- RealtimeStatus
- ModalitiesArrayToUnion
- Modality
- StreamChunk
- ToolCallState
- ToolResultState
Variable References
ModelMessage
Defined in: packages/ai/src/types.ts:431
Type Parameters#
TContent#
TContent extends string | null | ContentPart[] = string | null | ContentPart[]
Properties#
blockOrder?#
optional blockOrder?: ModelMessageBlock[];Defined in: packages/ai/src/types.ts:455
The order of the blocks of an assistant message, when it is not the default order (all thinking, then the text, then the tool calls). Each entry points into thinking, into content (a string, by UTF-16 length), or into toolCalls. The library writes and reads this field. A reader that finds a map that does not match the message uses the default order.
content#
content: TContent;Defined in: packages/ai/src/types.ts:438
createdAt?#
optional createdAt?: Date;Defined in: packages/ai/src/types.ts:485
Optional message creation timestamp. When present, message converters preserve it across persist → hydrate round-trips.
error?#
optional error?: string;Defined in: packages/ai/src/types.ts:457
Error reported by an AG-UI tool message.
id?#
optional id?: string;Defined in: packages/ai/src/types.ts:480
Optional stable message id. Providers ignore it; it exists so a persisted transcript can retain the streaming messageId and survive the persist → hydrate round-trip. When present, modelMessagesToUIMessages reuses it instead of generating a fresh id, so a hydrated message keeps the same identity as its live stream — which is what lets a mid-stream reload resume the SAME message bubble in place (see @tanstack/ai-persistence).
metadata?#
optional metadata?: Record<string, any>;Defined in: packages/ai/src/types.ts:465
Optional AG-UI message metadata. TanStack-owned fields live under tanstack.
midConversationChange?#
optional midConversationChange?: MidConversationChange;Defined in: packages/ai/src/types.ts:463
The tools and system prompts that changed before this assistant message. chat() writes it when the adapter has a mid-conversation channel. Providers ignore it: adapters read TextOptions.midConversationChanges.
name?#
optional name?: string;Defined in: packages/ai/src/types.ts:439
role#
role: "assistant" | "user" | "tool";Defined in: packages/ai/src/types.ts:437
structuredOutput?#
optional structuredOutput?: StructuredOutputPart<unknown>;Defined in: packages/ai/src/types.ts:471
Completed structured output represented by this assistant message. content remains the provider-facing JSON text; this field preserves the typed UI part across persistence and message conversion.
thinking?#
optional thinking?: object[];Defined in: packages/ai/src/types.ts:447
Signed thinking to send back to the provider. redacted: true marks a block the provider encrypted: content is empty and signature holds its opaque data. See ThinkingPart.signature for the planned rename.
content#
content: string;redacted?#
optional redacted?: boolean;signature?#
optional signature?: string;toolCallId?#
optional toolCallId?: string;Defined in: packages/ai/src/types.ts:441
toolCalls?#
optional toolCalls?: ToolCall<unknown>[];Defined in: packages/ai/src/types.ts:440