AIProx documentation

Overview

AIProx's main paid endpoint is POST https://aiprox.dev/api/orchestrate; four single-capability endpoints sell one capability each at its own price. You send a task in plain English. AIProx splits it into at most 4 steps, runs each step on one of its own bots, in order, passing each step's output to the next, and returns one summarized answer with a per-step report and a receipt ID.

Quickstart

With a spend token

A spend token is a LightningProx balance (lnpx_...). Buy one at lightningprox.com/topup or get a free trial token (400 sats, 7 days). Each call takes 50 sats from it; the same balance also works on lightningprox.com.

curl https://aiprox.dev/api/orchestrate \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"task": "Get the latest bitcoin news and summarize it"}'

With L402 (pay per call)

No account and no token: send the request without a credential, pay the 50-sat invoice you get back, then send the same request with the credential.

# 1. No credential: HTTP 402 with a macaroon and a 50-sat Lightning invoice
curl -si https://aiprox.dev/api/orchestrate \
  -H "Content-Type: application/json" \
  -d '{"task": "Get the latest bitcoin news and summarize it"}'

# 2. Pay the invoice with any Lightning wallet and copy the payment preimage (64 hex characters).

# 3. Send the request again with the credential
curl https://aiprox.dev/api/orchestrate \
  -H "Content-Type: application/json" \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -d '{"task": "Get the latest bitcoin news and summarize it"}'

The 402 response (long values shortened):

HTTP/1.1 402 Payment Required
WWW-Authenticate: L402 macaroon="eyJhbW91bnRfc2F0cyI6NTAs...", invoice="lnbc500n1p..."

{
  "amount_sats": 50,
  "charge_id": "...",
  "docs": "https://aiprox.dev/docs.html",
  "error": "Authentication required",
  "hint": "Pay the Lightning invoice, then retry with: Authorization: L402 <macaroon>:<preimage>",
  "invoice": "lnbc500n1p...",
  "macaroon": "eyJhbW91bnRfc2F0cyI6NTAs...",
  "trial_hint": "Get a free trial token at aiprox.dev/start",
  "trial_url": "https://aiprox.dev/start"
}

Single-capability endpoints

Buy one capability without orchestration: no planning step and no summary step, one bot (or AIProx itself) does the work. Each endpoint has its own price and is paid like /api/orchestrate: an L402 invoice for that price, or a spend-token debit of that price (X-Spend-Token header or "spend_token" in the body). A failure after payment is refunded the same way. A request with a missing or invalid field gets a 400 before any invoice, so nothing is paid for a malformed request; a valid unpaid request gets the 402. An empty body or {} without a credential is treated as a discovery probe and gets the 402.

EndpointPriceBodyResult
POST /v1/search35 sats{"query": "...", "max_results": 8} (query up to 500 characters; max_results 1–20, default 8)an AI answer: summary, key_findings and up to 5 source URLs
POST /v1/extract20 sats{"url": "https://..."}title and clean main text of an HTML or plain-text page (up to 50,000 characters)
POST /v1/summarize40 sats{"text": "..."} (up to 20,000 characters) or {"url": "https://..."} (web page or PDF, up to 10 MB)summary, key_points
POST /v1/translate40 sats{"text": "...", "target_language": "Spanish"} (text up to 6,000 characters)translated_text, source_language

Every success has the same shape: {"status": "ok", "result": {...}, "price_sats": N, "receipt_id": "...", "duration_ms": N}. A failure after payment is {"status": "error", "error": "...", "message": "...", "receipt_id": "...", "price_sats": N, "refund": {...}} with HTTP 415, 422, 502, 503 or 504. Each call has 60 seconds.

URLs must be http:// or https:// and resolve to a public address: private, loopback and link-local addresses are refused with 400 url_not_allowed before payment. AIProx fetches the URL itself and does not follow redirects: a redirecting URL fails with 422 url_redirects (and redirect_location), refunded; send the final URL.

POST /v1/search — AIProx AI Web Answer

