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. Agents: CLW
Terminal or Tool
A command line, Postman, or lnget (recommended)
No Account Profile
No account or subscription. We keep minimal payment, delivery, refund, and abuse-prevention records. Providers process inputs when required.
Want to try this without a terminal? Use Document Analysis on the web — pay with any Lightning wallet, no setup needed.
No-Account Document Analysis via L402
Analyze contracts, financial records, legal filings, medical documents, and any sensitive file — without creating an account. Document text is extracted on your machine and sent as context. Sats4AI does not save the submitted text or response after the request completes; the selected model provider processes the text under its own data policy.
This service uses the text-generation endpoint with the fileContext parameter. Pricing is dynamic based on document length. Best model (recommended for documents): 12 characters/Sat, minimum 1 Sat per request.
API Endpoint: https://sats4ai.com/api/l402/generate-text
Data handling: Extract text from your document locally (client-side or on your machine), then send only the extracted text as fileContext. The original file never leaves your device. No account-linked document history is created. Payment and limited operational records are retained separately, and the selected model provider processes the submitted text under its own data policy.
Step 0: Extract Text from Your Document
Extract the text content from your file before sending it. For PDFs, use a library like pdfplumber (Python) or pdf-parse (Node.js). For DOCX, use python-docx or mammoth. The extracted text is sent as the fileContext string.
import pdfplumber
with pdfplumber.open("contract.pdf") as pdf:
text = "\n".join(page.extract_text() for page in pdf.pages)
# Then send text as fileContext in the request bodyStep 1: Initial Request (get Invoice)
Send the request with your document text and question. You will receive a 402 Payment Required response with a Lightning invoice priced based on the total character count (prompt + document).
Request body:
{
"input": [
{
"role": "User",
"content": "Summarize the key obligations and risks in this contract"
}
],
"fileContext": "<extracted text of your document>",
"fileName": "contract.pdf"
}Example curl command:
curl -X POST https://sats4ai.com/api/l402/generate-text \
-H "Content-Type: application/json" \
-d '{"input":[{"role":"User","content":"Summarize the key obligations and risks in this contract"}],"fileContext":"<extracted text of your document>","fileName":"contract.pdf"}' \
-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 (Phoenix, Muun, Alby, Wallet of Satoshi, etc.). Save the preimage (proof of payment) your wallet provides after payment.
Step 3: Re-send with Payment Proof
Send the exact same request again with the Authorization header containing your macaroon and preimage.
The JSON payload must be identical to Step 1 — same document text, same question, same model.
curl -X POST https://sats4ai.com/api/l402/generate-text \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON>:<YOUR_PREIMAGE>" \
-d '{"input":[{"role":"User","content":"Summarize the key obligations and risks in this contract"}],"fileContext":"<extracted text of your document>","fileName":"contract.pdf"}'The response body will contain the AI's analysis of your document as plain text.
Easier: Use lnget
lnget handles the full 3-step flow automatically — invoice, payment, and re-request in one command.
lnget -X POST https://sats4ai.com/api/l402/generate-text \
--json '{"input":[{"role":"User","content":"What are the termination clauses?"}],"fileContext":"<document text>","fileName":"contract.pdf"}'Request Parameters
fileContext: string (required for document analysis)
The extracted text content of your document. Extract this on your machine before sending. Its length is included in the dynamic pricing calculation.
fileName: string (optional)
Original filename. Used as a label in the prompt (e.g., [File: contract.pdf]). Helps the model understand the document type.
input: array of objects
Your question or instruction as a conversation array. At minimum one object with role: "User" and your question as content.
modelId: number or string (optional)
Omit for the best default model (recommended for documents — 262K context window). Use "standard" for shorter documents at lower cost (1,214 characters/Sat). See available models.
Example Questions
- Contracts & NDAs: "List all termination clauses and the notice periods required."
- Financial records: "Identify any liabilities over $100K and summarize the cash flow trend."
- Legal filings: "What are the plaintiff's core claims and what damages are being sought?"
- Medical reports: "Summarize the diagnosis and recommended treatment plan."
- Board documents: "What decisions were made and what action items were assigned?"