AI Agent Mode Overview
Understanding how AI agents can make autonomous payments using x402.
Why AI Agents Need Autonomous Payments
In previous lessons, you experienced the human payment flow: click a button, sign a transaction, receive content. This works well for humans but creates friction for AI agents that need to:
- Make hundreds or thousands of small payments automatically
- Operate without human intervention for each transaction
- Access paid services programmatically
Traditional payment systems require human-centric verification (CAPTCHA, KYC, manual approvals) that AI agents cannot complete. x402 solves this by enabling signature-based payments that can be automated.
Two AI Agent Modes
The x402 starter kit demonstrates two approaches to AI-powered payments:
1. Token-Based AI Chat
A pay-per-use chatbot where you pay based on actual token consumption:
- Pricing: $0.001 per 1,000 tokens (with a $0.50 max cap per message)
- Scheme: "upto" - authorize a maximum, pay only what you use
- Use case: Variable-cost AI interactions where usage differs per request
2. Autonomous AI Agent
A fully autonomous agent that manages its own wallet and budget:
- Pricing: Fixed $0.02 per service call (cryptocurrency price lookups)
- Scheme: "exact" - pay the specified amount per request
- Use case: Automated services that need to operate independently
Key Concepts
Agent Wallets
Unlike human payment mode where your main wallet signs each transaction, the autonomous agent uses a dedicated agent wallet:
- Separate from your main wallet: Your funds stay secure
- Encrypted in browser: Private key is encrypted using your wallet address
- Pre-funded with budget: You transfer USDC to set spending limits
- Signs autonomously: No popups or confirmations per transaction
Budget Authorization
Instead of approving each payment, you authorize a budget upfront:
- Create an agent wallet (one-time setup)
- Fund it with USDC (e.g., $0.75 default budget)
- The agent spends from this budget automatically
- Withdraw remaining funds when done
Gasless Payments
Both AI agent modes use the same gasless payment mechanism as human payments:
- Users sign EIP-712 authorizations (not transactions)
- The facilitator submits on-chain transactions
- No AVAX needed in the agent wallet - only USDC
Switching to AI Agent Mode
In the starter kit interface:
- Look for the mode tabs at the top of the page
- Click "AI Agent" to switch from Human Payment mode
- You'll see two sub-modes: Token-Chat and Autonomous-Agents
The following lessons will walk you through each mode in detail.
Is this guide helpful?
