Skip to main content
Full-stack reference: Go agent server exposes POST /agui as SSE with AG-UI JSON events; Next.js + CopilotKit consumes the stream. Source: examples/agent_with_agui/

What it demonstrates

  • Forwarding ev.ToJSON() over SSE
  • CopilotKit bridge in Next.js (runtimeUrl="/api/copilotkit" — the Go URL is set in the Next API route, not directly in React)
  • AG-UI event sequence for a real frontend

Additional requirements

Node.js (LTS) is required for the Next.js UI in terminal 2. The Go server has no extra dependencies.

Run

From examples/:
# Terminal 1 — Go agent server (:8787)
go run ./agent_with_agui/server

# Terminal 2 — Next.js UI
cd agent_with_agui/ui && npm install && npm run dev
Open http://localhost:3000. Health: GET http://localhost:8787/health. Override Go listen port with PORT=. Point the UI at another host:
AGENT_URL=http://127.0.0.1:8787/agui npm run dev

Try without the UI

curl -N -X POST http://localhost:8787/agui \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{"prompt":"What is 2+2?"}'
You should see data: {...} lines (AG-UI-style JSON from event.ToJSON()). Request body accepts {"prompt":"..."} or {"messages":[{"role":"user","content":"..."}]}. For a production-shaped split API/worker app with persisted chat history, see Agent Chat.

Learn more

AG-UI Protocol

Event format and integration

Stream

CLI streaming without UI

Agent Chat

Full chat app reference