An AI answer to a query, built from a live web search: a summary, key findings and up to 5 source URLs. Raw search results (titles, snippets) are not returned; see the terms for how the content may be used.

# L402: the first call returns 402 with a 35-sat invoice; pay it, then:
curl https://aiprox.dev/v1/search \
  -H "Content-Type: application/json" \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -d '{"query": "bitcoin lightning network adoption", "max_results": 3}'

# Spend token
curl https://aiprox.dev/v1/search \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"query": "bitcoin lightning network adoption", "max_results": 3}'
{
  "status": "ok",
  "result": {
    "query": "bitcoin lightning network adoption",
    "summary": "The sources describe the Lightning Network as Bitcoin's layer-2 payment network, used for small, fast payments...",
    "key_findings": ["...", "..."],
    "sources": ["https://lightning.network/", "https://..."]
  },
  "price_sats": 35,
  "receipt_id": "orch_1793446800123_3f9a1c2b7d4e",
  "duration_ms": 6210
}

POST /v1/extract

The title and readable main text of a page: scripts, navigation, headers, footers, forms and hidden elements are removed. No model is involved. HTML and plain text only (415 for anything else; use /v1/summarize for a PDF). Pages that need JavaScript to render may have little text (422 no_text_found, refunded).

curl https://aiprox.dev/v1/extract \
  -H "Content-Type: application/json" \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -d '{"url": "https://example.com/"}'

curl https://aiprox.dev/v1/extract \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"url": "https://example.com/"}'
{
  "status": "ok",
  "result": {
    "url": "https://example.com/",
    "title": "Example Domain",
    "text": "This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.",
    "length": 156,
    "truncated": false,
    "content_type": "text/html"
  },
  "price_sats": 20,
  "receipt_id": "orch_1793446800456_8b2e0d91c4a7",
  "duration_ms": 180
}

POST /v1/summarize

A summary and key points of pasted text, a web page or a PDF. Send text or url, not both.

curl https://aiprox.dev/v1/summarize \
  -H "Content-Type: application/json" \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -d '{"url": "https://bitcoin.org/bitcoin.pdf"}'

curl https://aiprox.dev/v1/summarize \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"text": "Paste up to 20,000 characters here..."}'
{
  "status": "ok",
  "result": {
    "summary": "The paper proposes a peer-to-peer electronic cash system that prevents double-spending without a trusted third party...",
    "key_points": ["...", "...", "..."],
    "source_type": "pdf",
    "source_url": "https://bitcoin.org/bitcoin.pdf"
  },
  "price_sats": 40,
  "receipt_id": "orch_1793446800789_c0ffee112233",
  "duration_ms": 14820
}

POST /v1/translate

Translation with source-language detection. target_language is a language name or code ("Spanish", "pt-BR").

curl https://aiprox.dev/v1/translate \
  -H "Content-Type: application/json" \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -d '{"text": "Payments settle in seconds.", "target_language": "Spanish"}'

curl https://aiprox.dev/v1/translate \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"text": "Payments settle in seconds.", "target_language": "Spanish"}'
{
  "status": "ok",
  "result": {
    "translated_text": "Los pagos se liquidan en segundos.",
    "source_language": "English",
    "target_language": "Spanish"
  },
  "price_sats": 40,
  "receipt_id": "orch_1793446801012_5a6b7c8d9e0f",
  "duration_ms": 2940
}

A failure after payment, with the refund:

HTTP/1.1 422 Unprocessable Entity

{
  "status": "error",
  "error": "url_redirects",
  "message": "The URL redirects; redirects are not followed. Send the final URL instead.",
  "redirect_location": "https://www.example.org/",
  "price_sats": 20,
  "receipt_id": "orch_1793446801345_0a1b2c3d4e5f",
  "refund": {"status": "credential_restored", "rail": "l402", "sats": 20, "charge_id": "...",
             "hint": "Your L402 credential was restored: retry with the same Authorization header"}
}

An L402 credential pays for its own invoice's amount: a credential paid for a cheaper endpoint, sent to a dearer one, gets a fresh 402 with "code": "credential_amount_too_low" and is not used.

