AgentOS Gateway

Create a unified API gateway for multiple AgentOS instances

Create the remote server file

First, create a server that will host agents remotely:

remote_server.py
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools

db = SqliteDb(id="remote-db", db_file="tmp/remote.db")

assistant = Agent(
    name="Assistant",
    id="assistant-agent",
    model=OpenAIResponses(id="gpt-5.2"),
    instructions="You are a helpful assistant.",
    db=db,
)

researcher = Agent(
    name="Researcher",
    id="researcher-agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[HackerNewsTools()],
    db=db,
)

research_team = Team(
    name="Research Team",
    id="research-team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[assistant, researcher],
    db=db,
)

agent_os = AgentOS(
    id="remote-server",
    agents=[assistant, researcher],
    teams=[research_team],
)

app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="remote_server:app", reload=True, port=7778)

Create the gateway file

gateway.py
from agno.agent import RemoteAgent
from agno.os import AgentOS
from agno.team import RemoteTeam

# Create the gateway that proxies to remote agents
gateway = AgentOS(
    id="api-gateway",
    description="Gateway for remote agents and teams",
    agents=[
        RemoteAgent(base_url="http://localhost:7778", agent_id="assistant-agent"),
        RemoteAgent(base_url="http://localhost:7778", agent_id="researcher-agent"),
    ],
    teams=[
        RemoteTeam(base_url="http://localhost:7778", team_id="research-team"),
    ],
)

app = gateway.get_app()

if __name__ == "__main__":
    gateway.serve(app="gateway:app", reload=True, port=7777)

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U "agno[os]" openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Start the Remote Server

In terminal 1, start the remote server:

python remote_server.py

Start the Gateway

In terminal 2, start the gateway:

python gateway.py

Use the Gateway

Now you can access all agents through the gateway at http://localhost:7777:

from agno.client import AgentOSClient
import asyncio

async def main():
    client = AgentOSClient(base_url="http://localhost:7777")
    config = await client.aget_config()
    print(f"Available agents: {[a.id for a in config.agents]}")
    
    # Run a remote agent through the gateway
    response = await client.run_agent(
        agent_id="assistant-agent",
        message="Hello from the gateway!",
    )
    print(response.content)

asyncio.run(main())

If authorization is enabled on remote servers and all endpoints are protected, not all of the functions work correctly on the gateway. Specifically /config, /workflows, /workflows/{workflow_id}, /agents, /teams, /agents/{agent_id}, /teams/{team_id} need to be unprotected for the gateway to work correctly.