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

# Call and stream an Agent on another AgentOS

> Call an agent hosted on another AgentOS with RemoteAgent, in both single-shot and streaming mode.

RemoteAgent presents a remote AgentOS Agent through the same asynchronous run shape used by local Agno components.

```python remote_agent.py theme={null}
"""
Call and stream an Agent on another AgentOS
===========================================

RemoteAgent presents a remote AgentOS Agent through the same asynchronous run
shape used by local Agno components.

Prerequisites: start `servers/agentos_server.py` and set OPENAI_API_KEY
Run: .venvs/demo/bin/python cookbook/05_agent_os/20_remote/01_remote_agent.py
Try: change either arithmetic prompt and observe the remote calculator call
"""

import asyncio

from agno.agent import RemoteAgent
from agno.run.agent import (
    RunCompletedEvent,
    RunContentEvent,
    RunErrorEvent,
    RunStartedEvent,
)

BASE_URL = "http://127.0.0.1:7780"

# ---------------------------------------------------------------------------
# Create Remote Agent
# ---------------------------------------------------------------------------

remote_assistant = RemoteAgent(
    base_url=BASE_URL,
    agent_id="assistant-agent",
)

# ---------------------------------------------------------------------------
# Run Remote Agent
# ---------------------------------------------------------------------------


async def run_remote_agent() -> None:
    """Run one complete response and one typed remote stream."""
    response = await remote_assistant.arun(
        "Use the calculator to multiply 17 by 23.",
        session_id="remote-agent-session",
    )
    print(f"Non-streaming run: {response.run_id}")
    print(response.content)

    print("\nStreaming response:")
    async for event in remote_assistant.arun(
        "Use the calculator to add 41 and 1, then explain the result.",
        session_id="remote-agent-session",
        stream=True,
        stream_events=True,
    ):
        if isinstance(event, RunStartedEvent):
            print(f"Run started: {event.run_id}")
        elif isinstance(event, RunContentEvent) and event.content is not None:
            print(event.content, end="", flush=True)
        elif isinstance(event, RunCompletedEvent):
            print(f"\nRun completed: {event.run_id}")
        elif isinstance(event, RunErrorEvent):
            raise RuntimeError(event.content or "Remote Agent run failed")


if __name__ == "__main__":
    asyncio.run(run_remote_agent())
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U "agno[os]" openai
```

**2. Export your API keys**

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

**3. Clone Agno**

Clone the pinned Agno source and run the remaining commands from its root:

```bash theme={null}
git clone https://github.com/agno-agi/agno.git
cd agno
git checkout v3.0.4
```

**4. Start the remote AgentOS**

Open another terminal in the parent directory where `.venv` and the cloned `agno` directory are siblings, then start the upstream on port 7780:

```bash Mac/Linux theme={null}
source .venv/bin/activate
export OPENAI_API_KEY="your_openai_api_key_here"
cd agno
python cookbook/05_agent_os/20_remote/servers/agentos_server.py
```

```powershell Windows theme={null}
.venv\Scripts\activate
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Set-Location agno
python cookbook/05_agent_os/20_remote/servers/agentos_server.py
```

**5. Run the example**

Run the example from the repository root:

```bash theme={null}
python cookbook/05_agent_os/20_remote/01_remote_agent.py
```

Full source: [cookbook/05\_agent\_os/20\_remote/01\_remote\_agent.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/05_agent_os/20_remote/01_remote_agent.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.