Accept AI Agent Payments via Stripe

RelAI Team
Feb 15, 2026 · 3 min read
Accept AI Agent Payments via Stripe

Stripe just opened crypto payins for machine payments. AI agents can now pay for your API in USDC on Base, and the money lands in your Stripe Dashboard as USD - same place as your credit card revenue.

We built stripePayTo() into the RelAI SDK so you can set this up in 3 lines.

The Problem

If you're an API provider accepting x402 payments today, you receive USDC directly to your wallet. That works - but it means you need to:

  • Manage a crypto wallet with private keys
  • Off-ramp USDC to your bank account manually
  • Track revenue across two systems (Stripe for cards, wallet for crypto)
  • Handle taxes and reporting for crypto income separately
Most API businesses already use Stripe. Adding a second revenue channel with different tooling is friction.

The Fix

stripePayTo() eliminates all of that. Payments flow through x402 as usual, but instead of landing in your wallet, they land in Stripe:
import Relai, { stripePayTo } from '@relai-fi/x402/server';

const relai = new Relai({ network: 'base' });

app.get('/api/data', relai.protect({
price: 0.01,
payTo: stripePayTo(process.env.STRIPE_SECRET_KEY),
}), (req, res) => {
res.json({ data: 'premium content' });
});

That's it. No wallet, no private keys, no off-ramping.

How It Works Under the Hood

Each time an agent hits your API without a payment header:

  1. 402 response - the SDK creates a Stripe PaymentIntent with payment_method_types: ["crypto"]
  2. Deposit address - Stripe returns a fresh USDC deposit address on Base via next_action.crypto_collect_deposit_details
  3. Client pays - the agent's x402 client signs and settles USDC to that address
  4. Auto-capture - Stripe detects the on-chain payment, captures the PI, and credits your balance in USD
From the agent's perspective, nothing changes. It sees a standard x402 402 response with a payTo address and pays normally. The agent doesn't know (or care) that Stripe is on the other end.

What You Get

  • Unified revenue - crypto and card payments in one Stripe Dashboard
  • USD settlement - no crypto exposure, no volatility risk
  • Built-in reporting - sales tax, refunds, and invoicing through Stripe
  • No wallet management - Stripe handles the deposit address
  • Base network - low fees, fast settlement (auto-configured)

Compared to Raw Stripe x402

Stripe's own x402 docs require ~45 lines and 6 imports to set up. You need to manually create PaymentIntents, extract deposit addresses, handle the payment lifecycle, and wire up a facilitator client.

With RelAI:

Stripe docs@relai-fi/x402
Lines of code~453
Imports6 packages1 package
Facilitator setupManualAuto-configured
Network configManualAuto (Base)
Deposit addressYou extract itSDK handles it

Requirements

  1. Stripe account with crypto payins enabled
  2. STRIPE_SECRET_KEY in your environment variables
  3. @relai-fi/x402 v0.5.0+ installed
npm install @relai-fi/x402@latest

Dynamic Pricing + Stripe

Works with dynamic pricing too - the SDK creates a correctly-sized PaymentIntent per request:

app.get('/api/generate', relai.protect({
  price: (req) => {
    const tokens = parseInt(req.query.tokens) || 100;
    return tokens * 0.0001; // $0.0001 per token
  },
  payTo: stripePayTo(process.env.STRIPE_SECRET_KEY),
}), handler);

Each request gets a PaymentIntent matching the exact price. No over-charging, no rounding issues.

For Agent Developers

Nothing changes on your side. If you're already using the RelAI client SDK or any x402-compatible client, payments to Stripe-backed APIs work identically. You pay USDC to a Base address - whether that address belongs to a merchant wallet or Stripe is transparent to you.

Get Started

  1. Install the SDK: npm install @relai-fi/x402@latest
  2. Add stripePayTo(process.env.STRIPE_SECRET_KEY) as your payTo
  3. Deploy and start earning
Full API reference in the SDK documentation.

Need protocol context first? Read the x402 overview and the RelAI documentation hub.


RelAI connects AI agents to paid APIs through the x402 protocol. With stripePayTo(), API providers can accept machine payments directly into Stripe - no crypto knowledge required.

Understand x402 before you implement

This guide uses payment primitives from the x402 standard. Read the protocol overview for a complete flow, terminology, and integration FAQ.