Payment

Lightning is the only payment method. Every orchestrate call costs a flat 50 sats; the single-capability endpoints have their own prices and are paid the same way.

MethodHowWhen you are charged
Spend tokenX-Spend-Token: lnpx_... header, or "spend_token" in the body (the body wins if both are sent)50 sats are taken from the token before the task runs. If the token is unknown, expired or below 50 sats, nothing runs (401 or 402).
L402Authorization: L402 <macaroon>:<preimage>The paid invoice is the charge. Each credential pays for one call; sending it again gets a new 402 with "code": "credential_spent_rechallenged".

Requests that carry any other payment field (a wallet address or a wallet session) or a non-Lightning rail are refused with 400 unsupported_payment_method. Requests that cannot run (an unknown agent, a capability with no bot, a step list naming a bot AIProx does not run) are refused before anything is charged.

Request

POST https://aiprox.dev/api/orchestrate with Content-Type: application/json.

FieldTypeDescription
taskstringWhat you want done. Required. If absent, the last "role": "user" message of a messages array is used, or else a prompt string.
capabilitystringRun the task as one step on the best bot for this capability (see GET /api/capabilities).
agentstringRun the task as one step on this bot, by name.
modelstringPassed to bots that let you choose a model.
image_urlstringAn image for a vision step.
callback_urlstringWith capability or agent: run in the background and POST the result here (see Async jobs). Must be http(s) and must not resolve to a private address.
dry_runbooleanShow what would run, without charging or running (see Dry run).
spend_tokenstringSpend token, instead of the X-Spend-Token header.

Modes

ModeHow to ask for itWhat runs
Multi-step (default)Only taskA model plans at most 4 steps, one capability each; each step runs on the best bot for its capability. If the plan has more than 4 steps, the first 3 and the last are kept.
Single capabilitycapabilityOne step on the best bot for that capability.
Named botagentOne step on that bot.
Step listA task written as Step 1: use search-bot to ... Step 2: use sentiment-bot to ...The named bots, in that order, at most 4. No planning model is used.

Response

Multi-step and step-list calls

Example (from a test run with stub bots; real durations are longer):

{
  "agents_used": ["search-bot", "lightningprox"],
  "duration_ms": 30,
  "powered_by": "aiprox-orchestrator v2",
  "price_sats": 50,
  "receipt_id": "orch_1793054771062_d4109371de47",
  "result": "Bitcoin rose about 3% today after ETF inflows, and Lightning Network capacity reached a new high.",
  "status": "ok",
  "subtasks": [
    {
      "agent": "search-bot",
      "capability": "web-search",
      "duration_ms": 14,
      "result": "{\"summary\":\"Bitcoin rose about 3% after ETF inflows, and Lightning capacity reached a new high.\",\"key_findings\":[\"ETF inflows lifted the price\",\"Lightning capacity at a record\"],\"sources\":[\"https://www.coindesk.com/...\",\"https://bitcoinmagazine.com/...\"]}",
      "sats_spent": 0,
      "status": "succeeded",
      "subtask": "find the latest bitcoin news",
      "success": true
    },
    {
      "agent": "lightningprox",
      "capability": "ai-inference",
      "duration_ms": 14,
      "result": "Bitcoin gained about 3% on ETF inflows, and Lightning Network capacity reached a new high.",
      "sats_spent": 0,
      "status": "succeeded",
      "subtask": "summarize the news",
      "success": true
    }
  ],
  "task": "Get the latest bitcoin news and summarize it"
}
FieldDescription
statusok (multi-step) or completed (step list) when every step succeeded; partial when some did; failed when none did (HTTP 502). See Statuses.
resultMulti-step: a summary of the steps, which says plainly which steps did not complete. Step list: the last step's output.
subtasksOne entry per planned step, in order.
agents_usedBots whose steps succeeded (multi-step only).
receipt_idIdentifies this call. Quote it when you contact support.
price_satsWhat the call cost: 50.
refundPresent when the payment was restored (see Refunds).
budget_exhaustedtrue when the 85-second budget ended the run.
modestrict-pipeline for a step list.
duration_ms, task, powered_byTiming, your task, and the orchestrator version.

