Key Moments

AI Dev 26 x SF | Ondra Urban: Agents with Wallets? Putting 25,000 Tools on x402

DeepLearning.AIDeepLearning.AI
Education5 min read22 min video
May 21, 2026|49 views|1
Save to Pod

Want to know something specific about what's covered?

We've already dissected every moment. Ask and we will deliver (with timestamps).

TL;DR

Agents can now pay for tools and services using a new HTTP 402 protocol, but a clever refund workaround is needed for usage-based pricing instead of an 'up to' payment scheme.

Key Insights

1

The HTTP 402 Payment Required status code, popularized by the x402 protocol, allows agents to pay for services directly.

2

Apify's marketplace of 25,000 tools ('actors') processed $1.2 million in revenue for its global developer community in the last month.

3

The initial 'exact' payment scheme in x402 is unsuitable for dynamic, usage-based pricing models common in LLM token generation or database queries.

4

Apify implements a 'refund-based' workaround for the 'exact' scheme by overcharging and returning unused funds, a practice adapted from the x402 community.

5

Coinbase recently released the 'up to' payment scheme for x402, which Apify now supports, though client adoption is still pending.

6

The MCPC CLI tool allows agents to sign payments using x402 without exposing private keys by storing credentials securely in the system keychain.

The challenge of agent payments today

Currently, AI agents interacting with the real world through tools face significant hurdles when it comes to payments. While agents can be programmed to discover restaurants, book concerts, or shop for gifts using various tools and APIs, the final step of payment is a major bottleneck. Common methods like sharing credit card details are fraught with security risks and lack real-time control over spending limits. Alternatively, manually subscribing to every service an agent might use becomes unmanageable as the number of tools grows. This gap prevents agents from performing end-to-end tasks autonomously, requiring human intervention for financial transactions.

Introducing agentic payment protocols

To address this, agentic payment protocols have emerged as a standardized way for agents and service providers to communicate about financial transactions. Instead of each agent needing to learn unique payment methods for every vendor, a common standard is adopted. Several protocols exist, including L402, AP2, UCP, ACP, and Visa Intelligent Commerce, with x402 being a prominent contender focused on API payments. These protocols offer varying features, such as anonymity, authentication, and suitability for different transaction types, indicating that a multi-protocol approach might be necessary as the ecosystem matures.

Understanding the x402 protocol

The x402 protocol, an open-source standard by Coinbase, leverages the HTTP 402 Payment Required status code. Unlike L402, which used the Bitcoin Lightning Network and incurred higher costs and complexity, x402 utilizes USDC on the Coinbase base blockchain, making it more accessible. A key improvement in x402 V2 is the transition of all payment-related information from JSON response bodies to headers. This crucial change allows for easier integration into existing APIs without requiring modifications to their core functionality, enabling implementation via simple middleware. The protocol is decentralized, built on blockchain technology, and initially focused on APIs. The entire flow is designed for a seamless user experience: an agent requests a resource, receives a 402 response, creates a payment signature, resubmits the request with the signature, the server verifies the payment via a facilitator, performs the work, and then settles the transaction and delivers the content. This sequence prioritizes immediate service delivery over pre-payment, with settlement occurring only after verification and work completion.

The 'exact' payment scheme's limitations

A significant hurdle for widespread adoption of x402, especially for platforms like Apify with a diverse range of tools, is the 'exact' payment scheme. This scheme requires a predefined, fixed amount to be charged for a service. While suitable for static resources or predictable API calls, it falters when dealing with usage-based pricing. For instance, generating LLM tokens or executing complex database queries involves dynamic costs that cannot be precisely known upfront. Apify, hosting 25,000 'actors' (tools) developed by a global community, processes $1.2 million in revenue monthly. The dynamic nature of many of these actors, such as a Google Maps scraper that might retrieve an unknown number of reviews, makes the 'exact' scheme impractical. The inability to accurately estimate costs for variable usage hinders the seamless operation of such services for agents.

The refund-based workaround

To circumvent the limitations of the 'exact' payment scheme, Apify, adapting an idea from the x402 community, implemented a clever workaround: the 'exact' scheme with refunds. Instead of setting the exact charge amount, the system sets the charge as an upper bound, effectively acting like an 'up to' scheme. A slightly higher amount than anticipated is charged initially, and any unused portion of the payment is refunded. This is possible because the payment payload includes the sender's wallet address. A crypto transaction can then be initiated to return the overpaid amount. This method allows agents to utilize services with dynamic pricing without upfront cost uncertainty, bridging the gap left by the strict 'exact' scheme. While not formally part of the protocol, this practical solution enables functionality that would otherwise be impossible.

Adoption of the 'up to' scheme and MCPC

Recently, Coinbase released the 'up to' payment scheme for x402, which simplifies charging for variable usage by allowing a maximum charge amount. Apify has now adopted this standard, which is a significant improvement over their refund workaround. However, client adoption of the 'up to' scheme is still developing, meaning the refund method will continue to be used for transactions where the client does not yet support the new standard. For agents to actually make payments, they need a secure way to connect their wallets. Apify recommends against embedding private keys directly into the agent's context. Instead, they utilize a tool like the MCPC CLI, which securely manages credentials in the system keychain and provides only the payment signature to the agent, thus preventing the leakage of sensitive private keys while enabling secure, agent-driven payments.

Demo and integration with MCP

A demonstration showcased the x402 payment process using Apify's platform. An agent was prompted to scrape Instagram posts from National Geographic, specifying payment via x402 using the MCPC CLI. The agent successfully fetched the necessary tools, verified the availability of funds ($10+ balance), and initiated the payment. The transaction, confirmed on blockchain explorers, showed a charge of $1 and a subsequent refund of 99 cents, demonstrating the effectiveness of the refund mechanism for a usage cost of just one cent. This process can work seamlessly with both Apify's platform API and its Model Context Protocol (MCP) server. While MCP typically uses a 401 unauthorized response for authentication, x402 requires a 402. To accommodate this, Apify uses a custom query parameter 'payment_x402' for x402 payments within MCP. The MCPC CLI plays a crucial role here by facilitating the payment signature generation, which is then appended to the API request, enabling direct API usage with payment executed through the x402 protocol.

Payment Protocols Mentioned

Data extracted from this episode

ProtocolKey FeaturesStatus
L402Uses Bitcoin Lightning Network, expensive, difficult to work withNot popular
X42Uses HTTP 402, open source, by Coinbase, uses USDC, request/response headers only, decentralizedBeing popularized
Exact Scheme (X42)Requires exact amount upfront, good for fixed callsLimited for dynamic pricing
Exact Scheme with Refunds (Hack)Charges upper bound, refunds unused amountWorkaround for dynamic pricing
Up to Scheme (X42)Charges up to a certain amountRecently released, not widely supported yet

Common Questions

Agentic payments refer to systems where AI agents can independently make payments for services or tools. The challenge lies in securely and reliably enabling agents to transact in the real world without direct human oversight, especially with fluctuating costs.

Topics

Mentioned in this video

More from DeepLearningAI

View all 94 summaries

Ask anything from this episode.

Save it, chat with it, and connect it to Claude or ChatGPT. Get cited answers from the actual content — and build your own knowledge base of every podcast and video you care about.

Get Started Free