AG-UI

Expose Agno agents via the AG-UI protocol

AG-UI, the Agent-User Interaction Protocol, standardizes how AI agents connect to frontend applications.

Migration from Apps: For migration from AGUIApp, see the v2 migration guide for complete steps.

Example usage

Install backend dependencies

uv pip install 'agno[os,agui]' openai
export OPENAI_API_KEY="your_openai_api_key"

Run the backend

Save the code as basic.py and run python basic.py. It exposes POST http://localhost:7777/agui using AgentOS and AGUI.

basic.py
from agno.agent.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI

chat_agent = Agent(model=OpenAIResponses(id="gpt-5.4"))

agent_os = AgentOS(agents=[chat_agent], interfaces=[AGUI(agent=chat_agent)])
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="basic:app", reload=True)

Run the frontend

Create a frontend using the AG-UI application starter:

npx create-ag-ui-app@latest

Follow the starter's framework/client choices, then run its documented npm run dev command from the generated project. Configure the frontend's agent connection to use http://localhost:7777/agui, the backend endpoint above. The starter's own generated backend is an alternative; do not assume its default port or agent selection points to this server.

For a custom client, send the AG-UI RunAgentInput payload to that URL and consume the returned event stream. See the AG-UI integrations for client configuration.

Chat with the Agno Agent

Open the URL printed by your frontend dev server after configuring its agent endpoint. A successful connection streams AG-UI events from the backend when you send a message.

Additional examples are available in the cookbook.

Custom Events

Custom events created in tools are automatically delivered to AG-UI in the AG-UI custom event format.

Creating custom events:

from dataclasses import dataclass
from typing import Optional

from agno.run.agent import CustomEvent

@dataclass
class CustomerProfileEvent(CustomEvent):
    customer_name: Optional[str] = None
    customer_email: Optional[str] = None

Yielding from tools: This fragment assumes CustomerProfileEvent above and your application's synchronous fetch_customer function. Register get_customer_profile in the bound agent's tools list for it to be callable:

from agno.tools import tool

@tool()
async def get_customer_profile(customer_id: str):
    customer = fetch_customer(customer_id)

    yield CustomerProfileEvent(
        customer_name=customer["name"],
        customer_email=customer["email"],
    )

    yield f"Profile retrieved for {customer['name']}"

Custom events are streamed in real-time to the AG-UI frontend.

See Custom Events documentation for more details.

Core Components

  • AGUI (interface): Wraps an Agno Agent or Team into an AG-UI compatible FastAPI router.
  • AgentOS.serve: Serves the FastAPI app (including the AGUI router) with Uvicorn.

AGUI mounts protocol-compliant routes on the app.

AGUI interface

Main entry point for AG-UI exposure.

Initialization Parameters

ParameterTypeDefaultDescription
agentOptional[Union[Agent, RemoteAgent]]NoneAgno Agent or RemoteAgent instance.
teamOptional[Union[Team, RemoteTeam]]NoneAgno Team or RemoteTeam instance.
prefixstr""Route prefix (e.g., /chat, /web-research).
tagsOptional[List[str]]["AGUI"]OpenAPI tags for the router.

Provide agent or team.

Key Method

MethodParametersReturn TypeDescription
get_routerNoneAPIRouterReturns the AG-UI FastAPI router and attaches endpoints.

Endpoints

Mounted at the interface's route prefix (root by default):

  • POST /agui: Main entrypoint. Accepts RunAgentInput from ag-ui-protocol. Streams AG-UI events.
  • GET /status: Health/status endpoint for the interface.

Refer to ag-ui-protocol docs for payload details.

Authorization

With authorization enabled, POST /agui requires the run scope for the interface's bound entity: agents:run for an agent, teams:run for a team. Send the JWT as Authorization: Bearer <token>. GET /status requires a valid token but no scope.

For anonymous callers, forwardedProps.user_id attributes the run to a user. Authenticated callers are pinned to their token's principal, and a client-supplied user_id is ignored. See Scopes for the full route-to-scope mapping.

Serving AgentOS

Use AgentOS.serve to run the app with Uvicorn.

Parameters

ParameterTypeDefaultDescription
appUnion[str, FastAPI]requiredFastAPI app instance or import string.
hoststr"localhost"Host to bind. Override with AGENT_OS_HOST env var.
portint7777Port to bind. Override with AGENT_OS_PORT env var.
reloadboolFalseEnable auto-reload for development.
reload_includesOptional[List[str]]NoneFile patterns to watch for auto-reload.
reload_excludesOptional[List[str]]NoneFile patterns to exclude from reload.
workersOptional[int]NoneNumber of Uvicorn worker processes.
access_logboolFalseEnable Uvicorn access logging.

See cookbook examples for updated interface patterns.