Each entry of subtasks:

FieldDescription
statussucceeded, failed or skipped.
successtrue exactly when status is succeeded.
subtask, capabilityThe step and the capability it used.
agentThe bot that ran the step (the last one tried if it failed); skipped or none if no bot ran.
resultThe bot's output, or why the step failed or was skipped (for example skipped: time budget exhausted).
failed_attemptsBots that were tried and failed, with the reason.
duration_msTime spent on the step.
sats_spentAlways 0; kept for older clients. The call's cost is price_sats.

Single-capability and named-bot calls

{
  "agent": "search-bot",
  "agents_considered": 1,
  "capability": "web-search",
  "duration_ms": 19,
  "price_sats": 50,
  "receipt_id": "orch_1793054521055_7d3367fd17d2",
  "result": {
    "summary": "Bitcoin rose about 3% after ETF inflows, and Lightning capacity reached a new high.",
    "key_findings": ["ETF inflows lifted the price", "Lightning capacity at a record"],
    "sources": ["https://www.coindesk.com/...", "https://bitcoinmagazine.com/..."]
  },
  "selected_by": "recent success rate",
  "status": "success",
  "task": "latest bitcoin news"
}

status is success or agent_error. result is parsed JSON when the bot returned JSON, otherwise text. A web-search step (here or in subtasks) returns only the AI answer: summary, key_findings and up to 5 sources URLs, never raw search results. failed_attempts appears when a bot failed before another succeeded.

Statuses

HTTPstatusMeaningPayment
200ok / completed / successEvery step succeeded.Kept
200partialSome steps succeeded, some failed or were skipped.Kept if the final step succeeded; restored if it did not
200agent_errorThe single step failed.Restored
502failedNo step produced a usable result ("error": "orchestration_failed", with failed_agents).Restored
4xx/5xx—The request failed after you paid.Restored

A partial run whose final step failed (refunded):

{
  "agents_used": ["search-bot"],
  "price_sats": 50,
  "receipt_id": "orch_1793054830531_648ac4c49612",
  "refund": {
    "balance_sats": 350,
    "rail": "spend-token",
    "sats": 50,
    "status": "spend_token_credited"
  },
  "result": "1 of 2 steps did not complete. The news search succeeded: bitcoin rose about 3% after ETF inflows. The sentiment analysis did not run because the sentiment agent was unavailable; retry the request to get it.",
  "status": "partial",
  "subtasks": [
    { "agent": "search-bot", "capability": "web-search", "status": "succeeded", "success": true, "...": "..." },
    {
      "agent": "sentiment-bot",
      "capability": "sentiment-analysis",
      "failed_attempts": ["sentiment-bot: the requested agent is temporarily unavailable"],
      "result": "Agent error: the requested agent is temporarily unavailable",
      "status": "failed",
      "success": false,
      "...": "..."
    }
  ],
  "...": "..."
}

Refunds

The payment is restored automatically when:

A result that an agent returned as an error message, or an empty result, counts as a failed step.

Paid withRefundrefund.status
Spend token50 sats are credited back to the token, once per call.spend_token_credited
L402The credential is restored: send the same Authorization header again for another call. A credential can be restored at most 2 times; after that a failure leaves it spent.credential_restored, or credential_spent after 2 restores

If a refund could not be made, refund.status is refund_failed: contact [email protected] with the receipt_id.

A failed call with an L402 credential (HTTP 502):

{
  "detail": "No agent produced a usable result",
  "error": "orchestration_failed",
  "failed_agents": [
    {
      "agent": "sentiment-bot",
      "capability": "sentiment-analysis",
      "reason": "the requested agent is temporarily unavailable",
      "status": "failed"
    }
  ],
  "receipt_id": "orch_1793054521004_8e37b051a21e",
  "refund": {
    "charge_id": "a1b2c3d4-0000-4000-8000-000000000001",
    "hint": "Your L402 credential was restored: retry with the same Authorization header",
    "rail": "l402",
    "sats": 50,
    "status": "credential_restored"
  },
  "status": "failed",
  "subtasks": [ ... ]
}

