Agent Pay Standard

A simple, AI-readable standard for agents to pay for services. No SDK integration needed — just a URL.

The Problem

Your API needs to charge AI agents for access. But agents don't have credit cards, and integrating a payment protocol on both sides is complex. You just want to say “pay me $0.50 to this address” and have the agent figure it out.

The Solution

Return an HTTP 402 response with a link to agent-pay.md — a markdown document that any AI agent can read and follow. The agent reads the instructions, makes a USDC payment from its IndieGent wallet, and retries the request.

No SDK. No protocol handshake. Just text that LLMs understand.


For Service Providers

Step 1: Return a 402 response

When an agent needs to pay, return:

HTTP/1.1 402 Payment Required
Content-Type: application/json

{
  "error": "payment_required",
  "amount": "0.50",
  "token": "USDC",
  "chain": "base",
  "recipient": "0xYourWalletAddress",
  "memo": "search-query-abc123",
  "instructions": "https://indiegent.com/.well-known/agent-pay.md"
}

Step 2: Verify payment on retry

When the agent retries, it includes the transaction hash in the X-Payment-Tx header:

GET /your-endpoint
X-Payment-Tx: 0xabc123def456...

Verify the transaction on Base chain:

  • Confirm it's a USDC transfer to your address
  • Confirm the amount matches what you charged
  • Confirm the transaction is finalized (Base finalizes in ~2 seconds)

Response fields

FieldTypeRequiredDescription
errorstringYesMust be "payment_required"
amountstringYesUSD amount to pay (e.g. "0.50" for 50 cents)
tokenstringYesAlways "USDC"
chainstringYesAlways "base"
recipientstringYesYour wallet address on Base
memostringNoOptional reference (e.g. request ID)
instructionsstringYesURL to agent-pay.md

For Agent Developers

Handling 402 responses

When your agent receives an HTTP 402 with the IndieGent payment format, here's the flow:

  1. Parse the JSON response to get amount, recipient, and memo
  2. Check your wallet balance (is it enough?)
  3. Send a USDC transfer to the recipient on Base chain
  4. Wait for confirmation (~2 seconds)
  5. Retry the original request with X-Payment-Tx: 0x... header

Example handler (JavaScript)

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

const USDC = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
const account = privateKeyToAccount(process.env.INDIEGENT_AGENT_KEY);
const client = createWalletClient({
  account, chain: base, transport: http()
});

async function fetchWithPayment(url, options = {}) {
  let response = await fetch(url, options);

  // If 402, pay and retry
  if (response.status === 402) {
    const payment = await response.json();

    if (payment.error === "payment_required" && payment.chain === "base") {
      // Send USDC payment
      const txHash = await client.writeContract({
        address: USDC,
        abi: [{
          name: "transfer", type: "function",
          inputs: [
            { name: "to", type: "address" },
            { name: "amount", type: "uint256" }
          ],
          outputs: [{ name: "", type: "bool" }],
        }],
        functionName: "transfer",
        args: [payment.recipient, parseUnits(payment.amount, 6)],
      });

      // Retry with payment proof
      response = await fetch(url, {
        ...options,
        headers: {
          ...options.headers,
          "X-Payment-Tx": txHash,
        },
      });
    }
  }

  return response;
}

// Usage — just like fetch() but handles payments automatically
const data = await fetchWithPayment("https://api.example.com/search?q=hello");

The .well-known Files

IndieGent hosts two discovery files that agents and services can reference:

agent-pay.md

https://indiegent.com/.well-known/agent-pay.md

A markdown document written for AI agents. Contains step-by-step payment instructions, contract addresses, code examples, and balance checking guidance. Any LLM can read this and follow the instructions.

agent-pay.json

https://indiegent.com/.well-known/agent-pay.json

Machine-structured JSON with contract addresses, chain IDs, environment variable names, and an example 402 response format. For agents that prefer structured data over prose.


Why Markdown?

AI agents are LLMs. LLMs are great at reading text and following instructions. They're not great at implementing binary protocols or parsing custom headers.

By using a markdown document as the payment “standard,” we meet AI agents where they are. No SDK to install. No protocol to implement. The agent reads the doc, understands what to do, and does it.

This is the same reason robots.txt, security.txt, and llms.txt work — simple text files at well-known URLs that machines can discover and parse.


Comparison with x402

IndieGent Agent Payx402
FormatJSON body + markdown instructionsBase64-encoded HTTP headers
Integration effortReturn a JSON responseInstall middleware + facilitator
Agent readsMarkdown (natural language)Binary protocol
SettlementDirect USDC transferVia facilitator service
Multi-chainBase only (for now)EVM + Solana
GaslessGas sponsored by IndieGentERC-3009 transferWithAuthorization
ComplexityLowHigh

Agent Pay and x402 are complementary. An IndieGent wallet can pay via either standard. Agent Pay is designed for simplicity and AI-native discovery. x402 is designed for protocol-level interoperability.

IndieGentIndieGent — Independent wallets for independent agents

npm install -g @indiegent/cli