AI agents are becoming smarter, faster, and more useful β but one thing they still struggle with is payments. How does an agent pay for an API call? How does a developer charge for agent services without setting up clunky billing systems?
This is the gap the x402 payments protocol (from Coinbase) is designed to solve. And with our ADK-TS (Agent Development Kit for TypeScript) starter template, we show how developers can build AI agents with native crypto payments β turning pay-per-use into reality.
What is the x402 payments protocol?
The x402 protocol is an open standard from Coinbase that makes HTTP 402 Payment Required usable for the modern web.
The flow is elegantly simple: when you request a paid resource, the server replies with a 402 Payment Required response that tells you exactly how much to pay, what token to use (e.g., USDC), and where to send it. Your client then makes the payment on-chain and retries the request with proof of payment in the X-PAYMENT header. Finally, the server verifies the payment and unlocks the content or API.
This creates a universal pay-to-access system for the internet, powered by crypto micropayments. Unlike credit cards, it works for fractions of a cent, settles instantly, and is globally accessible.

What is ADK-TS? (Agent Development Kit for TypeScript)
ADK-TS is a TypeScript framework for building AI agents, designed to give developers a robust, type-safe foundation for everything from simple chatbots to complex multi-agent systems.
The framework provides built-in support for multiple AI models (OpenAI, Claude, Gemini, etc.), along with essential tools for memory, streaming, and session management.
What sets it apart is its seamless integration capabilities with external services and APIs. With ADK-TS, you don't just write agents β you build enterprise-grade AI systems without boilerplate.
Who is IQ AI?
At IQ AI, we're building the Agent Tokenization Platform β a marketplace where AI agents can be tokenized, traded, and monetized. Developers can publish agents, expose premium features, and even enable agents to transact with one another.
To make this work, agents need the ability to charge and pay seamlessly. That's why we've integrated x402 protocol payments into ADK-TS, creating the foundation for autonomous, monetized AI agents.
How ADK-TS and x402 work together
When you combine ADK-TS agents with the x402 protocol, you unlock a new capability: agents that can charge and pay on-chain automatically. Our starter template demonstrates this through three key components working in harmony:
- The server acts as an x402 paywall proxy, defining free and paid API routes whilst enforcing pricing and verifying payments.
- The agent, built with ADK-TS, intelligently uses free tools for basic operations and paid tools for premium features.
- The client employs axios middleware with wallet integration to handle x402 payment challenges, make on-chain payments in USDC on Base testnet, and retry requests with proof.
The user experience feels seamless:
- The agent greets you and provides free information, such as current API prices.
- When you request a paid action, it clearly states the price and asks for approval.
- Once approved, the payment processes automatically, and the result is returned.
- No API keys. No subscriptions. Just pay-per-call with crypto.
Understanding the Setup
One of the most elegant aspects of this template is that pricing and payment logic live on the server, not buried inside your agent code. This architectural decision brings significant advantages:
- You can change your pricing without redeploying agents
- The agent stays clean and focused only on using tools rather than enforcing payments
- Users get a transparent experience where the agent can tell them upfront how much an action costs before they approve it.
This separation of concerns makes scaling effortless. If the upstream API changes or you decide to tweak the costs of certain actions, your agent doesn't break β the proxy server handles it gracefully.
Deep dive: Agent Template Architecture

The IQ-x402 agent template is structured into two complementary parts that work together seamlessly:
- The server component acts as an x402-paywalled proxy, forwarding requests to the IQ AI API whilst enforcing pricing and exposing a free /api/get-prices route so the agent can always display costs before asking for payment.
- The agent component is a TypeScript agent built with ADK-TS tools, featuring both free and paid functionality. The GET_PRICES tool remains always available, providing transparency about costs.
- The paid tools β GET_AGENT_INFO, GET_AGENT_STATS, GET_HOLDINGS, and GET_TOP_AGENTS β require on-chain payment before returning results, creating a natural division between free exploration and premium insights.
Looking at the implementation, you'll find the core logic distributed across three key files:
- The
server/src/index.ts
defines the pricing map (PAID_ROUTES) and payment middleware, creating the economic backbone of the system. - The
agent/src/agents/IQ-x402/tools.ts
implements both the free and paid tools using the x402-enabled axios client. - Finally,
agent/src/agents/IQ-x402/agent.ts
contains the main agent logic that greets users, fetches prices proactively, and crucially asks for explicit consent before making any paid calls.
Testing the Template
Once everything is set up, running the template gives you a web UI powered by adk-web, where you can interact with the agent directly in your browser. The experience showcases the power of the x402 integration beautifully.
Free actions like fetching prices work instantly, giving users immediate value and transparency. When you request paid actions such as fetching token statistics, the x402 payment flow springs into action:
- The agent requests the resource, and the server returns a 402 Payment Required response.
- Your wallet prompts you to approve a small payment in Base Sepolia testnet USDC.
- Once approved, the agent automatically retries the call and delivers the data.

