Skip to main content
The ModelResponse class contains the response from a language model, including content, tool calls, media outputs, and metrics.

Core Fields

role
str
default:"None"
Role of the response message.
content
Any
default:"None"
Text content of the response.
parsed
Any
default:"None"
Parsed structured output (when using output_schema).

Media Outputs

audio
Audio
default:"None"
Audio generated by the model.
images
List[Image]
default:"None"
Images generated by LLM or tools.
videos
List[Video]
default:"None"
Videos generated by tools.
audios
List[Audio]
default:"None"
Multiple audio outputs from tools.
files
List[File]
default:"None"
Files generated by tools.

Tool Calls

tool_calls
List[Dict[str, Any]]
Model tool calls (function calls to execute).
tool_executions
List[ToolExecution]
Actual tool execution results.

Reasoning

reasoning_content
str
default:"None"
Reasoning/thinking content from the model.
redacted_reasoning_content
str
default:"None"
Redacted reasoning content.

Metadata

event
str
default:"assistant_response"
Event type: “assistant_response”, “tool_call_started”, etc.
provider_data
Dict[str, Any]
default:"None"
Provider-specific metadata.
citations
Citations
default:"None"
Citations from the model.
response_usage
MessageMetrics
default:"None"
Token usage and timing metrics.
created_at
int
Unix timestamp of response creation.

State Updates

updated_session_state
Dict[str, Any]
default:"None"
Session state updates from tool executions.

Compression

compression_stats
Dict[str, Any]
default:"None"
Statistics about context compression if applied.

Model Metrics

input_tokens
int
default:"None"
Number of input tokens.
output_tokens
int
default:"None"
Number of output tokens.
total_tokens
int
default:"None"
Total token count.
time_to_first_token
float
default:"None"
Time to first token in seconds.
reasoning_tokens
int
default:"None"
Number of reasoning tokens.
cache_read_tokens
int
default:"None"
Tokens read from cache.
cache_write_tokens
int
default:"None"
Tokens written to cache.

Methods

to_dict()

Serialize response to dictionary.
data = response.to_dict()

from_dict()

Deserialize response from dictionary.
response = ModelResponse.from_dict(data)

ToolExecution

Represents the execution of a tool.
tool_call_id
str
default:"None"
ID of the tool call.
tool_name
str
default:"None"
Name of the tool executed.
tool_args
Dict[str, Any]
default:"None"
Arguments passed to the tool.
result
str
default:"None"
Result returned by the tool.
tool_call_error
bool
default:"None"
Whether the tool call resulted in an error.
child_run_id
str
default:"None"
If the tool created a run (agent/team/workflow), its run ID.

HITL Fields

requires_confirmation
bool
default:"None"
Whether the tool requires user confirmation.
confirmed
bool
default:"None"
Whether the tool has been confirmed.
requires_user_input
bool
default:"None"
Whether the tool requires user input.
external_execution_required
bool
default:"None"
Whether the tool requires external execution.

Example Usage

response = agent.run("What's 2+2?")

print(response.content)  # "The answer is 4."
print(response.response_usage.input_tokens)
print(response.response_usage.output_tokens)

Build docs developers (and LLMs) love