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§
- Assistant
Message - Assistant response message.
- System
Message - System notification (informational, error, etc.).
- Usage
- Token usage information.
- User
Message - User-originated message.
Enums§
- Content
Block - A block of content within a message.
- Message
- A message in the conversation.
- Message
Level - Message severity level.
- Stop
Reason - Why the model stopped generating.
- System
Message Type - System message subtypes.
- Tool
Result Block - 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.