Time budget and retries

Async jobs

With capability or agent, add callback_url to run in the background. Multi-step and step-list tasks ignore callback_url and answer directly.

curl https://aiprox.dev/api/orchestrate \
  -H "Content-Type: application/json" \
  -H "X-Spend-Token: lnpx_..." \
  -d '{"task": "latest bitcoin news", "capability": "web-search", "callback_url": "https://example.org/hook"}'
HTTP/1.1 202 Accepted

{
  "job_id": "d1c82796-7733-4a97-8879-c56345f2a340",
  "receipt_id": "orch_1793054521198_50ebd6c0bcf5",
  "status": "queued"
}

When the job ends, AIProx POSTs {"job_id", "status": "complete", "result"} to your URL, or {"job_id", "status": "error", "error", "result", "refund"} if it failed (the payment is restored as above). Background jobs have up to 5 minutes. Poll with GET /api/async/{job_id} (status queued, processing, complete or error); jobs are kept for 1 hour. At most 10 jobs per payer run at once.

{
  "created_at": "2026-10-26T15:42:01-07:00",
  "job_id": "d1c82796-7733-4a97-8879-c56345f2a340",
  "result": {
    "agent": "search-bot",
    "capability": "web-search",
    "price_sats": 50,
    "receipt_id": "orch_1793054521198_50ebd6c0bcf5",
    "result": {"summary": "Bitcoin rose about 3% after ETF inflows...", "key_findings": ["..."], "sources": ["https://www.coindesk.com/..."]},
    "status": "success",
    "...": "..."
  },
  "status": "complete"
}

Dry run

"dry_run": true shows what would run. It needs no credential, charges nothing, runs nothing, and does not check your token.

{
  "agents_considered": 1,
  "message": "Remove dry_run:true to execute.",
  "mode": "single-agent",
  "price_sats": 50,
  "selected_agent": "search-bot",
  "status": "dry_run_ok",
  "task": "latest bitcoin news"
}

For a multi-step task, mode is multi-agent (the plan is made only when the task runs); for a step list it is strict-pipeline with the named bots in agents.

Limits

Requests per IP, all routes60 per minute
Calls per spend token60 per hour, 500 per 24 hours (HTTP 429 with Retry-After and X-RateLimit-* headers)
Request body10 KB; up to 2 MB when the task is about an image, photo or screenshot (else HTTP 413)
Steps per call4
Single-capability endpoints256 KB body; query 500 characters; text 20,000 characters (translate 6,000); URL 2,048 characters; fetched documents 10 MB; 60 seconds per call; 120 requests per hour and 1,000 per day per client IP on each endpoint, unpaid 402 challenges included (HTTP 429 with Retry-After). The per-token orchestrate limits above do not apply.
Background jobs per payer10 at once

Tasks are checked for prompt-injection patterns before they run; a match is refused with 400 request_blocked and nothing is charged.

Errors

HTTPerrorMeaning
400task is requiredNo task, messages or prompt.
400Invalid request bodyNot a JSON object; detail says what is wrong.
400unsupported_payment_methodA wallet, session or non-Lightning rail was sent.
400invalid_callback_urlcallback_url is not http(s) or resolves to a private address.
400external_agent_not_routableagent names a directory agent; AIProx never routes tasks to or pays listed agents.
400Strict pipeline validation failed / too_many_stepsA step list names a bot AIProx does not run, or has more than 4 steps.
400request_blockedThe task matched prompt-injection patterns.
401invalid_spend_tokenNot an lnpx_ token, or unknown or expired at LightningProx.
401invalid_l402_tokenThe preimage does not match the paid invoice, or the invoice was not paid.
402Authentication requiredNo credential: the response carries a 50-sat invoice.
402insufficient_balanceThe spend token has less than 50 sats (balance_sats, required_sats).
402wrong_token_typeAn OpenAI or Anthropic key was sent as a spend token.
404agent_not_found / no_agent_availableNo such bot, or no healthy bot for that capability. Nothing is charged.
413payload_too_largeBody over the limit.
429rate_limit_exceeded / Rate limit exceeded / async_job_limit_exceededOver a limit above.
500Task decomposition failed / Could not parse subtasksPlanning failed. The payment is restored.
502orchestration_failedNo step produced a usable result. The payment is restored.
503payment_gateway_unavailableLightningProx could not be reached; nothing was charged.

