ModelResponse class contains the response from a language model, including content, tool calls, media outputs, and metrics.
Core Fields
Role of the response message.
Text content of the response.
Parsed structured output (when using output_schema).
Media Outputs
Audio generated by the model.
Images generated by LLM or tools.
Videos generated by tools.
Multiple audio outputs from tools.
Files generated by tools.
Tool Calls
Model tool calls (function calls to execute).
Actual tool execution results.
Reasoning
Reasoning/thinking content from the model.
Redacted reasoning content.
Metadata
Event type: “assistant_response”, “tool_call_started”, etc.
Provider-specific metadata.
Citations from the model.
Token usage and timing metrics.
Unix timestamp of response creation.
State Updates
Session state updates from tool executions.
Compression
Statistics about context compression if applied.
Model Metrics
Number of input tokens.
Number of output tokens.
Total token count.
Time to first token in seconds.
Number of reasoning tokens.
Tokens read from cache.
Tokens written to cache.
Methods
to_dict()
Serialize response to dictionary.from_dict()
Deserialize response from dictionary.ToolExecution
Represents the execution of a tool.ID of the tool call.
Name of the tool executed.
Arguments passed to the tool.
Result returned by the tool.
Whether the tool call resulted in an error.
If the tool created a run (agent/team/workflow), its run ID.
HITL Fields
Whether the tool requires user confirmation.
Whether the tool has been confirmed.
Whether the tool requires user input.
Whether the tool requires external execution.