AG-UI: Bridging AI Agents and Frontend Applications
The open protocol that connects any agent to any app. Docs · Examples · Spec · Discord AG-UI is an open, lightweight, event-based protocol that standardizes how AI agents connect to user-facing applications. Ag
The open protocol that connects any agent to any app.
Docs · Examples · Spec · Discord
AG-UI is an open, lightweight, event-based protocol that standardizes how AI agents connect to user-facing applications.
Agents don't fit the request/response model. They stream tokens, call tools mid-response, update shared state, pause for a human, and spawn subagents, and every framework does it differently. AG-UI replaces that custom wiring with one bi-directional event stream: the agent emits typed events, and any client can render them, no matter which framework built the agent. The same agent can power a web app, a mobile app, a terminal, or Slack.
Important
AG-UI 1.0 is here. The protocol now has a stable, frozen specification backed by a JSON Schema, and the TypeScript, Python, and .NET SDKs are generated from it. 1.0 is backwards compatible in both directions: 0.x agents work with 1.0 clients and vice versa.
Quick start
Start a new app. The CLI scaffolds a frontend (CopilotKit on Next.js, or a terminal client) wired to the agent framework you pick:
npx create-ag-ui-app@latest
Then follow the printed next steps. The generated templates call OpenAI, so set your key before npm run dev:
export OPENAI_API_KEY="sk-..."
An AG-UI agent is any HTTP endpoint that accepts a RunAgentInput and streams events back. No API keys needed for this one.
1. The agent (Python). Requires Python 3.9+.
pip install ag-ui-protocol fastapi uvicorn
# server.py
import uuid
from fastapi import FastAPI, Request
from fastapi.responses import StreamingResponse
from ag_ui.core import (
PROTOCOL_VERSION,
RunAgentInput,
RunStartedEvent,
RunFinishedEvent,
TextMessageStartEvent,
TextMessageContentEvent,
TextMessageEndEvent,
)
from ag_ui.encoder import EventEncoder
app = FastAPI()
@app.post("/")
async def run_agent(input_data: RunAgentInput, request: Request):
encoder = EventEncoder(accept=request.headers.get("accept"))
async def events():
yield encoder.encode(RunStartedEvent(
thread_id=input_data.thread_id,
run_id=input_data.run_id,
protocol_version=PROTOCOL_VERSION,
))
message_id = str(uuid.uuid4())
yield encoder.encode(TextMessageStartEvent(message_id=message_id, role="assistant"))
for chunk in ["Hello ", "from ", "AG-UI!"]:
yield encoder.encode(TextMessageContentEvent(message_id=message_id, delta=chunk))
yield encoder.encode(TextMessageEndEvent(message_id=message_id))
yield encoder.encode(RunFinishedEvent(thread_id=")
Limitations & Trade-offs
AG-UI may present challenges in managing overlapping event streams, as indicated by community discussions about unresolved pending_tool_calls. Users should ensure proper implementation to avoid such issues.
Originally published on GitTrending — Explore daily architectural deep-dives and quality scores for trending open-source GitHub projects.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.