content
Attribute AssistantContentChunk
Type: TypeAlias
Chunks of assistant content that may be streamed as generated by the LLM.
Attribute AssistantContentPart
Type: TypeAlias
Content parts that can be included in an AssistantMessage.
Class Audio
Audio content for a message.
Audio can be included in messages for voice or sound-based interactions.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['audio'] | - |
| source | Base64AudioSource | - |
Function download
Download and encode an audio file from a URL.
Parameters
Returns
| Type | Description |
|---|---|
| Audio | An `Audio` with a `Base64AudioSource` |
Function download_async
Asynchronously download and encode an audio file from a URL.
Parameters
Returns
| Type | Description |
|---|---|
| Audio | An `Audio` with a `Base64AudioSource` |
Function from_file
Create an Audio from a file path.
Parameters
Returns
| Type | Description |
|---|---|
| Audio | - |
Function from_bytes
Create an Audio from raw bytes.
Parameters
Returns
| Type | Description |
|---|---|
| Audio | - |
Class Base64AudioSource
Audio data represented as a base64 encoded string.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['base64_audio_source'] | - |
| data | str | The audio data, as a base64 encoded string. |
| mime_type | AudioMimeType | The mime type of the audio (e.g. audio/mp3). |
Class Base64DocumentSource
Document data represented as a base64 encoded string.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['base64_document_source'] | - |
| data | str | The document data, as a base64 encoded string. |
| media_type | DocumentBase64MimeType | The media type of the document (e.g. application/pdf). |
Class Base64ImageSource
Image data represented as a base64 encoded string.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['base64_image_source'] | - |
| data | str | The image data, as a base64 encoded string. |
| mime_type | ImageMimeType | The mime type of the image (e.g. image/png). |
Attribute ContentPart
Type: TypeAlias
Content parts that may be included in a Message.
Class Document
Document content for a message.
Documents (like PDFs) can be included for the model to analyze or reference.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['document'] | - |
| source | Base64DocumentSource | TextDocumentSource | URLDocumentSource | - |
Function from_url
Create a Document from a URL.
Returns
| Type | Description |
|---|---|
| Document | - |
Function from_file
Create a Document from a file path.
Parameters
Returns
| Type | Description |
|---|---|
| Document | - |
Function from_bytes
Create a Document from raw bytes.
Parameters
Returns
| Type | Description |
|---|---|
| Document | - |
Class Image
Image content for a message.
Images can be included in messages to provide visual context. This can be used for both input (e.g., user uploading an image) and output (e.g., model generating an image).
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['image'] | - |
| source | Base64ImageSource | URLImageSource | - |
Function from_url
Create an Image reference from a URL, without downloading it.
Parameters
| Name | Type | Description |
|---|---|---|
| cls | Any | - |
| url | str | The URL of the image |
Returns
| Type | Description |
|---|---|
| Image | An `Image` with a `URLImageSource` |
Function download
Download and encode an image from a URL.
Parameters
Returns
| Type | Description |
|---|---|
| Image | An `Image` with a `Base64ImageSource` |
Function download_async
Asynchronously download and encode an image from a URL.
Parameters
Returns
| Type | Description |
|---|---|
| Image | An `Image` with a `Base64ImageSource` |
Function from_file
Create an Image from a file path.
Parameters
Returns
| Type | Description |
|---|---|
| Image | - |
Function from_bytes
Create an Image from raw bytes.
Parameters
Returns
| Type | Description |
|---|---|
| Image | - |
Attribute ImageMimeType
Type: Literal['image/png', 'image/jpeg', 'image/webp', 'image/gif', 'image/heic', 'image/heif']
Class Text
Text content for a message.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['text'] | - |
| text | str | The text content. |
Class TextChunk
Represents an incremental text chunk in a stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['text_chunk'] | - |
| content_type | Literal['text'] | The type of content reconstructed by this chunk. |
| delta | str | The incremental text added in this chunk. |
Class TextDocumentSource
Plain text document data.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['text_document_source'] | - |
| data | str | The document data, as plain text. |
| media_type | DocumentTextMimeType | The media type of the document (e.g. text/plain, text/csv). |
Class TextEndChunk
Represents the end of a text chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['text_end_chunk'] | - |
| content_type | Literal['text'] | The type of content reconstructed by this chunk. |
Class TextStartChunk
Represents the start of a text chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['text_start_chunk'] | - |
| content_type | Literal['text'] | The type of content reconstructed by this chunk. |
Class Thought
Thinking content for a message.
Represents the thinking or thought process of the assistant. These generally are summaries of the model's reasoning process, rather than the direct reasoning tokens, although this behavior is model and provider specific.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['thought'] | - |
| thought | str | The thoughts or reasoning of the assistant. |
Class ThoughtChunk
Represents an incremental thought chunk in a stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['thought_chunk'] | - |
| content_type | Literal['thought'] | The type of content reconstructed by this chunk. |
| delta | str | The incremental thoughts added in this chunk. |
Class ThoughtEndChunk
Represents the end of a thought chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['thought_end_chunk'] | - |
| content_type | Literal['thought'] | The type of content reconstructed by this chunk. |
Class ThoughtStartChunk
Represents the start of a thought chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['thought_start_chunk'] | - |
| content_type | Literal['thought'] | The type of content reconstructed by this chunk. |
Class ToolCall
Tool call content for a message.
Represents a request from the assistant to call a tool. This is part of an assistant message's content.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['tool_call'] | - |
| id | str | A unique identifier for this tool call. |
| name | str | The name of the tool to call. |
| args | str | The arguments to pass to the tool, stored as stringified json. |
Class ToolCallChunk
Represents an incremental tool call chunk in a stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['tool_call_chunk'] | - |
| content_type | Literal['tool_call'] | The type of content reconstructed by this chunk. |
| delta | str | The incremental json args added in this chunk. |
Class ToolCallEndChunk
Represents the end of a tool call chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['tool_call_end_chunk'] | - |
| content_type | Literal['tool_call'] | The type of content reconstructed by this chunk. |
Class ToolCallStartChunk
Represents the start of a tool call chunk stream.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['tool_call_start_chunk'] | - |
| content_type | Literal['tool_call'] | The type of content reconstructed by this chunk. |
| id | str | A unique identifier for this tool call. |
| name | str | The name of the tool to call. |
Class ToolOutput
Tool output content for a message.
Represents the output from a tool call. This is part of a user message's content, typically following a tool call from the assistant.
Bases:
Generic[JsonableT]Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['tool_output'] | - |
| id | str | The ID of the tool call that this output is for. |
| name | str | The name of the tool that created this output. |
| value | JsonableT | The output value from the tool call. |
Class URLDocumentSource
Document data referenced via external URL.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['url_document_source'] | - |
| url | str | The url of the document (e.g. https://example.com/paper.pdf). |
Class URLImageSource
Image data referenced via external URL.
Attributes
| Name | Type | Description |
|---|---|---|
| type | Literal['url_image_source'] | - |
| url | str | The url of the image (e.g. https://example.com/sazed.png). |
Attribute UserContentPart
Type: TypeAlias
Content parts that can be included in a UserMessage.