Skip to main content
When the Team has a model:
  • Agents without a model use the Team’s model
  • Agents with their own model keep their own model
  • In nested teams, agents use the model from their direct parent team
  • The reasoning_model, parser_model, and output_model must be set explicitly on each team member or team
When the Team has no model:
  • The Team and all agents default to OpenAI gpt-4o
1

Create a Python file

touch model_inheritance.py
2

Add the following code to your Python file

model_inheritance.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.team.team import Team

# These agents don't have models set
researcher = Agent(
    name="Researcher",
    role="Research and gather information",
    instructions=["Be thorough and detailed"],
)

writer = Agent(
    name="Writer",
    role="Write content based on research",
    instructions=["Write clearly and concisely"],
)

# This agent has a model set
editor = Agent(
    name="Editor",
    role="Edit and refine content",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions=["Ensure clarity and correctness"],
)

# Nested team setup
analyst = Agent(
    name="Analyst",
    role="Analyze data and provide insights",
)

sub_team = Team(
    name="Analysis Team",
    model=OpenAIChat(id="gpt-5-mini"),
    members=[analyst],
)

team = Team(
    name="Content Production Team",
    model=OpenAIChat(id="gpt-4o"),
    members=[researcher, writer, editor, sub_team],
    instructions=[
        "Research the topic thoroughly",
        "Write clear and engaging content",
        "Edit for quality and clarity",
        "Coordinate the entire process",
    ],
    show_members_responses=True,
)

team.initialize_team()

# researcher and writer inherit gpt-4o from team
print(f"Researcher model: {researcher.model.id}")
print(f"Writer model: {writer.model.id}")

# editor keeps its explicit model
print(f"Editor model: {editor.model.id}")

# analyst inherits gpt-5-mini from its sub-team
print(f"Analyst model: {analyst.model.id}")

team.print_response(
    "Write a brief article about AI", stream=True
)
3

Create a virtual environment

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

Install libraries

pip install -U agno openai
5

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
6

Run Team

python model_inheritance.py
7

Find All Cookbooks

Explore all the available cookbooks in the Agno repository. Click the link below to view the code on GitHub:Agno Cookbooks on GitHub