Skip to main content
MessageContent encodes text, images, video, audio, and documents for agent execution and chat completions.

MessageContent Overview

MessageContent is a Pydantic model. It validates six content types.

Input Types

Text Input

text is a string.

Image Input

image_url takes an HTTP or HTTPS URL. detail is optional. Default is auto.
detail values:
  • auto (default): The SDK picks the detail level.
  • low: Lower resolution. Faster processing.
  • high: Higher resolution. More detailed analysis.

Video Input

video_url takes an HTTP or HTTPS URL.

Audio Input

audio_url takes an HTTP or HTTPS URL.

Document / File Input (URL)

file_url takes an HTTP or HTTPS URL.

Document / File Input (Upload)

input_file takes a Files API file ID.
input_file accepts file_id (Files API upload) or file_url (presigned or public URL). The SDK fetches the file.

Using Multi-modal Inputs

Each input is a separate field on the input model.
Python

In an Agent Execution

Execution input fields are MessageContent.

In a Chat Completion

Each message content value is an array of content objects. One message can hold several items.

Toolset Selection

toolsets limits the request to the listed tool categories.

Available Tool Categories

Usage Examples

Set toolsets when the task needs a known set of tools. Unused tool routing adds latency and cost.

Best Practices

  • Upload files with the Files API and pass file_id in production. Public URLs are for development and testing.
  • Set detail="high" for fine-grained analysis, such as medical imaging or document OCR. Set detail="low" when speed matters more than detail.
  • URLs must be publicly reachable. Prefer HTTPS. The SDK checks URL format only.
  • Define Pydantic models for agent execution inputs. The SDK validates them.
  • Upload large videos and documents with the Files API. That path reports errors and upload progress.
  • Send text instructions with the media. The text states the operation.
A chat message content array can mix text and media.

URL Validation

image_url, video_url, audio_url, and file_url require http or https. Any other scheme raises ValueError.

Artifacts

Retrieve generated artifacts from agent responses.

Agent Execution

Execute an agent and read structured results.

Agent Creation

Create an agent that accepts these inputs.