x402

Pay-per-request treasury access for wallet-sovereign agents

x402 is the path for autonomous agents that should not wait for a human-issued API key. The agent receives a 402 challenge, pays with its wallet, retries with an X-Payment proof, and receives the treasury response. Live now on Base Sepolia (testnet) with x402 protocol v1; mainnet settlement on Base activates with the Stackit.ai Base deployment.

Last updated June 12, 2026

Machine-readable prices

Agents should read the price document before attempting paid calls. Free evaluation endpoints are priced at zero.

curl -s https://www.stackit.ai/x402/prices.json | jq

Payment flow

1. RequestAgent calls a paid endpoint without bearer auth or payment proof.
2. ChallengeStackit.ai returns HTTP 402 with price, token, chain, facilitator, and payment target.
3. PayAgent signs and submits the USDC payment using its own wallet.
4. RetryAgent retries the original request with X-Payment: <base64 proof>.
5. ResponseStackit.ai verifies payment and returns the API response or typed safety error.

Challenge shape (x402 v1)

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

{
  "x402Version": 1,
  "error": "X-PAYMENT header is required...",
  "accepts": [{
    "scheme": "exact",
    "network": "base-sepolia",
    "maxAmountRequired": "20000",
    "resource": "https://www.stackit.ai/api/v1/estimate",
    "description": "Live authenticated fee and action estimate.",
    "mimeType": "application/json",
    "payTo": "0x...",
    "maxTimeoutSeconds": 60,
    "asset": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
    "extra": { "name": "USDC", "version": "2" }
  }],
  "sandbox_alternative": "Mint a free key at POST /api/v1/sandbox/keys"
}

Retry shape

curl -X POST https://www.stackit.ai/api/v1/estimate \
  -H "Content-Type: application/json" \
  -H "X-Payment: <base64 PaymentPayload>" \
  -d '{"action":"borrow","amount":10000}'

# Success responses include a settlement receipt:
# X-Payment-Response: <base64 {success, transaction, network, payer}>

The payment is an EIP-3009 USDC authorization signed by the agent wallet, verified and settled through the public facilitator at www.x402.org/facilitator.

TypeScript (official client)

import { wrapFetchWithPayment } from "x402-fetch";
import { privateKeyToAccount } from "viem/accounts";

// Fund the wallet with Base Sepolia USDC from a testnet faucet.
const account = privateKeyToAccount(process.env.AGENT_KEY);
const fetchWithPay = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPay(
  "https://www.stackit.ai/api/v1/treasury",
  { method: "GET" }
); // 402 challenge is paid and retried automatically

Python (official client)

# pip install x402 eth-account httpx
from eth_account import Account
from x402.clients.httpx import x402HttpxClient

account = Account.from_key(AGENT_KEY)
async with x402HttpxClient(
    account=account, base_url="https://www.stackit.ai"
) as client:
    r = await client.get("/api/v1/treasury")

Current status

Testnet live. The five priced endpoints (treasury, health, estimate, borrow, deposits) return spec-correct x402 v1 challenges and settle testnet USDC on Base Sepolia through the public facilitator. Paid calls operate on the same simulated treasury state as the sandbox, keyed to the paying wallet address. Mainnet settlement on Base — and real treasury execution — activates with the Stackit.ai Base deployment. Free alternatives remain: the sandbox ladder and in-protocol live-access requests at POST /api/v1/agents/apply.