Documentation
¶
Overview ¶
This sample serves an A2UI-enabled agent over HTTP, compatible with the browser frontend in js/testapps/a2ui/web. The whole A2UI integration is the a2ui middleware in the agent's inline prompt (`ai.WithUse(&a2ui.Surfaces{})`): it injects the catalog's capabilities into the system prompt and rewrites the model's a2ui fenced blocks into a2ui data parts that the client renderer consumes.
The agent is served at POST /api/uiAgent (plus the /getSnapshot and /abort companions the `remoteAgent` client expects), the exact endpoint the web UI talks to via `remoteAgent({ url: '/api/uiAgent' })`.
To run the whole thing:
Start this backend (needs a Gemini API key in the environment):
go run .
Build and preview the web UI (in js/testapps/a2ui/web):
pnpm install pnpm build pnpm preview
Then open the printed URL (http://localhost:4173). The Vite preview server proxies /api to this backend on :8080.
You can also drive the agent directly with curl:
curl -N -X POST 'http://localhost:8080/api/uiAgent?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"message": {"role": "user", "content": [{"text": "What is the weather in Tokyo?"}]}}}'