Model input
Provide conversation history to generateText or streamText.
AI Tools · Type Alias
ModelMessage is the AI SDK Core type for conversation messages sent to models. It unifies system, user, assistant, and tool messages, including multimodal content and tool interactions.
ModelMessage is the common message type accepted by AI SDK Core operations. It is a union of system, user, assistant, and tool messages, with content shapes appropriate to each role; the SDK also exposes a Zod schema for validating the type.
type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;import { ModelMessage } from 'ai';
const messages: ModelMessage[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain TypeScript generics.' },
{ role: 'assistant', content: 'Generics let types work with a variety of values.' },
];This creates a typed conversation containing system, user, and assistant messages.
Provide conversation history to generateText or streamText.
Represent multimodal user prompts containing images or files.
Describe assistant tool calls and subsequent tool results.
SystemModelMessageUserModelMessageAssistantModelMessageToolModelMessageTextPartImagePartFilePartToolCallPart