Skip to main content
Trinity
Guides/Nevermined Payments

Nevermined x402 Payments

Monetize agents with per-request payments using the Nevermined x402 payment protocol. Users pay per chat message; agents earn credits.

Concepts

x402 Protocol — HTTP-native payment protocol. Unauthenticated requests to a paid endpoint return HTTP 402 (Payment Required) with payment instructions.
NVM API Key — Nevermined platform API key used to verify payments and settle credits.
Agent ID — The Nevermined-assigned identifier for the agent being monetized.
Plan ID — The Nevermined plan that defines credit pricing and allocation.
Access Token — A payment-signature header value that proves the caller has purchased credits.

Setup (Admin)

1

Open the agent detail page and navigate to the payment settings.

2

Enter the NVM API Key, Agent ID, and Plan ID from Nevermined.

3

Enable payments for the agent.

4

The agent now has a paid chat endpoint: POST /api/paid/{agent_name}/chat.

Payment Flow

Client -> POST /api/paid/{agent}/chat (no token)
  <- 402 Payment Required (includes payment info)

Client -> Purchases credits via Nevermined checkout page
Client -> POST /api/paid/{agent}/chat (payment-signature header)
  <- 200 OK (agent response, 1 credit deducted)
StepAction
1Client sends a chat request without payment credentials
2Trinity returns HTTP 402 with Nevermined payment details
3Client purchases credits via the Nevermined checkout page
4Client retries the request with payment-signature header containing the access token
5Trinity verifies payment, deducts one credit, routes to agent
6Trinity settles the transaction with Nevermined

Payment Info (Public)

Call GET /api/paid/{agent_name}/info to retrieve payment requirements without authentication. Returns the Agent ID, Plan ID, checkout URL, and credits per request.

API Endpoints

EndpointMethodDescription
/api/paid/{agent_name}/chatPOSTPaid chat (returns 402/403/200)
/api/paid/{agent_name}/infoGETPayment requirements (no auth)
/api/nevermined/agents/{name}/configPOSTConfigure payment settings
/api/nevermined/agents/{name}/configGETGet payment configuration
/api/nevermined/agents/{name}/configDELETERemove payment configuration
/api/nevermined/agents/{name}/config/togglePUTEnable or disable payments
/api/nevermined/agents/{name}/paymentsGETPayment history
/api/nevermined/settlement-failuresGETFailed settlements (admin)
/api/nevermined/retry-settlement/{log_id}POSTRetry failed settlement (admin)

MCP Tools

ToolDescription
configure_neverminedSet NVM API Key, Agent ID, Plan ID
get_nevermined_configRetrieve current payment configuration
toggle_neverminedEnable or disable payments
get_nevermined_paymentsView payment history

Limitations

Only one Nevermined plan per agent.
Settlement failures must be retried manually via the admin endpoint.
The payment-signature header is required on every paid request; there is no session persistence.