Skip to main content
GET
http://127.0.0.1:8765
/
a2u
/
info
A2U API
curl --request GET \
  --url http://127.0.0.1:8765/a2u/info \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "stream": "<string>",
  "filters": [
    {}
  ],
  "subscription_id": "<string>"
}
'

A2U API

The A2U (Agent-to-User) API provides Server-Sent Events (SSE) streaming for real-time agent-to-user communication.

Overview

A2U enables real-time event streaming from agents to users, including:
  • Agent status updates
  • Thinking/processing indicators
  • Tool call notifications
  • Response streaming
  • Error notifications

When to Use

  • Real-time UI: Update UI as agent processes
  • Progress tracking: Show agent thinking/tool usage
  • Streaming responses: Display responses as they’re generated

Base URL + Playground

# Start A2U server
praisonai serve a2u --host 127.0.0.1 --port 8083
Base URL: http://127.0.0.1:8083

Endpoints

GET /a2u/info

Get A2U server information and available event types.
curl http://127.0.0.1:8083/a2u/info
Response:
{
  "name": "A2U Event Stream",
  "version": "1.0.0",
  "streams": ["events"],
  "event_types": [
    "agent.started",
    "agent.thinking",
    "agent.tool_call",
    "agent.response",
    "agent.completed",
    "agent.error"
  ]
}

POST /a2u/subscribe

Create a subscription to an event stream.
stream
string
default:"events"
Stream name to subscribe to
filters
array
Optional list of event types to filter
curl -X POST http://127.0.0.1:8083/a2u/subscribe \
  -H "Content-Type: application/json" \
  -d '{"stream": "events", "filters": ["agent.response", "agent.completed"]}'
Response:
{
  "subscription_id": "sub-abc123def456",
  "stream_name": "events",
  "stream_url": "http://127.0.0.1:8083/a2u/events/sub/sub-abc123def456",
  "created_at": "2024-01-15T10:30:00Z"
}

GET /a2u/events/

Subscribe and stream events via SSE.
stream_name
string
default:"events"
Stream name to subscribe to
curl -N http://127.0.0.1:8083/a2u/events/events
SSE Events:
event: agent.started
data: {"agent_id": "agent-1", "agent_name": "Assistant"}
id: evt-001

event: agent.thinking
data: {"agent_id": "agent-1", "message": "Processing query..."}
id: evt-002

event: agent.tool_call
data: {"agent_id": "agent-1", "tool_name": "web_search", "arguments": {"query": "AI"}}
id: evt-003

event: agent.response
data: {"agent_id": "agent-1", "response": "Here are the results..."}
id: evt-004

event: agent.completed
data: {"agent_id": "agent-1", "result": "Task completed"}
id: evt-005

POST /a2u/unsubscribe

Unsubscribe from an event stream.
subscription_id
string
required
Subscription ID to unsubscribe
curl -X POST http://127.0.0.1:8083/a2u/unsubscribe \
  -H "Content-Type: application/json" \
  -d '{"subscription_id": "sub-abc123def456"}'
Response:
{
  "status": "unsubscribed"
}

GET /a2u/health

A2U subsystem health check.
curl http://127.0.0.1:8083/a2u/health
Response:
{
  "status": "healthy",
  "active_subscriptions": 3,
  "active_streams": 1
}

Event Types

EventDescription
agent.startedAgent started processing
agent.thinkingAgent is thinking/processing
agent.tool_callAgent called a tool
agent.responseAgent generated a response
agent.completedAgent completed task
agent.errorAgent encountered an error

Errors

StatusDescription
200Success
400Invalid request
404Subscription not found
500Server error

CLI Equivalent

# Start A2U server
praisonai serve a2u --port 8083

Python SDK

from praisonai.endpoints.a2u_server import (
    emit_agent_started,
    emit_agent_response,
    emit_agent_completed
)

# Emit events from your agent code
emit_agent_started("agent-1", "Assistant")
emit_agent_response("agent-1", "Hello, how can I help?")
emit_agent_completed("agent-1", result="Done")

Notes

  • Events are delivered via Server-Sent Events (SSE)
  • Subscriptions auto-cleanup on disconnect
  • Use filters to reduce event volume
  • Events include timestamps and unique IDs