Query paid AI agents over HTTP. Get an x402 access token and send it in the payment-signature header to authorize calls with the Nevermined Payments SDK.
Once a Payment Plan is purchased, user(s) can query all the AI Agents linked to that plan.For identifying the user as a valid subscriber, they need to send HTTP requests to the AI Agent and include a valid Access Token. This is sent using the payment-signature HTTP header (per the x402 protocol).
Nevermined Proxy instances are standard HTTP Proxies in charge of authorizing users trying to access AI Agents or Services.
Once a user is a subscriber, sending a request is quite simple.
The access token is minted against a delegation — a one-time authorization that lets the facilitator spend on the subscriber’s behalf, up to a limit. Create the delegation once with createDelegation / create_delegation, then reference it by delegationId whenever you mint a token.
TypeScript
Python
// Create a delegation once — it authorizes spend up to a limit, reusable across tokens.const { delegationId } = await payments.delegation.createDelegation({ provider: 'erc4337', // 'stripe' | 'braintree' | 'visa' for fiat plans spendingLimitCents: 10000, // $100 budget durationSecs: 604800, // 7 days currency: 'usdc', // 'usd' for fiat plans})const { accessToken } = await payments.x402.getX402AccessToken(planId, agentId, { scheme: 'nvm:erc4337', // 'nvm:card-delegation' for fiat plans delegationConfig: { delegationId },})// OUTPUT: accessToken is a JWT string containing X402 v2 payment credentials
from payments_py.x402 import X402TokenOptions, DelegationConfig, CreateDelegationPayload# Create a delegation once — it authorizes spend up to a limit, reusable across tokens.delegation = payments.delegation.create_delegation( CreateDelegationPayload( provider="erc4337", # 'stripe' | 'braintree' | 'visa' for fiat plans spending_limit_cents=10000, # $100 budget duration_secs=604800, # 7 days currency="usdc", # 'usd' for fiat plans ))token_response = payments.x402.get_x402_access_token( plan_id, agent_id, token_options=X402TokenOptions( scheme="nvm:erc4337", # "nvm:card-delegation" for fiat plans delegation_config=DelegationConfig(delegation_id=delegation.delegation_id) ),)access_token = token_response["accessToken"]# OUTPUT: access_token is a JWT string containing X402 v2 payment credentials
Is this a fiat plan or a crypto plan? It determines the provider/currency above and whether you must pass a scheme. The direct getX402AccessToken call defaults to crypto (nvm:erc4337) — for card plans pass scheme: 'nvm:card-delegation'. See Order Plans for how to detect a plan’s type before you pay.
Once you have a valid X402 access token, you can query the AI Agent by making a standard HTTP request with the token in the payment-signature header.This request must be sent directly to the Agent endpoint (the Agent API description is in the Agent Metadata).
Because Nevermined authorizes standard HTTP requests, they can be used to protect any kind of AI Agent or Service exposing an HTTP API.