ai_sdk.types
.
Messages
CoreMessage subclasses
Class | Role | Typical usage |
---|---|---|
CoreSystemMessage | system | Set behaviour & identity of the assistant. |
CoreUserMessage | user | Explicit user instructions (text / images / files). |
CoreAssistantMessage | assistant | Model responses (text, reasoning, tool calls). |
CoreToolMessage | tool | Container for tool results fed back to the model. |
.to_dict()
helper that returns the OpenAI-compatible representation, so you can seamlessly drop them into the low-level LanguageModel
interface if needed.
Content parts
parts_breakdown.py
TokenUsage
Simple container holdingprompt_tokens
, completion_tokens
, total_tokens
– populated on all helpers when the provider returns usage data.
ToolCall / ToolResult
Used internally for the tool-calling loop but exposed onGenerateTextResult
so you can inspect or persist the chain-of-thought.
OnStepFinishResult
Object passed to the optionalon_step
callback after every model ↔ tool interaction. Fields include:
step_type
– one ofinitial
,continue
,tool-result
.finish_reason
,usage
,text
,tool_calls
,tool_results
, …
All types are frozen (
pydantic.ConfigDict(frozen=True)
) meaning you can safely log & share
them without accidental mutation.