pull down to refresh

Most AI APIs still have the same two failure modes:

  1. You gate everything behind auth/paywall, so nobody tries it.
  2. You give a big free tier, so you get usage but no revenue, and you're afraid to raise prices.

L402 is the first HTTP-native pattern I've used that makes small Lightning payments feel ergonomic. The server just replies with HTTP 402 Payment Required, includes a BOLT11 invoice, and tells the client how to retry.

What the flow looks like (concrete)What the flow looks like (concrete)

  • Step 1: allow 1 free call per IP per 24h (so the happy path is dead simple)
  • Step 2: after that, return 402 plus a Lightning invoice and a payment_hash (or retry header)
  • Step 3: client pays the invoice, then retries the exact same request including the payment_hash

This is normal control flow, like handling 429 with Retry-After.

Example endpoint you can hit right nowExample endpoint you can hit right now

  • POST https://maximumsats.com/api/dvm
    • First query free per IP per 24 hours
    • Then 21 sats per call via L402

Curl demoCurl demo

# 1) First call: free (or you'll get a 402 if you've already used it today)
curl -sS https://maximumsats.com/api/dvm \
  -H 'content-type: application/json' \
  -d '{"prompt":"Give me 5 concrete ways to price an LLM feature without subscriptions."}'

# 2) If you got a 402, pay the invoice shown in the JSON.
# Then retry the same request including the payment_hash exactly as instructed by the response.

Why this matters for AI specificallyWhy this matters for AI specifically

  • Lots of AI features have tiny marginal costs you can pass through: 5 sats, 21 sats, 100 sats. Subscriptions feel like a mismatch.
  • A 1-call free tier is a clean filter for bots and never-pay traffic, without killing try-before-you-buy.
  • The retry semantics are easy to automate in clients (no web checkout flows).

What I'd like to see nextWhat I'd like to see next

  • SDKs that treat 402 + invoice as a first-class pattern.
  • More APIs publishing machine-readable pricing (free tier + costs). For example:
    • https://wot.klabo.world/pricing

Implementation detail: I return a JSON body on 402 with (a) the BOLT11 invoice, (b) a payment_hash, and (c) explicit retry instructions. Clients can treat it like 429: if 402, pay invoice, then retry the same request including payment_hash (or the provided header) and the server releases the result.

reply