A2A x402 extension: enabling pay-per-call monetisation for AI agents

9 min read

Os artigos são publicados em inglês; traduções são exibidas quando disponíveis.

Client agentyour-agent.comGET /.well-known/agent-card.json200 · application/a2a+json{ name, description, version, capabilities, supportedInterfaces[], skills[] }
The standard discovery flow augmented with x402 payment negotiation, enabling autonomous agents to verify rates and settle invoices seamlessly.

When AI agents hire other AI agents to execute specialized workflows, traditional billing models break down. Monthly subscriptions and human-signed credit cards cannot support high-frequency, millisecond-scale delegation. The A2A x402 extension revives HTTP 402 to turn the agentic web into an automated economy.

The emergence of machine-to-machine commerce

The A2A protocol specification established how agents advertise capabilities and exchange tasks across corporate boundaries. But as multi-agent ecosystems mature, a critical question emerges: how do service providers monetize high-value agents?

Consider a specialized legal audit agent or a protein-folding analysis model. The operator cannot offer unlimited free access to arbitrary calling agents across the Internet, nor can they ask an autonomous client agent to complete an interactive checkout form.

What autonomous systems need is programmatic, machine-readable monetisation:

  • The calling agent inspects costs before dispatching a task.
  • The receiving agent meters compute or tokens in real time.
  • Payment is settled immediately or streamed per token.

What is the x402 extension?

Developed under the open-source initiative hosted at google-agentic-commerce/a2a-x402, the x402 extension leverages the standardized extensibility model of the core a2aproject/A2A specification.

The name pays homage to HTTP 402 Payment Required, a status code reserved since the 1990s for digital cash systems that never reached global browser consensus.

In multi-agent networks, x402 standardizes:

  1. Pricing Metadata in Agent Cards: Transparent rates declared in /.well-known/agent.json.
  2. Challenge Handshake: A standardized 402 challenge response containing invoice details and accepted payment networks.
  3. Proof-of-Payment Header: Cryptographic receipts or signed payment hashes submitted by the caller to unlock execution.

Declaring payment metadata in Agent Cards

Rather than fragmenting the core specification, x402 uses the official extensions namespace of the A2A v1.0 standard:

Agent Card declaring x402 pricing extensions
{
  "name": "Market Intelligence Oracle",
  "version": "1.0.0",
  "supportedInterfaces": [
    {
      "url": "https://oracle.example.com/a2a/v1",
      "protocolBinding": "JSONRPC",
      "protocolVersion": "1.0"
    }
  ],
  "extensions": {
    "x402": {
      "version": "1.0.0",
      "pricing": {
        "model": "per-call",
        "currency": "USDC",
        "amount": "0.05",
        "network": "base",
        "settlementAddress": "0x71C...3a9B"
      },
      "billingEndpoints": {
        "challenge": "https://oracle.example.com/x402/challenge",
        "verify": "https://oracle.example.com/x402/verify"
      }
    }
  },
  "skills": [
    {
      "id": "deep-equity-scan",
      "name": "Deep Equity Scan",
      "description": "Performs fundamental analysis on listed equity tickers.",
      "tags": ["finance", "equity", "analytics"]
    }
  ]
}

By publishing this document at /.well-known/agent.json, the provider allows calling models to determine whether the requested task fits within their autonomous spending budget before making an initial network call.

The negotiation and settlement lifecycle

The standard interaction cycle between a consumer agent and an x402-enabled provider agent follows a four-step pattern:

Client agentyour-agent.comGET /.well-known/agent-card.json200 · application/a2a+json{ name, description, version, capabilities, supportedInterfaces[], skills[] }

The discovery and payment flow: reading pricing metadata, negotiating terms, and settling execution claims.

  1. Discovery & Evaluation: The client agent reads the provider's Agent Card, parsing the extensions.x402 block to verify acceptable currencies and pricing limits.
  2. Invocation / 402 Challenge: The client submits a task request. If payment has not been pre-authorized, the server halts processing and returns an HTTP 402 with an X-Payment-Required challenge containing a cryptographic invoice hash.
  3. Settlement: The client signs a micropayment transaction (e.g., streaming USDC or generating a settlement token) and resubmits the request with an X-Payment-Authorization header.
  4. Execution & Receipt: The server verifies the settlement on-chain or via its payment gateway, completes the task, and returns the result with an immutable payment receipt.

How to build and generate a monetized agent

Building a commercial AI agent on A2A requires getting the foundational metadata right. If the card schema is invalid, client agents cannot discover or negotiate with your service.

To assemble your card:

  1. Open our Agent Card generator to draft your baseline endpoints, skills, and authentication schemes.
  2. Add your extensions.x402 configuration block defining your rates and accepted settlement networks.
  3. Validate your syntax with our Agent Card validator to ensure full v1.0 compliance.
  4. Deploy the output file to your domain root at /.well-known/agent.json.

Perguntas frequentes

What is the relationship between HTTP 402 and A2A x402?

HTTP status code 402 ("Payment Required") was reserved in the original HTTP specification for digital cash systems. The x402 extension formalizes this concept for AI agents, providing machine-readable payment challenges and settlement receipts.

Which pricing and settlement models are supported by x402?

The extension supports flat pay-per-request pricing, token-based usage metering, and prepaid deposit balances, settling via conventional credit rails, stablecoins, or Lightning networks.

Can an agent offer both free and paid skills?

Yes. The extensions property can be declared at the top-level for default pricing or nested within individual skill definitions to offer free search alongside premium execution.

How do calling agents verify invoice legitimacy before paying?

Calling agents verify that the payment challenge originates from the signed interface endpoint declared in the Agent Card, ensuring funds are routed to the verified provider wallet.

Does the AgentCard.net generator support adding protocol extensions?

Yes, the generator supports the standard v1.0 extensions namespace, allowing you to include x402 pricing descriptors directly in your output JSON.

Referências

  1. A2A protocol specification (a2a-protocol.org)a2a-protocol.org
  2. A2A protocol repository (a2aproject/A2A)github.com/a2aproject/A2A
  3. A2A x402 extension repositorygithub.com/google-agentic-commerce/a2a-x402

Ferramenta relacionada: Agent Card Generator

Próximo passo

Build an A2A-compliant Agent Card in minutes.

Use our interactive generator to configure your interfaces, declare custom extensions, and export clean, production-ready v1.0 JSON.