Skip to content

UnifiedResponse

autogen.llm_clients.models.unified_response.UnifiedResponse #

Bases: BaseModel

Provider-agnostic response format.

This response format can represent responses from any LLM provider while preserving all provider-specific features (reasoning, citations, etc.).

Features: - Provider agnostic (OpenAI, Anthropic, Gemini, etc.) - Rich content blocks (text, images, reasoning, citations) - Usage tracking and cost calculation - Provider-specific metadata preservation - Serializable (no attached functions) - Extensible status field for provider-specific statuses

STANDARD_STATUSES class-attribute #

STANDARD_STATUSES = ['completed', 'in_progress', 'failed']

id instance-attribute #

id

model instance-attribute #

model

messages instance-attribute #

messages

usage class-attribute instance-attribute #

usage = Field(default_factory=dict)

cost class-attribute instance-attribute #

cost = None

provider instance-attribute #

provider

provider_metadata class-attribute instance-attribute #

provider_metadata = Field(default_factory=dict)

finish_reason class-attribute instance-attribute #

finish_reason = None

status class-attribute instance-attribute #

status = None

text property #

text

Quick access to text content from all messages.

reasoning property #

reasoning

Quick access to reasoning blocks from all messages.

get_content_by_type #

get_content_by_type(content_type)

Get all content blocks of a specific type across all messages.

This is especially useful for unknown types handled by GenericContent.

PARAMETER DESCRIPTION
content_type

The type string to filter by (e.g., "text", "reasoning", "reflection")

TYPE: str

RETURNS DESCRIPTION
list[BaseContent]

List of content blocks matching the type across all messages

Source code in autogen/llm_clients/models/unified_response.py
def get_content_by_type(self, content_type: str) -> list[BaseContent]:
    """Get all content blocks of a specific type across all messages.

    This is especially useful for unknown types handled by GenericContent.

    Args:
        content_type: The type string to filter by (e.g., "text", "reasoning", "reflection")

    Returns:
        List of content blocks matching the type across all messages
    """
    return [block for msg in self.messages for block in msg.get_content_by_type(content_type)]

is_standard_status #

is_standard_status()

Check if this response uses a standard status value.

RETURNS DESCRIPTION
bool

True if status is one of the standard statuses (completed, in_progress, failed),

bool

False if it's a custom/future status or None

Source code in autogen/llm_clients/models/unified_response.py
def is_standard_status(self) -> bool:
    """Check if this response uses a standard status value.

    Returns:
        True if status is one of the standard statuses (completed, in_progress, failed),
        False if it's a custom/future status or None
    """
    return self.status in self.STANDARD_STATUSES if self.status else False