# Running Teams (/agent-os/usage/client/run-teams)



<Steps>
  <Step title="Create a Python file">
    ```python title="run_teams.py"
    import asyncio
    import os

    from agno.client import AgentOSClient
    from agno.run.team import RunCompletedEvent, RunContentEvent


    HEADERS = {"Authorization": f"Bearer {os.environ['OS_SECURITY_KEY']}"}

    async def run_team_non_streaming():
        """Execute a non-streaming team run."""
        print("=" * 60)
        print("Non-Streaming Team Run")
        print("=" * 60)

        client = AgentOSClient(base_url="http://localhost:7778")

        # Get available teams
        config = await client.aget_config(headers=HEADERS)
        if not config.teams:
            print("No teams available")
            return

        team_id = config.teams[0].id
        print(f"Running team: {team_id}")

        # Execute the team
        result = await client.run_team(
            team_id=team_id,
            message="What is the capital of France and what is 15 * 7?",
            headers=HEADERS,
        )

        print(f"\nRun ID: {result.run_id}")
        print(f"Content: {result.content}")


    async def run_team_streaming():
        """Execute a streaming team run."""
        print("\n" + "=" * 60)
        print("Streaming Team Run")
        print("=" * 60)

        client = AgentOSClient(base_url="http://localhost:7778")

        # Get available teams
        config = await client.aget_config(headers=HEADERS)
        if not config.teams:
            print("No teams available")
            return

        team_id = config.teams[0].id
        print(f"Streaming from team: {team_id}")
        print("\nResponse: ", end="", flush=True)

        async for event in client.run_team_stream(
            team_id=team_id,
            message="Tell me about Python programming in 2 sentences.",
            headers=HEADERS,
        ):
            if isinstance(event, RunContentEvent):
                print(event.content, end="", flush=True)
            elif isinstance(event, RunCompletedEvent):
                pass

        print("\n")


    async def main():
        await run_team_non_streaming()
        await run_team_streaming()


    if __name__ == "__main__":
        asyncio.run(main())
    ```
  </Step>

    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U "agno[os]" openai
    ```
  </Step>

  <Step title="Set the server model key">
    Set this key in the terminal that starts the example server. The client sends requests to AgentOS and does not call OpenAI directly.

    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        $Env:OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Start an AgentOS Server">
    Set `OS_SECURITY_KEY` in the client terminal to the same value used by the server. The code sends it as a bearer credential on each request.

    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OS_SECURITY_KEY="your_os_security_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```powershell
        $Env:OS_SECURITY_KEY="your_os_security_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    Start the [client example server](/examples/agent-os/python-client/-server) on port 7778. It registers the team used by this client.
  </Step>

  <Step title="Run the Client">
    <CodeBlockTabs defaultValue="Mac">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac">
          Mac
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac">
        ```bash
        python run_teams.py
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        python run_teams.py
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>
</Steps>
