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

Clone a Voice via L402

Clone a voice from an audio sample. Returns a voice_id that you can use with the Text-to-Speech endpoint to generate speech in that voice. Flat rate: 7,500 sats per clone.

Ideal for creating custom voices for agents, branded TTS, audiobook narration, or any scenario where you need a specific voice without ongoing subscription fees.

API Endpoint: https://sats4ai.com/api/l402/voice-clone

Constraints

  • Audio sample must be a publicly accessible URL or base64 data URI
  • Processing takes 1-5 minutes depending on model and audio length
  • Two quality tiers: speech-02-turbo (faster) and speech-02-hd (higher quality)
  • Accuracy range: 0.0 to 1.0 (default 0.7) — higher values produce closer voice matches but take longer

Step 1: Initial Request (get Invoice)

Send the request with your voice sample URL. You will receive a 402 Payment Required response with a Lightning invoice for 7,500 sats.

Request body:

{
  "voice_file": "https://example.com/my-voice-sample.mp3",
  "model": "speech-02-turbo",
  "accuracy": 0.7
}

Example curl command:

curl -X POST https://sats4ai.com/api/l402/voice-clone \
-H "Content-Type: application/json" \
-d '{"voice_file":"https://example.com/my-voice-sample.mp3","model":"speech-02-turbo","accuracy":0.7}' \
-i

Expected response headers:

www-authenticate: L402 macaroon="<YOUR_MACAROON>", invoice="<LIGHTNING_INVOICE>"

Step 2: Pay the Lightning Invoice

Pay the 7,500-sat invoice with any Lightning wallet (Phoenix, Muun, Alby, Wallet of Satoshi, etc.). Save the preimage your wallet provides after payment.

Step 3: Re-send with Payment Proof

Send the exact same request again with the Authorization header.

The JSON payload must be identical to Step 1.

curl -X POST https://sats4ai.com/api/l402/voice-clone \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON>:<YOUR_PREIMAGE>" \
-d '{"voice_file":"https://example.com/my-voice-sample.mp3","model":"speech-02-turbo","accuracy":0.7}'

Successful response: {"success": true, "voice_id": "abc123", "model": "speech-02-turbo", "message": "Voice cloned successfully! Use voice ID \"abc123\" with the TTS endpoint."}

Easier: Use lnget

lnget POST https://sats4ai.com/api/l402/voice-clone \
  --json '{"voice_file":"https://example.com/sample.mp3","model":"speech-02-turbo"}'

Python Example

import requests

# Step 1 — get invoice
r = requests.post("https://sats4ai.com/api/l402/voice-clone",
    json={"voice_file": "https://example.com/sample.mp3", "model": "speech-02-turbo", "accuracy": 0.7},
    headers={"Content-Type": "application/json"})
# r.status_code == 402
# Parse macaroon and invoice from r.headers["www-authenticate"]

# Step 2 — pay invoice with your Lightning wallet, get preimage

# Step 3 — re-send with auth
r2 = requests.post("https://sats4ai.com/api/l402/voice-clone",
    json={"voice_file": "https://example.com/sample.mp3", "model": "speech-02-turbo", "accuracy": 0.7},
    headers={
        "Content-Type": "application/json",
        "Authorization": "L402 <macaroon>:<preimage>"
    })
print(r2.json())
# {"success": true, "voice_id": "...", "message": "Voice cloned successfully!"}

Request Parameters

voice_file: string required

Public URL to an audio file containing the voice to clone, or a base64 data URI. Supported formats: MP3, WAV, M4A, FLAC.

model: string (optional)

Quality tier. "speech-02-turbo" (faster, default) or "speech-02-hd" (higher quality).

accuracy: number (optional)

Voice matching accuracy. Range: 0.0 to 1.0. Default: 0.7. Higher values produce closer matches but may take longer to process.

need_noise_reduction: boolean (optional)

Apply noise reduction to the voice sample before cloning. Default: false.

need_volume_normalization: boolean (optional)

Normalize volume levels in the voice sample. Default: false.

Use Cases

  • Create a custom branded voice for your agent or product
  • Clone your own voice to generate TTS audio that sounds like you
  • Audiobook narration with a consistent custom voice
  • Accessibility tools with a familiar, personalized voice
  • One-time voice cloning without monthly subscription fees