Message Types¶
Types for multimodal content in messages. These types enable you to pass text and images to your agents.
Overview¶
Zap supports multimodal content through these types:
TextContent: Plain text contentImageContent: Image content (URL or base64-encoded data)ContentPart: Union type of text or image contentMessageContent: Either a string or a list of content parts
Usage Example¶
from zap_ai import (
Zap,
ZapAgent,
TextContent,
ImageContent,
)
# Create agent with vision-capable model
agent = ZapAgent(
name="VisionAgent",
prompt="You are a helpful assistant that can see images.",
model="gpt-4o",
)
zap = Zap(agents=[agent])
await zap.start()
# Send multimodal message with text and image
task = await zap.execute_task(
agent_name="VisionAgent",
task=[
TextContent(type="text", text="What's in this image?"),
ImageContent(
type="image_url",
image_url={"url": "https://example.com/photo.jpg"}
),
],
)
API Documentation¶
TextContent¶
zap_ai.TextContent
dataclass
¶
ImageContent¶
zap_ai.ImageContent
dataclass
¶
Image content part in a multimodal message.
Supports URLs (including data: URIs for base64) per LiteLLM spec.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str
|
Image URL or data: URI with base64 content. |
type |
Literal['image_url']
|
Content type identifier (always "image_url"). |
detail |
ImageDetailLevel | None
|
Optional detail level ("auto", "low", "high") for vision models. |
format |
str | None
|
Optional explicit mime type (e.g., "image/png"). |
to_litellm()
¶
Convert to LiteLLM format.
from_litellm(data)
classmethod
¶
Parse from LiteLLM format.
from_url(url, detail=None)
classmethod
¶
Create from an image URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Image URL (http/https). |
required |
detail
|
ImageDetailLevel | None
|
Optional detail level ("auto", "low", "high") for vision models. |
None
|
Returns:
| Type | Description |
|---|---|
ImageContent
|
ImageContent instance. |
from_base64(data, mime_type='image/png', detail=None)
classmethod
¶
Create from base64-encoded image data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Base64-encoded image data (without data: prefix). |
required |
mime_type
|
str
|
Image MIME type (e.g., "image/png", "image/jpeg"). Must be a valid image/* type. |
'image/png'
|
detail
|
ImageDetailLevel | None
|
Optional detail level ("auto", "low", "high") for vision models. |
None
|
Returns:
| Type | Description |
|---|---|
ImageContent
|
ImageContent instance with data: URI. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If mime_type is not a valid image type. |
ContentPart¶
zap_ai.ContentPart = TextContent | ImageContent
module-attribute
¶
MessageContent¶
zap_ai.MessageContent = str | list[ContentPart]
module-attribute
¶
See Also¶
- Multimodal Vision Guide - Complete guide to using images with agents
- Core API - Main Zap classes