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

# Tool Choice

> Demonstrates using `tool_choice` to force the Team to execute a specific tool.

```python tool_choice.py theme={null}
"""
Tool Choice
===========

Demonstrates using `tool_choice` to force the Team to execute a specific tool.
"""

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


@tool()
def get_city_timezone(city: str) -> str:
    """Return a known timezone identifier for a supported city."""
    city_to_timezone = {
        "new york": "America/New_York",
        "london": "Europe/London",
        "tokyo": "Asia/Tokyo",
        "sydney": "Australia/Sydney",
    }
    return city_to_timezone.get(city.lower(), "Unsupported city for this example")


# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
agent = Agent(
    name="Operations Analyst",
    model=OpenAIResponses(id="gpt-5-mini"),
    instructions=[
        "Use the tool output to answer timezone questions.",
        "Do not invent values that are not in the tool output.",
    ],
)

# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
teams_timezone = Team(
    name="Tool Choice Team",
    model=OpenAIResponses(id="gpt-5-mini"),
    members=[agent],
    tools=[get_city_timezone],
    tool_choice={
        "type": "function",
        "function": {"name": "get_city_timezone"},
    },
    instructions=[
        "You are a logistics assistant.",
        "For every request, resolve the city timezone using the available tool.",
        "Return the timezone identifier only in one sentence.",
    ],
    markdown=True,
)


# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    teams_timezone.print_response("What is the timezone for London?", stream=True)
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `tool_choice.py`, then run:

    ```bash theme={null}
    python tool_choice.py
    ```
  </Step>
</Steps>

Full source: [cookbook/03\_teams/03\_tools/tool\_choice.py](https://github.com/agno-agi/agno/blob/main/cookbook/03_teams/03_tools/tool_choice.py)
