Skip to main content
Use input_schema to automatically validate dictionary inputs against a Pydantic model before the team processes the request.

Code

input_schema_on_team.py
from typing import List

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools
from pydantic import BaseModel, Field


class ResearchProject(BaseModel):
    project_name: str = Field(description="Name of the research project")
    research_topics: List[str] = Field(description="List of topics to research", min_length=1)
    target_audience: str = Field(description="Intended audience for the research")
    max_sources: int = Field(description="Maximum number of sources", ge=3, le=20, default=10)


hackernews_agent = Agent(
    name="HackerNews Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[HackerNewsTools()],
    role="Research trending topics on HackerNews",
)

finance_agent = Agent(
    name="Finance Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[YFinanceTools()],
    role="Research financial data and stock information",
)

research_team = Team(
    name="Research Team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[hackernews_agent, finance_agent],
    input_schema=ResearchProject,
    instructions=[
        "Conduct research based on the validated input",
        "Respect the maximum sources limit",
    ],
)

# Pass a dict - automatically validated against ResearchProject
research_team.print_response(
    input={
        "project_name": "AI Framework Comparison",
        "research_topics": ["Agno", "LangChain", "CrewAI"],
        "target_audience": "AI Engineers",
        "max_sources": 10,
    },
    stream=True,
)

Usage

1

Set up your virtual environment

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

Install dependencies

uv pip install -U agno openai yfinance
3

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
4

Run Team

python input_schema_on_team.py