Deploy agents as A2A servers for agent-to-agent communication.
CLI
pip install "praisonaiagents[os]"
export OPENAI_API_KEY="your-key"
# Start A2A server
praisonai serve a2a --port 8001
| Option | Default | Description |
|---|
--host | 127.0.0.1 | Host to bind to |
--port | 8001 | Server port |
--file | agents.yaml | Agents YAML file |
Python
from praisonaiagents import Agent, A2A
agent = Agent(
name="Assistant",
role="Helpful AI Assistant",
goal="Help users with their questions",
llm="gpt-4o-mini"
)
a2a = A2A(agent=agent)
a2a.serve(host="0.0.0.0", port=8000)
serve() creates a FastAPI app and starts uvicorn for you. For custom FastAPI apps, use a2a.get_router() instead.
Expected Output:
INFO: Started server process
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000
Verify:
curl http://localhost:8000/.well-known/agent.json
Response:
{
"name": "Assistant",
"description": "Helpful AI Assistant",
"url": "http://localhost:8000/a2a",
"version": "1.0.0",
"capabilities": {
"streaming": true,
"pushNotifications": false,
"stateTransitionHistory": false
}
}
agents.yaml
A2A server is Python-only. No agents.yaml support.
A2A Endpoints
| Endpoint | Method | Description |
|---|
/.well-known/agent.json | GET | Agent Card for discovery |
/a2a | POST | JSON-RPC messages |
/status | GET | Server status |
A2A Parameters
| Parameter | Type | Default | Description |
|---|
agent | Agent | — | PraisonAI Agent instance |
agents | AgentTeam | — | Multi-agent team (agents.start() is called) |
name | str | agent.name | A2A endpoint name |
description | str | agent.role | Agent description |
url | str | http://localhost:8000/a2a | A2A endpoint URL |
version | str | 1.0.0 | Version string |
prefix | str | "" | URL prefix |
auth_token | str | None | Bearer token for POST /a2a auth |
Authentication
a2a = A2A(agent=agent, auth_token="sk-my-secret-key")
a2a.serve(port=8000)
Clients must send Authorization: Bearer sk-my-secret-key. Discovery (/.well-known/agent.json) stays public per A2A spec.
Send A2A Message
curl -X POST http://localhost:8000/a2a \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "message/send",
"id": "1",
"params": {
"message": {
"role": "user",
"parts": [{"type": "text", "text": "Hello!"}]
}
}
}'
Response:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"message": {
"role": "agent",
"parts": [{"type": "text", "text": "Hello! How can I help you?"}]
}
}
}
Python Client
import requests
# Get Agent Card
response = requests.get("http://localhost:8000/.well-known/agent.json")
agent_card = response.json()
print(f"Agent: {agent_card['name']}")
# Send Message
message = {
"jsonrpc": "2.0",
"method": "message/send",
"id": "1",
"params": {
"message": {
"role": "user",
"parts": [{"type": "text", "text": "Hello!"}]
}
}
}
response = requests.post("http://localhost:8000/a2a", json=message)
print(response.json())
Troubleshooting
| Issue | Fix |
|---|
| Port in use | lsof -i :8000 |
| Missing deps | pip install "praisonaiagents[os]" |
| No API key | export OPENAI_API_KEY="your-key" |
| Agent Card 404 | Check router is included in app |