Skip to main content

Messages

Verifiers uses a provider-agnostic message format compatible with OpenAI and Anthropic APIs.

Overview

The Messages type represents conversations as lists of message objects, where each message has a role and content.

Type Definition

Message Types

SystemMessage

System instructions that set context for the conversation. Example:

UserMessage

User input or environment observations. Example:
Multimodal:

AssistantMessage

Model responses, including text, reasoning, and tool calls. Text response:
With tool calls:
With reasoning (OpenAI o1/o3):
With thinking blocks (Claude 3.7 Sonnet):

ToolMessage

Tool execution results returned to the model. Example:

TextMessage

Legacy format for completion-style APIs. Example:

MessageContent

Content can be:
  • String: Simple text
  • List of parts: Multimodal content (text, images, audio)

TextContentPart

Example:

ImageUrlContentPart

Example:

InputAudioContentPart

Example:

ToolCall

Represents a tool invocation from the assistant. Example:

Example Usage

Building Conversations

Tool Call Flow

Multimodal Messages

Extracting Content

Formatting for Display

Provider Compatibility

Verifiers messages are compatible with:
  • OpenAI: Direct usage with openai.ChatCompletion.create()
  • Anthropic: Automatic conversion by AnthropicClient
  • Custom APIs: Can be serialized/deserialized as needed

Validation

Messages use Pydantic models for validation:

Dict-like Access

Message objects support dict-like access:

See Also

  • Response - API response format
  • State - Rollout state containing messages
  • Tool - Tool definition format