Help us shape the future of Go! Take the 2026 Go Developer Survey

a2ui

command
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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(&a2uix.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:

  1. Start this backend (needs a Gemini API key in the environment):

    go run .

  2. 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?"}]}}}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL