L402 API
Pay with Bitcoin, get AI results. Copy-paste the commands below.
Choose a service:
Before You Start
Want to try this without a terminal? Use File Conversion on the web — pay with any Lightning wallet, no setup needed.
Using the L402 File Conversion API
Convert files between formats (e.g. DOCX to PDF, PNG to WEBP). Powered by CloudConvert.
API Endpoint: https://sats4ai.com/api/l402/convert-file
Step 1: Initial Request
Send the file (base64-encoded) with source and target formats. You will receive a 402 Payment Required response.
curl -X POST https://sats4ai.com/api/l402/convert-file \
-H "Content-Type: application/json" \
-d '{
"file": "<base64-encoded-file-data>",
"file_name": "document.docx",
"extensionFrom": "docx",
"extensionTo": "pdf"
}' \
-iExpected Response Headers:
www-authenticate: L402 macaroon="<YOUR_MACAROON>", invoice="<LIGHTNING_INVOICE>"Step 2: Pay the Lightning Invoice
Pay the invoice and save the preimage.
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/convert-file \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{
"file": "<base64-encoded-file-data>",
"file_name": "document.docx",
"extensionFrom": "docx",
"extensionTo": "pdf"
}'Expected Successful Response:
{ "url": "https://..." }The returned URL is a temporary download link for the converted file.
Request Body Parameters
file: string (required)
Base64-encoded file data. Can include a data URI prefix (it will be stripped automatically).
file_name: string (required)
Original file name (e.g. "document.docx").
extensionFrom: string (required)
Source file format (e.g. "docx", "png", "mp4").
extensionTo: string (required)
Target file format (e.g. "pdf", "webp", "mp3").