Skip to main content

L402 API Access

Use AI tools by paying with Bitcoin. No signup. No API keys.

Pay with Bitcoin. Get AI Results.

Access 30+ AI services using Lightning Network micropayments. No signup, no monthly subscription, no reusable API key. Just sats.

Not a developer? You can use all of these tools directly on the web — browse available tools and pay with any Lightning wallet, no setup needed.

New: full reference for L402, MCP, WebLN, async jobs, error codes, retry safety, auto-routing and CORS — see /docs.

No Signup

No registration email or password

💰

Pay Per Use

No subscriptions. Only pay when you use it

🔒

No Account Profile

No account-linked behavioral history

Bitcoin Native

Lightning payments settle in seconds

How It Works

1

Send Your Request

Call any API endpoint with your data. You'll get back a Lightning invoice to pay.

2

Pay with Lightning

Pay the invoice with any Lightning wallet. Takes seconds, costs pennies.

3

Get Your Result

Re-send the same request with your proof of payment. Done.

Building an autonomous agent? MCP handles payment negotiation inline — no header parsing or retry logic needed. See why MCP vs raw HTTP matters or go straight to the MCP docs.

Services & Pricing

All prices in Satoshis (1 Sat ~ $0.001 USD). Click any service for full instructions.

ServicePrice
Image Generation100-200 Sats/image
Text Generation12-1215 chars/Sat · 1 Sat minimum
Video Generation250-400 Sats/sec
Video from Image250-400 Sats/sec
Music Generation5 Sats/second
Text to Speech~5-106 chars/sat
Speech Transcription10 Sats/minute
Image Analysis21 Sats/image
3D Model Generation1600 Sats/model
File Conversion100 Sats/file
OCR / Text Extraction10 Sats/page
SMS Servicevaries by country
Automated Phone Callvaries by country & duration
AI Phone Callstarting at ~150 sats/min
Send Fax500 Sats (≤10 pages) +50/page
Receive Fax500 Sats (+200 OCR)
Email Sending200 Sats/email
Voice Cloning7,500 Sats
Image Editing200-450 Sats/edit
PDF Merge100 Sats
HTML to PDF50 Sats
Document Translation1,215 chars/Sat · 1 Sat minimum
Receipt OCR25 sats/page
Background Removal44 Sats/image
Image Upscaling5 Sats/image
Render Card5 Sats/card
Face Restoration25 Sats/image
NSFW Detection2 Sats/image
Object Detection5 Sats/image
Smart Object Removal130 Sats/image
Photo Colorization5 Sats/image
Image Deblurring110 Sats/image

Easiest Way: Use lnget

lnget is Lightning Labs' official CLI for L402 APIs — handles request, payment, and authentication in a single command. Install: go install github.com/lightninglabs/lnget/cmd/lnget@latest

Copy and paste any of these examples:

Generate an image:

lnget -X POST https://sats4ai.com/api/l402/generate-image \
  -d '{"prompt":"A cat on the moon"}'

Generate text:

lnget -X POST https://sats4ai.com/api/l402/generate-text \
  -d '{"input":[{"role":"user","content":"Explain Bitcoin"}]}'

Transcribe audio:

lnget -X POST https://sats4ai.com/api/l402/transcribe-audio \
  -d '{"file":"<base64-audio>","type":"transcription"}'

lnget auto-pays the Lightning invoice, caches the token, and returns the result. Our tokens are bound to one service and one quantity and expire in 10 minutes; when a cached token is rejected, lnget pays the fresh invoice on its own — one extra round-trip, never a failure.

Spend cap. lnget refuses any invoice above 1,000 sats by default (exactly 1,000 passes) and any routing fee above 10 sats. The refusal happens on your side after the 402, so we never see it. For a dearer service pass --max-cost <sats> (or lnget config set l402.max_cost_sats <sats>). Above the default today: clone-voice (7,500 sats), generate-3d-model (1,600 sats); and every metered service — audiobook, video, TTS, calls, fax — can exceed it depending on the input, so quote first with /api/estimate-cost and set the cap from the quote.

