> ## Documentation Index
> Fetch the complete documentation index at: https://spacesail.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Inheritance

This example demonstrates how agents automatically inherit the model from their parent team.

**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`

```python model_inheritance.py theme={null}
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
)
```

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install required libraries">
    ```bash theme={null}
    pip install agno openai
    ```
  </Step>

  <Step title="Set environment variables">
    ```bash theme={null}
    export OPENAI_API_KEY=****
    ```
  </Step>

  <Step title="Run the agent">
    ```bash theme={null}
    python model_inheritance.py
    ```
  </Step>
</Steps>
