Skip to main content

Overview

Content types represent messages exchanged with the model. Each message can contain multiple parts with different media types.

Content

Base class for multi-part message content.

Fields

list[Part]
List of parts that constitute a single message. Each part may have a different IANA MIME type.
str
The producer of the content. Must be either ‘user’ or ‘model’. Defaults to ‘user’ if not set.

Example

UserContent

Convenience class for creating user messages.

Constructor

Automatically sets role="user" and cannot be changed.

Examples

ModelContent

Convenience class for creating model messages.

Constructor

Automatically sets role="model" and cannot be changed.

Examples

Part Union Types

PartUnionDict

Accepts various input formats:

ContentUnion

Content Construction Patterns

Text Only

Multimodal Content

Function Calling

Chat History

Dict Representations

ContentDict

PartDict

Media Resolution

Control tokenization quality for media:

See Also