L402 tokens expire after 10 minutes — pay the invoice and submit your request within that window. Media URLs (images, video, audio) expire after 2 hours. Download or display them promptly.

Building autonomous agents? CLW is a Bitcoin wallet built for AI agents — lets them receive, hold, and spend sats programmatically.

Auto-Paying L402 Libraries

These open-source libraries handle L402 payment automatically — your code makes a normal HTTP request, the library detects the 402 challenge, pays the invoice, and retries with proof. No payment logic needed.

TS
npm install l402-requests

l402-requests — three lines of TypeScript. Supports Strike, LND, NWC (Alby Hub, CoinOS), with built-in budget controls and spending logs.

PY
pip install l402-requests

l402-requests — same auto-paying flow for Python.

.NET
dotnet add package l402-dotnet

l402-dotnet — same auto-paying flow for .NET.

import { get } from 'l402-requests';

// That's it. The library pays the Lightning invoice automatically.
const response = await get("https://sats4ai.com/api/l402/generate-text", {
  method: "POST",
  body: JSON.stringify({ input: [{ role: "user", content: "Explain Bitcoin" }] })
});

Manual Flow (Step by Step)

If you prefer to handle payments yourself (or want to understand how L402 works under the hood):

1

Send your request to the API endpoint

You'll get a 402 Payment Required response with a Lightning invoice and a macaroon (access token).

2

Pay the Lightning invoice

Use any Lightning wallet (Phoenix, Muun, Wallet of Satoshi, Alby, etc.). For autonomous AI agents, see CLW. Save the preimage (proof of payment) your wallet gives you.

3

Re-send the exact same request with your payment proof

Add this header: Authorization: L402 <macaroon>:<preimage>

Click any service below for the exact copy-paste commands.

Refunds & Error Handling

All services use prepaid invoices — payment settles instantly before the AI task runs. If the task fails after payment, you get an automatic refund via LNURL-withdraw.

!

What happens on failure

If the AI provider returns an error after you've paid, the response includes a refund object with an lnurl_withdraw field — a bech32-encoded LNURL-withdraw URL you can use to pull your sats back.

A

For agents

Check response.error_code to decide how to recover, then parse response.refund.lnurl_withdraw to claim the refund programmatically with any LNURL-compatible wallet or library.

Error codes

TIMEOUT — retry later or try a different model

CONTENT_FILTERED — rephrase prompt (safety filter triggered)

RATE_LIMITED — wait and retry

INVALID_INPUT — fix parameters

SERVICE_ERROR — try different model or contact support

Full machine-readable catalog: GET /api/error-codes

H

For humans

On the web dashboard, the LNURL-withdraw link is displayed as a QR code you can scan with any Lightning wallet.

Rate limiting

The first 2 failures per 15-minute window receive a full refund. After that, a 2 sat routing fee is deducted from each refund to discourage abuse. This resets every 15 minutes.

// Example error response with refund
{
  "error": "Image generation timed out",
  "error_code": "TIMEOUT",
  "refund": {
    "charge_id": 12345,
    "refund_amount": 200,
    "lnurl_withdraw": "lnurl1dp68gurn8ghj7...",
    "status": "pending"
  }
}

What is L402?

L402 is a standard that lets you pay for API access with Bitcoin instead of creating an account and reusable API key. It combines:

  • Lightning Network — instant Bitcoin payments (fractions of a penny)
  • Macaroons — tamper-proof access tokens (like a receipt)

The result: pay-per-use AI with no customer account. No signup, reusable API key, credit card, or monthly bill. We keep minimal payment, delivery, refund, and abuse-prevention records, not an account-linked activity history.

Learn more about the L402 protocol

