Skip to main content

Module message

Module message 

Source
Expand description

Message types for the conversation protocol.

These types mirror the wire format used by LLM APIs. The conversation is a sequence of messages with roles (system, user, assistant) and content blocks (text, tool_use, tool_result, thinking).

Structs§

AssistantMessage
Assistant response message.
SystemMessage
System notification (informational, error, etc.).
Usage
Token usage from an API response.
UserMessage
User-originated message.

Enums§

ContentBlock
A block of content within a message.
Message
A message in the conversation.
MessageLevel
Message severity level.
StopReason
Why the model stopped generating.
SystemMessageType
System message subtypes.
ToolResultBlock
A block within a rich tool result (for multi-modal tool output).

Functions§

image_block_from_file
Helper to create an image content block from a file path.
image_message
Helper to create a user message with an image.
messages_to_api_params
Convert messages to the API wire format (for sending to the LLM).
messages_to_api_params_cached
Convert messages to API params with cache_control breakpoints.
tool_result_message
Helper to create a tool result message.
user_message
Helper to create a user message with text content.