Skip to main content
This example demonstrates how to pass an output_schema to a specific team run, allowing you to get structured output without setting a default schema on the team.
1

Add the following code to your Python file

output_schema_on_run.py
from pydantic import BaseModel
from agno.agent import Agent
from agno.team import Team
from agno.models.openai import OpenAIChat


class MarketReport(BaseModel):
    overview: str
    findings: list[str]


analyst = Agent(name="Analyst", model=OpenAIChat(id="gpt-4o-mini"))
team = Team(members=[analyst], model=OpenAIChat(id="gpt-4o-mini"))

response = team.run(
    "Analyze the current AI market trends",
    output_schema=MarketReport,
    stream=False,
)

print(response.content)
2

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
3

Install libraries

pip install -U agno openai
4

Export your OpenAI API key

  export OPENAI_API_KEY="your_openai_api_key_here"
5

Run the example

python output_schema_on_run.py