L402 API
Pay with Bitcoin, get AI results. Copy-paste the commands below.
Choose a service:
Before You Start
Lightning Wallet
Phoenix, Muun, Wallet of Satoshi, Alby, or any LN wallet
Terminal or Tool
A command line, Postman, or lnget (recommended)
Private & No Signup
No account, no subscription, no personal data. Pay only when you use it
Using the L402 OCR API
Extract text from PDFs, images, and scanned documents. Returns clean Markdown with tables, headers, and formatting preserved.
Price: 10 Sats per page · Supported formats: PDF, PNG, JPEG, TIFF, WebP, BMP
API Endpoint: https://sats4ai.com/api/l402/ocr
Quickest: Use lnget
One command — payment is handled automatically.
# Extract text from a PDF (easiest method)
DOC=$(base64 -w0 invoice.pdf)
lnget -X POST https://sats4ai.com/api/l402/ocr \
-H "Content-Type: application/json" \
-d "{\"document\": \"data:application/pdf;base64,$DOC\", \"model\": \"Mistral OCR\"}"Step 1: Initial Request
Send the document as a base64 data URI. You will receive a 402 Payment Required response.
curl -X POST https://sats4ai.com/api/l402/ocr \
-H "Content-Type: application/json" \
-d '{
"document": "data:application/pdf;base64,JVBERi0xLjQg...",
"model": "Mistral OCR"
}' \
-iExpected Response Headers:
www-authenticate: L402 macaroon="<YOUR_MACAROON>", invoice="<LIGHTNING_INVOICE>"Step 2: Pay the Lightning Invoice
Pay the invoice with any Lightning wallet and save the preimage (proof of payment).
Step 3: Final Request
Send the exact same request with the Authorization header.
Important: The JSON payload must be identical to Step 1.
curl -X POST https://sats4ai.com/api/l402/ocr \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{
"document": "data:application/pdf;base64,JVBERi0xLjQg...",
"model": "Mistral OCR"
}'Expected Successful Response:
{
"content": "# Invoice\n\n| Item | Price |\n|------|-------|\n| Widget | $9.99 |\n\nThank you for your purchase.",
"pages": 1
}Request Body Parameters
document: string (required)
Base64-encoded document as a data URI. Use data:application/pdf;base64,... for PDFs or data:image/png;base64,... for images. If no prefix is provided, PDF is assumed.
model: string (required)
Accepted Values: "Mistral OCR"
Response Format
content: Extracted text in Markdown format. Tables are rendered as Markdown tables, headers preserved, page breaks marked with ---.
pages: Number of pages processed.