x402 Standard: Enabling Seamless Open Payment Integration

Overview

x402 is the open payment standard that enables services to charge for access to their APIs and content directly over HTTP. It is built around the HTTP 402 Payment Required status code and allows clients to programmatically pay for resources without accounts, sessions, or credential management.

With x402, any web service can require payment before serving a response β€” using crypto-native payments for speed, privacy, and efficiency.

We integrates x402 to enable AI agents and wallets to access on-chain analytics and insights seamlessly, with built-in authentication and pay-per-call support using wallet-based payments.

What is x402?

x402 is an emerging open standard developed by Coinbase for AI-native API access.

It defines how AI agents and applications can securely authenticate, authorize, and pay for API calls using crypto wallets instead of traditional API keys or credit cards.

In short, x402 is:

  • A crypto-based API gateway standard.

  • Designed for agentic workloads β€” enabling APIs to be called directly by AI models or smart wallets.

  • Built around verified identities and per-call metered billing using on-chain settlements.

Why x402?

Benefit
Description

Crypto-native authentication

No API keys β€” access is verified via signed requests or delegated wallet credentials.

On-chain billing & metering

Pay for API usage via tokens or smart contract credits.

Agent compatibility

AI agents and dApps can directly call APIs through their wallet identity.

Unified access layer

Works seamlessly across multiple providers that support the x402 protocol (e.g., Coinbase, OpenAI agents, Virtuals).

Security & trust

No shared secrets or keys in backend configs β€” access is cryptographically validated.

This makes x402 ideal for AI agents, autonomous analytics services, and dApps that need dynamic, authenticated access to data APIs.


How We Supports x402

The AI Data APIs natively support x402 headers and payment flows, allowing secure, wallet-based access to paid API endpoints.

High-level workflow

  1. Initial request:

    The agent or user makes a request to the API endpoint (e.g., /v1/ask-loky).

  2. Payment challenge:

    If payment is required, the API responds with a 402 Payment Required status and includes payment instructions in the response body.

  3. Payment authorization:

    The client (AI agent, wallet, or automated service) completes the payment using an x402-compatible wallet or SDK, which signs the payment payload as proof of payment.

  4. Retry with proof:

    The client retries the same request, now including the X-PAYMENT header containing the cryptographic proof of payment.

  5. Verification and response:

    The server verifies the payment via the x402 facilitator. Once validated, the API returns the requested on-chain data or AI insights securely.


Supported APIs with x402


Technical details

This section explains how developers can integrate x402 with AI Data APIs using Node.js, including authentication, payments, and rate limits.

Integration with x402 using Node.js is simple and can be summarized in 3 steps:

  1. Install x402-fetch.

  2. Create a wallet client (EVM).

  3. Use the wrapper to make paid API requests β€” payment flows are handled automatically.

Here’s Node.js example to make requests using x402-fetch (see the official documentation for examples in other languages).

Prerequisites

Before starting, ensure you have:

  • A crypto wallet with USDC (any EVM-compatible wallet)

  • Node.js and npm

  • Service to access to a endpoint requiring x402 payment

1. Install Dependencies

npm install x402-fetch

2. Create a Wallet Client (EVM)

import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";

// Load private key from environment variable
const account = privateKeyToAccount(process.env.PRIVATE_KEY!);

3. Make Paid Requests Automatically (x402-fetch)

import { wrapFetchWithPayment, decodeXPaymentResponse } from "x402-fetch";

// Wrap native fetch with x402 payment support
const fetchWithPayment = wrapFetchWithPayment(fetch, account);

const response = await fetchWithPayment(
	"<https://api.dapplooker.com/v1/trending>", 
	{
	  method: "GET",
	}
);

const body = await response.json();
console.log(body);

const paymentResponse = decodeXPaymentResponse(
  response.headers.get("x-payment-response")!
);
console.log(paymentResponse);

The client handles 402 Payment Required responses automatically, completes the payment flow, and retries the request with the correct X-PAYMENT header.


4. Authentication

  • Wallet-based β€” no API keys required.

  • X-PAYMENT header contains cryptographic proof of payment.

  • Supported wallets: Coinbase Smart Wallet, Virtuals Agent Wallet, or any x402-compliant client.

  • Stateless authentication β€” no sessions or credential storage needed.


5. Rate Limits

  • Default rate limits per wallet/account apply.

  • Excessive unpaid or failed requests may trigger temporary throttling.


References


Examples & Use Cases

1. AI Agent Calling APIs

An on-chain AI agent receives a user query like

β€œAnalyze recent liquidity inflow for $VIBES.”

The agent:

  • Signs a request via its x402 wallet.

  • Calls POST /api/v1/ask-loky with x402-authorization.

  • Receives structured analytics data.

2. Virtuals ACP Agent Integration

Virtuals ACP buyer agents use the APIs via x402 for authenticated data delivery inside the Agent Commerce Protocol (ACP).


FAQ

Do I need an API key if I’m using x402?

No β€” x402 replaces traditional API key authentication.

Can I use x402 with any EVM wallet?

Only wallets or agents that implement the x402 signing spec (currently Coinbase Smart Wallet,

Last updated

Was this helpful?