π‘ Tip: Grab some testnet USDC and ETH from the Base Sepolia faucets before testing, so you can experience the flow without spending real funds.
The Magic of the Combination - ADK-TS + x402
The real magic here lies in how ADK-TS and x402 complement each other perfectly. ADK-TS handles the intelligence side β memory, workflows, streaming, and multi-agent orchestration. Meanwhile, x402 handles the economics side β letting your agent earn, spend, and unlock access with on-chain micropayments.
Together, you can envision agents that sell access to their own tools or knowledge, pay each other for services in true machine-to-machine economies, and monetise data, statistics, or insights on demand without relying on subscriptions or advertisements.
This template serves as a starting point, but it demonstrates how powerful the model becomes: agents that are both intelligent and economically independent.
How users pay with x402 (wallet flow explained)
The payment experience extends beyond just servers receiving funds β users need an intuitive way to make payments with their wallet.
The flow works seamlessly in practice: when a user requests a paid action, the server replies with 402 Payment Required. The wallet integration kicks in, whether it's a browser wallet like MetaMask or Coinbase Wallet, an in-app wallet, or a facilitator service.
For human users, a wallet popup appears asking for approval ("Pay $0.05 USDC?"). For automated agents, the middleware can auto-pay microtransactions or forward the consent request appropriately.
Once payment is sent, the retry request includes an X-PAYMENT header with cryptographic proof. The server then verifies the payment and responds by unlocking the requested content, API data, or agent functionality.
This makes crypto micropayments feel as seamless as paying for coffee β but for digital services.
Why this matters for developers and the AI community
This starter template represents more than just a proof of concept β it's a glimpse into transformative possibilities.
Consider the shift from traditional subscription models to pay-per-API calls, where APIs can charge mere cents per request.
Imagine agent marketplaces where AI agents pay each other for data, models, or services.
Picture decentralised agent economies where agents earn, spend, and transact on-chain autonomously.
By combining ADK-TS and x402, we're enabling a future where AI agents are not just intelligent, but also economically autonomous.
Get started with the ADK-TS x402 template
The template runs on Base Sepolia testnet, allowing you to experiment risk-free using test USDC and ETH from faucets.
You'll receive a complete setup: an x402-enabled server with free and paid routes, an ADK-TS agent wired with both free and paid tools, and a wallet-enabled axios client that handles payments automatically.
Clone it, run pnpm run dev, and start experimenting with monetized AI agents today.
Final thoughts: AI + crypto payments = the future
The internet has waited decades for a standard way to implement pay-to-access functionality. With Coinbase's x402 payments protocol, that standard is finally here. With ADK-TS, we can seamlessly bring it into AI agents. And with IQ AI, we're building the ecosystem where these monetised agents can thrive.
This is just the beginning β the future of autonomous, pay-per-use AI is in your hands.
Resources
- IQ AI x402 Agent Template - Our starter project combining ADK-TS with the x402 protocol
- IQ AI Agent Tokenization Platform - Platform for creating, tokenising, and trading AI agents
- ADK-TS GitHub Repository - The Agent Development Kit (ADK-TS) for TypeScript for building AI agents
- ADK-TS Documentation - Comprehensive guides, API references, and examples
- x402 Official Website - The official site for the x402 protocol, including examples and updates
- x402 GitHub Repository (Coinbase) - The open-source implementation maintained by Coinbase