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
System instructions that guide the model’s behavior.UserMessage
Messages from the user, supporting text and multimodal content.TextPart
ImagePart
FilePart
AssistantMessage
Messages from the assistant, containing text, reasoning, or tool calls.AssistantTextPart
ReasoningPart
Internal reasoning/thinking from models that support extended reasoning.ToolCallPart
ToolCall
ToolResultMessage
Results from executing a tool call.Tool Types
ToolDefinition
ToolSet
ToolChoice
Model Types
ChatModel
Interface for chat/completion models.EmbeddingModel
Interface for embedding models.ImageModel
Interface for image generation models.Configuration Types
ModelConfig
Model configuration parameters.ReasoningConfig
Configuration for extended thinking/reasoning.Generation Options
GenerateOptions
GenerateObjectOptions
StreamObjectOptions
Result Types
GenerateResult
GenerateObjectResult
FinishReason
Streaming Types
StreamResult
StreamEvent
StreamObjectResult
ObjectStreamEvent
Usage Types
ChatUsage
Token usage reported after chat completion.inputTokensis the total including cached reads and cache writesoutputTokensis the total including visible text and reasoning- For providers like Anthropic, cache tokens are normalized and included in the total
ChatInputTokenDetails
ChatOutputTokenDetails
EmbeddingUsage
Embedding Types
EmbedOptions
EmbedResult
Image Generation Types
ImageGenerateOptions
ImageGenerateResult
GeneratedImage
Type Usage Examples
Building Type-Safe Conversations
Type-Safe Tool Handling
Working with Usage Data
Source Location
~/workspace/source/packages/core-ai/src/types.ts