Skip to main content
Messages represent individual turns in a conversation history. They support both simple text content and multimodal content (text, images, files).

Structure

Fields

string
required
The role of the message sender. One of:
  • "user" - Message from the user
  • "assistant" - Message from the AI
  • "tool" - Tool execution results
string | list
required
The message content. Can be:
  • A simple string for text-only messages
  • A list of content parts for multimodal messages
System instructions should use the system parameter in generate_text(), not a message with role: "system".

Content Part Types

Text Part

Image Part

Images can be base64-encoded data, raw bytes, or a URL:

File Part

Using the Message Class

While the dict interface is recommended, you can also use the Message class:

Provider Support

See Also