Overview
core-ai uses a comprehensive type system to ensure type safety across all operations. This page documents the essential types for working with messages, models, configurations, and results.Message types
Message
Union type representing all message types in a conversation.SystemMessage
UserMessage
TextPart
ImagePart
FilePart
AssistantMessage
AssistantTextPart
ReasoningPart
providerMetadata is provider-namespaced. The top-level key is the provider identifier (for example 'anthropic', 'google', or 'openai'). Use getProviderMetadata() for typed access.
ToolCallPart
ToolCall
ToolResultMessage
Tool types
ToolDefinition
ToolSet
ToolChoice
Model types
ChatModel
EmbeddingModel
ImageModel
Configuration types
ReasoningConfig
Provider options types
Provider-specific options are namespaced by provider name and validated with Zod schemas by each provider adapter.Generation options
BaseGenerateOptions
Shared options for all generation functions.GenerateOptions
ExtendsBaseGenerateOptions with tool support.
GenerateObjectOptions
StreamObjectOptions
Result types
GenerateResult
GenerateObjectResult
FinishReason
Streaming types
ChatStream
Replayable handle for a chat streaming operation. Iterating after events have arrived replays the buffered history.StreamEvent
ObjectStream
Replayable handle for a structured object streaming operation.ObjectStreamEvent
Usage types
ChatUsage
inputTokens is the total including cached reads and cache writes. outputTokens is the total including visible text and reasoning.