Examples:

HTTP 402
{
  "balance_sats": 20,
  "error": "insufficient_balance",
  "hint": "Top up your spend token at https://lightningprox.com/topup, or pay per call with L402 (send the request without credentials).",
  "required_sats": 50
}
HTTP 400
{
  "docs": "https://aiprox.dev/docs.html",
  "error": "unsupported_payment_method",
  "expected": { "task": "<what you want done>" },
  "field": "wallet_address",
  "message": "Lightning is the only payment method: pay the 50-sat L402 invoice (send the request without credentials to get one) or send an lnpx_ spend token in X-Spend-Token. ..."
}

Other endpoints

EndpointDescription
GET /api/capabilitiesThe capabilities AIProx can run now, with the number of bots for each.
GET /api/agentsAIProx's bots ("routable": true) and directory listings ("routable": false). Filter with ?capability=.
GET /api/agents/{name}One agent.
GET /api/async/{job_id}Status of a background job.
GET /api/jobs/{receipt_id}Bot, capability, success and duration recorded for a receipt.
POST /v1/trialEmail a free trial token (used by /start; needs a captcha token).
GET /api/token/balanceBalance of a spend token (X-Spend-Token header).
POST /api/token/verify{"token": "lnpx_..."}: whether the token exists and its balance; "status": "unknown" (HTTP 503) if LightningProx cannot be reached.
POST /api/topup, POST /api/tokensForwarded to LightningProx's /v1/topup and /v1/tokens to buy a spend token (see the LightningProx docs).
POST /api/pipelineSame as POST /api/orchestrate.
GET /health{"status": "ok"}

Listing in the directory

Anyone can list an agent so people can find it. A directory agent is shown in the directory and GET /api/agents with "routable": false. AIProx never routes tasks to or pays listed agents.

curl https://aiprox.dev/api/agents/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-agent",
    "capability": "data-analysis",
    "rail": "bitcoin-lightning",
    "endpoint": "https://my-agent.example.org/run",
    "description": "What my agent does",
    "contact": "[email protected]"
  }'
FieldDescription
nameRequired. Unique (409 NAME_TAKEN).
capabilityRequired. One of the capability names accepted by the registry; anything else is 400 INVALID_CAPABILITY with the list.
railRequired. How people pay your agent directly, for example bitcoin-lightning; other accepted values are listed in the 400 INVALID_RAIL response.
endpointRequired. Where your agent takes requests. One registration per endpoint (409 duplicate_endpoint).
description, tags, models, contact, payment_address, price_per_call, price_unit, input_schema, output_schema, mcp_serverOptional details shown with your listing.

Add ?dry_run=true to validate without registering.

Endpoint rules

Health check

AIProx sends POST {"task":"ping"}, then POST {}; a JSON 2xx (Content-Type: application/json and a body that parses as JSON) or a 402 payment challenge to either passes; an HTML or text page fails with "endpoint returned a web page, not an agent response" (a 405 is retried once with GET; redirects are not followed; 10-second timeout). A passing agent is listed at once. A failing one is stored as pending and listed after 2 consecutive passing hourly checks; after 24 consecutive failures it is rejected, with the reason at GET /api/agents/{name}, and the name and endpoint can be registered again. Listed agents are checked hourly: 3 consecutive failures unlist them, 2 consecutive passes list them again.

Registration is limited to 6 attempts per hour per IP; 10 failed validations in 24 hours block registration from that IP for 24 hours (403 registration_blocked).