- Discovery: publish your AI Agent Card at
/.well-known/agent.json
. - Streaming and re-subscribe: set
capabilities.streaming: true
formessage/stream
andtasks/resubscribe
. - Authentication: credentials are sent in HTTP headers (e.g.,
Authorization: Bearer ...
), not in the JSON‑RPC payload. - Authorization/charging: the agent emits a final event with
metadata.creditsUsed
; Nevermined validates and burns credits accordingly.
Features
The libraries provide ana2a
module that enables seamless integration into new or existing A2A agents, including bearer token authentication, asynchronous task management, and push notification support. Main features:
- Bearer Token Authentication: The server extracts bearer tokens from the Authorization header and injects them into the task context.
- Credits Validation: Validates that the user has sufficient credits before executing a task.
- Credits Burning/Redemption: Redeem the credits specified in the result after successful execution.
- Push Notifications: Supports the A2A standard flow for push notification configuration and delivery.
- Asynchronous Task Handling: Supports intermediate and final state events, compatible with polling and streaming.
- Unified SDK: Provides both agent and client integration.
Quickstart
If you already have a Google A2A agent, or you are building a new one, add the Payments Library to your agent and obtain an API key:1
1. Get Your API Key
To interact with the Nevermined API, you need an API key.
- Go to the Nevermined App.
- Log in via Web3Auth.
- Navigate to the Settings section in the user menu.
- Click on the API Keys tab.
- Generate a new key, give it a descriptive name, and copy it.
- Store this key securely as an environment variable (e.g.,
NVM_API_KEY
).
2
2. Install and Initialize the Payments Library
Install the Payments Library and initialize the
Payments
client with your API key.Initialize the Payments Library
A2A Server
Add the Payment Extension to the Agent Card
Because your AI agent charges for requests, add a payment extension to your agent card. Add a payment extension undercapabilities.extensions
carrying Nevermined metadata:
- The
url
must match exactly the URL registered in Nevermined for the agent/plan. - The final streaming event must include
metadata.creditsUsed
with the consumed cost.
Define the Payment Agent Card in Your A2A Agent
Start the A2A Server
The agent is initialized using the Nevermined Payments Library and the A2A protocol. The executor defines the business logic for each type of request.- The Executor class routes and handles all supported operations (greeting, calculation, weather, translation, streaming, push notification).
- The handleTask method returns both the result and a boolean indicating if more updates are expected (for async flows).
- The agent publishes the initial task, intermediate status updates, and the final event as per the A2A standard.