For Developers: All endpoints and pricing are available as machine-readable JSON at /.well-known/l402-services, /api/l402/models, /api/models/routing, and /api/discover (keyword tool search, relevance-ranked). View L402 code examples (Python, Node.js, curl) or the MCP server repo on GitHub. Found a bug? Report it on GitHub or join the discussions.

Get Started

Pick a service to see full instructions with copy-paste examples.

Image Generation

Create images from text prompts

100-200 Sats/imageView docs →

Text Generation

AI chat and text completion

12-1215 chars/Sat · 1 Sat minimumView docs →

Video Generation

Generate videos from text

250-400 Sats/secView docs →

Video from Image

Animate images into video

250-400 Sats/secView docs →

Music Generation

A full song with AI vocals, or an instrumental. You pick the length.

5 Sats/secondView docs →

Text to Speech

3 tiers: OmniVoice Global (602+ langs), Inworld Max Premium (#1 ELO), Minimax Studio (voice cloning)

~5-106 chars/satView docs →

Speech Transcription

Transcribe audio to text

10 Sats/minuteView docs →

Image Analysis

Ask AI about any image

21 Sats/imageView docs →

3D Model Generation

Turn photos into 3D models

1600 Sats/modelView docs →

File Conversion

Convert between file formats

100 Sats/fileView docs →

OCR / Text Extraction

Extract text from PDFs and images

10 Sats/pageView docs →

SMS Service

Send text messages globally

varies by countryView docs →

Automated Phone Call

Place calls with TTS or audio playback. Pricing scales with duration and destination.

varies by country & durationView docs →

AI Phone Call

Send an AI voice agent to make a two-way phone call with transcript and analysis

starting at ~150 sats/minView docs →

Send Fax

Send a fax worldwide — PDF (from URL) or typed text. No fax machine required

500 Sats (≤10 pages) +50/pageView docs →

Receive Fax

Open a 24h window to receive a fax at our shared number, delivered to your email. Optional OCR

500 Sats (+200 OCR)View docs →

Email Sending

Send a one-off email to any address — no account, no domain setup, no monthly fee

200 Sats/emailView docs →

Voice Cloning

Clone a voice from an audio sample for use with TTS

7,500 SatsView docs →

Image Editing

Edit images with AI — background removal, style transfer, object removal

200-450 Sats/editView docs →

PDF Merge

Merge multiple PDFs into a single document

100 SatsView docs →

HTML to PDF

Convert HTML or Markdown to PDF documents

50 SatsView docs →

Document Translation

Translate text across 119 languages with ultra-fast AI

1,215 chars/Sat · 1 Sat minimumView docs →

Receipt OCR

Extract structured data from receipts and invoices

25 sats/pageView docs →

Background Removal

Remove background from any image, get transparent PNG

44 Sats/imageView docs →

Image Upscaling

Upscale images 2x or 4x with neural super-resolution

5 Sats/imageView docs →

Render Card

Typographic title cards as PNG or JPEG — the text you send is the text that appears, which no image model can promise

5 Sats/cardView docs →

Face Restoration

Restore blurry or damaged faces to sharp, natural quality

25 Sats/imageView docs →

NSFW Detection

Classify image safety (normal/suggestive/explicit). Falcons.ai — 100x cheaper than an LLM

2 Sats/imageView docs →

Object Detection

Detect and locate objects by name with bounding boxes. Grounding DINO (ECCV 2024)

5 Sats/imageView docs →

Smart Object Removal

Remove objects by describing what to remove — no mask needed. Grounding DINO + Bria Eraser

130 Sats/imageView docs →

Photo Colorization

Colorize black-and-white or grayscale photos with vivid, natural color. DDColor (ICCV 2023)

5 Sats/imageView docs →

Image Deblurring

Fix blurry or out-of-focus photos. NAFNet (ECCV 2022, SOTA). Real pixel reconstruction

110 Sats/imageView docs →