Overview
A2A (Agent-to-Agent) is a protocol that enables AI agents to communicate with each other using JSON-RPC. The Nevermined SDK provides A2A integration to:- Build A2A servers with payment validation
- Automatically verify x402 tokens on incoming requests
- Handle credit redemption for agent tasks
A2A Integration API
Access the A2A integration throughpayments.a2a:
Starting an A2A Server
Basic Server Setup
Building Agent Cards
With Payment Extension
Agent Card Structure
The agent card includes a payment extension:Server Configuration Options
| Option | Type | Required | Description |
|---|---|---|---|
agent_card | AgentCard | Yes | A2A agent card with payment extension |
executor | AgentExecutor | Yes | Your agent implementation |
payments_service | Payments | Yes | Payments instance |
port | int | No | Server port (default: 8080) |
task_store | TaskStore | No | Task storage implementation |
base_path | str | No | Base URL path (default: ”/“) |
expose_agent_card | bool | No | Expose /.well-known/agent.json |
hooks | dict | No | Request lifecycle hooks |
async_execution | bool | No | Enable async task execution |
Request Validation
The A2A server automatically validates payments:- Extracts Bearer token from Authorization header
- Verifies permissions against the agent’s plan
- Rejects requests with 402 if validation fails
Complete Example
Client Usage
Clients interact with the A2A server using the standard A2A protocol:Hooks
Add custom logic at request lifecycle points:Error Handling
| Error Code | HTTP Status | Description |
|---|---|---|
| -32001 | 401 | Missing Bearer token |
| -32001 | 402 | Payment validation failed |
| -32001 | 402 | Agent ID missing from card |