> ## 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.

# Server: A2A

> Deploy agents as A2A (Agent-to-Agent) protocol servers

Deploy agents as A2A servers for agent-to-agent communication.

## CLI

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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)
```

<Tip>
  `serve()` creates a FastAPI app and starts uvicorn for you. For custom FastAPI apps, use `a2a.get_router()` instead.
</Tip>

**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:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl http://localhost:8000/.well-known/agent.json
```

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "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

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "jsonrpc": "2.0",
  "id": "1",
  "result": {
    "message": {
      "role": "agent",
      "parts": [{"type": "text", "text": "Hello! How can I help you?"}]
    }
  }
}
```

## Python Client

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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     |

## Related

* [A2A API Reference](../api/a2a-api) - Full A2A endpoint documentation
* [AGUI Server](./agui) - Deploy as AGUI server
* [Agents Server](./agents) - Deploy as HTTP server
