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 data collection. 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, dedup, auto-routing and CORS — see /docs.

No Signup

No accounts, no emails, no passwords

💰

Pay Per Use

No subscriptions. Only pay when you use it

🔒

Private

No personal data collected. Ever

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 Generation5-15 Sats minimum
Video Generation300-550 Sats/sec
Video from Image100 Sats/sec
Music Generation300 Sats/song
Text to Speech10-100 chars/sat
Speech Transcription10 Sats/minute
Image Analysis21 Sats/image
3D Model Generation350 Sats/model
File Conversion100 Sats/file
OCR / Text Extraction10 Sats/page
SMS Servicevaries by country
Automated Phone Callvaries by country & duration
AI Phone Call~150-250 Sats/call
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 TranslationFrom 4 Sats
Receipt OCR50 Sats/page
Background Removal5 Sats/image
Image Upscaling5 Sats/image
Face Restoration5 Sats/image
NSFW Detection2 Sats/image
Object Detection5 Sats/image
Smart Object Removal15 Sats/image
Photo Colorization5 Sats/image
Image Deblurring20 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. Subsequent calls to the same endpoint reuse the cached token.

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

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 signing up for accounts and handing over personal data. 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 full privacy. No accounts, no API keys, no credit cards, no monthly bills. You only pay for what you use, and we never know who you are.

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 (semantic tool search). 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

5-15 Sats minimumView docs →

Video Generation

Generate videos from text

300-550 Sats/secView docs →

Video from Image

Animate images into video

100 Sats/secView docs →

Music Generation

Full songs with AI vocals, BPM/key control

300 Sats/songView docs →

Text to Speech

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

10-100 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

350 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

~150-250 Sats/callView 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

From 4 SatsView docs →

Receipt OCR

Extract structured data from receipts and invoices

50 Sats/pageView docs →

Background Removal

Remove background from any image, get transparent PNG

5 Sats/imageView docs →

Image Upscaling

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

5 Sats/imageView docs →

Face Restoration

Restore blurry or damaged faces to sharp, natural quality

5 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

15 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

20 Sats/imageView docs →