Skip to main content

L402 API

Pay with Bitcoin, get AI results. Copy-paste the commands below.

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 Text-to-Speech API

Convert text to natural-sounding speech audio. Returns a URL to the generated audio file (MP3).

Pricing: 300 Sats per generation. Text length: 1-5,000 characters.

API Endpoint: https://sats4ai.com/api/l402/tts

Step 1: Initial Request

Send your text and voice preferences. You will receive a 402 Payment Required response.

curl -X POST https://sats4ai.com/api/l402/tts \
-H "Content-Type: application/json" \
-d '{
  "text": "Hello, this is a test of the text to speech service.",
  "voice": "English_American_Female1",
  "speed": 1.0
}' \
-i

Expected 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/tts \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{
  "text": "Hello, this is a test of the text to speech service.",
  "voice": "English_American_Female1",
  "speed": 1.0
}'

Expected Successful Response:

{ "audioUrl": "https://..." }

The returned URL is a temporary link to the generated audio file. Download it promptly — media URLs expire after 2 hours.

Request Body Parameters

text: string (required)

The text to convert to speech. 1-5,000 characters.

voice: string (optional)

Voice preset to use. Examples: "English_American_Female1", "English_British_Male1". Default: "English_American_Female1".

speed: number (optional)

Speech speed multiplier. Range: 0.5 to 2.0. Default: 1.0.

modelId: number or string (optional)

Omit for the best default model. See available models.