AI Agents Pay for Services
with Crypto

A real session where the agent swarm used the x402 protocol to pay $0.05 USDC on Base and generate an image — autonomously.

A cat on a skateboard, anime style — generated via x402 payment

“a cat on a skateboard, anime style”

illustrious-hassuka-xl$0.05 USDCBase mainnet

How x402 Payment Works

1

Client sends POST request to API

2

Server responds with 402 Payment Required

3

Client signs EIP-712 payment (USDC on Base)

4

Client resends with X-PAYMENT header

5

Server validates, returns 200 with image

Session Transcript

T
Taras

Can you create an Openfort wallet (prod) so I can top it up?

AI
Agent Swarm

On it. The plan:

  1. Research the imference.com API (endpoints, pricing, x402 flow)
  2. Write a script using our Openfort wallet 0x6943...271b (5.89 USDC on Base)
  3. Generate the image: “cat on a skateboard, anime style”
  4. Report back each step
AI
Agent Swarm
Step 1 — API Research

Research complete:

EndpointPOST https://imference.com/ondemand/generate
Paymentx402 protocol — $0.05/image in USDC on Base
Modelillustrious-hassaku-xl (anime)
SDK@x402/fetch + @x402/evm handle 402 automatically
AI
Agent Swarm
Step 2 — Environment & Script

Environment configured. Verification script written using createX402Client() from the agent-swarm x402 module with Openfort signer on Base mainnet.

verify-x402.ts
const client = createX402Client({
  signer: openfortSigner,
  chain: "base",
});

const result = await client.fetch(
  "https://imference.com/ondemand/generate",
  {
    method: "POST",
    body: JSON.stringify({
      prompt: "a cat on a skateboard, anime style",
      model: "illustrious-hassuka-xl",
    }),
  }
);
// x402 handles 402 → sign → retry automatically
AI
Agent Swarm
Verification Successful

x402 payment flow verified end-to-end!

Prompt“a cat on a skateboard, anime style”
Modelillustrious-hassuka-xl
Cost$0.05 USDC on Base mainnet
Wallet0x69436bfe16c82a9a5ef74fd3de634c9c822c271b

Real payment on Base mainnet. The entire flow — from request to image — was autonomous.

T
Taras

Nice! Make sure to remember how to pay using x402.

AI
Agent Swarm

Noted. Saved a full x402 delegation guide to memory.

T
Taras

Can you create a new wallet and send me the address?

AI
Agent Swarm

New Openfort production wallet created:

Address0x0c34aa778b2d839e3434af9972d5861e3756894d

Brand new wallet — different from the existing one (0x69436bfe...).