Skip to content

Account & billing

402 payments

Pay for individual API requests with the HTTP 402 payment protocol, without an account or API key. PPQ currently supports L402 (Bitcoin Lightning).

How it works

  1. Send a request to any 402-enabled endpoint without an Authorization header.
  2. The server returns 402 Payment Required with a WWW-Authenticate: Payment header containing a challenge and a Lightning invoice.
  3. Pay the Lightning invoice with any Lightning wallet.
  4. Replay the original request with Authorization: Payment <credential>. The credential is the base64url-encoded JSON {"challenge": <parsed challenge>, "payload": {"preimage": "<hex preimage>"}}. The server checks the preimage against the invoice in the challenge and returns the data.

Each paid credential works once. Replay it before the signed challenge expires, 5 minutes after issue. The Lightning invoice stays payable for 10 minutes, but paying late does not extend the challenge.

402-compatible clients such as lnget and mppx automate this challenge-pay-replay loop.

Supported endpoints

CategoryEndpointMethodPricingMax per requestDefault model
Data enrichment
/v1/data/api/*
GET / POST
Fixed per endpoint (see Data enrichment)
$0.322. GET /v1/data/endpoints lists each final price.
—
Data enrichment (X/Twitter)
/v1/data/x/*
GET
Fixed per endpoint (see Data enrichment)
$0.0115
—
Image generation
/v1/images/generations
POST
Dynamic: varies by model, size and quality (see Image generation)
$0.35 × n
gpt-image-1
Image editing (OpenAI-spec)
/v1/images/edits
POST
Same as Image generation. Compatibility endpoint for OpenAI-spec clients.
$0.35 × n
gpt-image-1
Video generation
/v1/videos
POST
Dynamic: varies by model, duration and resolution (see Video generation)
$16.32
kling-2.5-turbo

Budgeting before the challenge

Every image and video model on GET /v1/models?type=image,video carries pricing.min_price and pricing.max_price: the cheapest and most expensive single generation it can be quoted at, across every quality and size. n multiplies the quote.

Prices are in USD. The invoice is in satoshis, at the BTC/USD rate the challenge carries (btc_usd_rate in its opaque data). Before you use max_price as a client-side cap such as lnget --max-cost (which takes whole sats), convert it to sats at the current rate.

max_price bounds the USD quote. The invoice amount is that quote converted at btc_usd_rate and rounded up to the next whole satoshi, so on cheap models the sats can exceed max_price × rate by up to one satoshi. Allow for it.

The route ceilings in the table are the highest max_price in the catalog as of November 2026, and move as models are added.

Pick the route from a model's category, not from its type:

  • text-to-image and image-to-image → /v1/images/*
  • text-to-video and image-to-video → /v1/videos

Image-to-video models are listed under type=image, but are priced and served as video.

Choosing a model

A request that names no model is quoted for the route's default model and, once paid, generated with it. The 402 body says so.

A paid credential is bound to the model and price it was quoted for, so a replay with a different model gets a fresh 402.

Examples

Data enrichment (curl)

# 1. Request without auth — get a 402 challenge with a Lightning invoice
curl -i -X POST https://api.ppq.ai/v1/data/api/fullenrich/people-search \
  -H "Content-Type: application/json" \
  -d '{"limit": 5, "current_company_domains": [{"value": "stripe.com"}]}'

# Response: 402 Payment Required
# WWW-Authenticate: Payment id="...", method="lightning", ...

# 2. Pay the invoice, then replay with the payment credential:
#    base64url( {"challenge": <parsed WWW-Authenticate challenge>, "payload": {"preimage": "<hex preimage>"}} )
#    (challenge = id, realm, method, intent, description, expires, request as-is, opaque = JSON-decoded opaque;
#     mppx's Challenge.fromResponse + Credential.serialize build this for you)
curl -X POST https://api.ppq.ai/v1/data/api/fullenrich/people-search \
  -H "Content-Type: application/json" \
  -H "Authorization: Payment <credential>" \
  -d '{"limit": 5, "current_company_domains": [{"value": "stripe.com"}]}'

Image generation (lnget)

# lnget handles the 402 challenge and Lightning payment automatically
lnget -X POST \
  -d '{"model": "gpt-image-1", "prompt": "a sunset over mountains", "size": "1024x1024"}' \
  --content-type application/json \
  --max-cost 500 \
  https://api.ppq.ai/v1/images/generations

Video generation (lnget)

# Submit a video generation job — returns 202 with a signed status URL
lnget -X POST \
  -d '{"model": "kling-2.5-turbo", "prompt": "ocean waves at sunset", "duration": "5", "aspect_ratio": "16:9"}' \
  --content-type application/json \
  --max-cost 500 \
  https://api.ppq.ai/v1/videos

# Poll the status URL from the response (no auth needed — URL is signed)
lnget "<status_url>"

# Video generation returns:
# { "id": "gen_...", "status": "pending", "status_url": "https://..." }

Notes

  • Video generation: the response includes a status_url, a signed URL you can poll without authentication to check progress and retrieve the final video.
  • Image generation: the response includes signed media URLs that work without authentication. Generation is synchronous and some models take over a minute (e.g. kling-v3-image, typically 25–60 s). It keeps running if your client disconnects.
  • Collecting an image after a disconnect: re-send the same request with the same Authorization: Payment credential. 200 returns the image, 202 (with Retry-After) means it is still generating, and 502 means it failed. This never bills a second generation and works after the challenge expires.
  • Signed URLs expire after 24 hours.
  • If you have a PPQ API key, you can still send it as Authorization: Bearer sk-.... The 402 flow only starts when the request has no API key.
  • The challenge is issued before the request body is validated, and a paid credential is consumed when it is accepted. Check your own request (prompt, image, parameters) before paying: a replay that the generation endpoint then rejects with 400 is not refunded.