Output Model

Generate a replacement response with an output model or convert a response to a schema with a parser model.

Set output_model to generate the final answer with a second model after the primary model handles the run.

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools

agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    tools=[HackerNewsTools()],
    output_model=OpenAIResponses(id="gpt-5.2"),
    output_model_prompt="Write a concise report using the supplied research.",
)

agent.print_response("Summarize the top AI stories on Hacker News")

Setup

Install the dependencies in your Python environment and set your OpenAI API key:

pip install agno openai
export OPENAI_API_KEY="your-api-key"

How It Works

  1. The primary model processes the request and handles tool calls.
  2. Agno removes the primary model's final assistant message from the run history.
  3. output_model generates a replacement response from the remaining history, including the user request and tool results.
  4. If parser_model is configured, it parses that replacement into output_schema.

output_model receives the run history with the primary final response removed. Use parser_model when the next model must transform the generated content into a Pydantic object.

Choose a Pipeline

GoalConfigurationFinal call order
Return the primary model's responsemodelPrimary model
Generate the final response with another modelmodel and output_modelPrimary, then output
Convert the response into a schemamodel, parser_model, and output_schemaPrimary, then parser
Generate a replacement and structure itmodel, output_model, parser_model, and output_schemaPrimary, output, then parser

Each secondary model adds a model call to the run.

Parameters

ParameterDescription
modelPrimary model for the run, including reasoning and tool calls
output_modelModel that generates a replacement final response from the run history
output_model_promptSystem prompt for output_model
output_schemaPydantic model or JSON schema for structured output
parser_modelModel that converts the preceding response into output_schema
parser_model_promptSystem prompt for parser_model

parser_model requires output_schema. Agno logs a warning and skips parsing when no schema is set.

Control the Output Model

output_model_prompt replaces the existing system message for the output-model call. Agno inserts it when the run history has no system message.

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools

agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    tools=[HackerNewsTools()],
    output_model=OpenAIResponses(id="gpt-5.2"),
    output_model_prompt=(
        "Return an executive summary with three findings and one recommendation."
    ),
)

agent.print_response("Research recent developments in AI agents")

Parse into a Schema

The parser model receives the preceding model's content as its user message.

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from pydantic import BaseModel, Field


class ArticleSummary(BaseModel):
    title: str
    key_points: list[str] = Field(description="Three to five main points")
    sentiment: str = Field(description="positive, negative, or neutral")


agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    output_schema=ArticleSummary,
    parser_model=OpenAIResponses(id="gpt-5.2"),
    parser_model_prompt="Extract only facts present in the supplied response.",
)

response = agent.run("Summarize recent changes to Python packaging")
if not isinstance(response.content, ArticleSummary):
    raise ValueError(f"Expected ArticleSummary, got: {response.content!r}")
summary = response.content
print(summary.key_points)

Agno supplies a default structured-output instruction when parser_model_prompt is unset. Set a custom prompt for extraction rules such as date formats, item limits, or field-specific constraints.

Combine Output and Parser Models

output_model runs before parser_model. The parser therefore structures the output model's replacement response.

agent = Agent(
    model=OpenAIResponses(id="gpt-5-mini"),
    output_model=OpenAIResponses(id="gpt-5.2"),
    output_model_prompt="Write a concise factual summary.",
    parser_model=OpenAIResponses(id="gpt-5.2"),
    parser_model_prompt="Map the summary to ArticleSummary.",
    output_schema=ArticleSummary,
)