Permit402

See it work in two minutes.

Forecast Co is a pretend weather API sitting behind a real Permit402 gateway. This page plays the AI agent: it has its own test wallet, gets asked to pay, pays, and gets the data. It uses free test USDC, so no real money moves.

permit402.com/g/demo
GET /v1/forecast$0.01
GET /v1/statusFree
Direct to the APIBlocked
  1. Your test wallet

    Created in this browser just now. It only ever holds test money.

    …

    Balance: …    BaseScan

  2. Get free test USDC

    On the Circle faucet choose USDC and Base Sepolia, paste your address and request tokens. It lands in under a minute. Press Refresh.

    Open faucet.circle.com
  3. Call the gateway

    Try each button in turn. The URL is the demo gateway, but you can paste your own gateway's URL here to test it too, as long as it's on the test network.

    What just happened

    1The gateway answered 402 Payment Required with the price, the network and the wallet to pay.
    2The agent signed a USDC payment and retried. The gateway checked it, called Forecast Co, and only settled the payment because the API succeeded. The money went straight to the gateway owner's wallet.
    3Paths without a price go straight through, free.
    4Calling Forecast Co directly fails: it only accepts requests carrying the gateway's secret header. That's the one change you make to your own API.

    The same thing from an agent

    Any x402 client works. With the official SDK it's a wrapped fetch:

    import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
    import { ExactEvmScheme } from "@x402/evm/exact/client";
    import { privateKeyToAccount } from "viem/accounts";
    
    const account = privateKeyToAccount(process.env.AGENT_KEY);
    const pay = wrapFetchWithPaymentFromConfig(fetch, {
      schemes: [{ network: "eip155:84532",
                  client: new ExactEvmScheme(account) }],
    });
    
    const res = await pay(
      "https://permit402.com/g/demo/v1/forecast?city=York");
    console.log(await res.json());

    Put your own API behind a toll

    It takes about ten minutes. The docs walk you through it step by step.