Input Formats

Demonstrates different input formats accepted by team run methods.

input_formats.py
"""
Input Formats
=============================

Demonstrates different input formats accepted by team run methods.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.team import Team

# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
researcher = Agent(
    name="Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Research topics",
)

# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
    name="Research Team",
    members=[researcher],
    model=OpenAIResponses(id="gpt-5.2"),
)

# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    # Dict input
    team.print_response(
        {"role": "user", "content": "Explain AI"},
        stream=True,
    )

    # List input
    team.print_response(
        ["What is machine learning?", "Keep it brief."],
        stream=True,
    )

    # Messages list input
    team.print_response(
        [{"role": "user", "content": "What is deep learning?"}],
        stream=True,
    )

How the inputs become messages

The dictionary is validated as a Message. The list of strings is joined with newlines into one user message. The final list of role/content dictionaries is rendered as text inside one user message; it is not parsed as a multi-message conversation.

For a single message with an explicit role, pass Message(role="user", content="What is deep learning?") from agno.models.message, or use the first dictionary form.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as input_formats.py, then run:

python input_formats.py

Full source: cookbook/03_teams/04_structured_input_output/input_formats.py