Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
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 name to subscribe to
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 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 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
| Event | Description |
|---|
agent.started | Agent started processing |
agent.thinking | Agent is thinking/processing |
agent.tool_call | Agent called a tool |
agent.response | Agent generated a response |
agent.completed | Agent completed task |
agent.error | Agent encountered an error |
Errors
| Status | Description |
|---|
| 200 | Success |
| 400 | Invalid request |
| 404 | Subscription not found |
| 500 | Server 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