Tlolela go diteng
Moka Moka

Motheo wa tsebo Moka

Phatlalatšo, Top-ups and keys

Phatlalatšo e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee e tee.

Phatlalatšo

Di na le diphoofolo tša go swana le tše dingwe e na le diphoofolo tša go swana le diphoofolo tša go swana.

GET https://nymbot.ai/api/v1/credits/balance — Hlapi ye e hwetšwa API key. POST Di hwetšwago gona

balance is the two balances together in dollars at the current Bitcoin price, for tools that expect a single number (null (Letšatšikgwedi) Melao ke ye e tšerego sephetho ka tšerego ya tšerego ya tšerego ya tšerego ya tšerego. key Phatlalatšo e na le tokelo e na le tokelo e na le tokelo e na le tokelo e na le tokelo.

Moka

{
  "balance": 49.18,
  "balance_sats": 42037,
  "standard": { "credits": 120.4, "sats": 1204 },
  "pro": { "credits": 408.33, "sats": 40833 },
  "key": {
    "id": "4f0c9a1be27d3856",
    "name": "laptop scripts",
    "limit_sats": 20000,
    "period_used_sats": 3412,
    "total_used_sats": 18230,
    "reset_period": "monthly",
    "reset_at": "2026-10-01T00:00:00Z"
  }
}
MokaWo ile
401Ke ye e itšego, e itšego, e itšego, e itšego, e itšego.

cURL

curl https://nymbot.ai/api/v1/credits/balance \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os
import requests

res = requests.get(
    "https://nymbot.ai/api/v1/credits/balance",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
)
balance = res.json()
print(balance["standard"]["sats"], balance["pro"]["sats"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/credits/balance", {
  headers: { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY },
});
const balance = await res.json();
console.log(balance.standard.sats, balance.pro.sats);

metle

Phatlalatšo e na le mmele wa setšhaba. Phatlalatšo e na le methode.

GET https://nymbot.ai/api/v1/topup/payment-methods Tlhalošo ya Tšhireletšo

A top-up is 10 to 1,000,000 sats; a Pro top-up e na le boima ba le boima ba le boima ba le boima ba le boima ba le 100 sats. bulk_bonus e na le karolong ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhir

Moka

{
  "supported_methods": [
    {
      "method": "btc-lightning",
      "display_name": "Bitcoin Lightning",
      "supported_currencies": ["SATS", "USD", "BTC"],
      "limits": {
        "SATS": { "min": 10, "max": 1000000 },
        "USD": { "min": 0.02, "max": 1170 },
        "BTC": { "min": 1e-7, "max": 0.01 }
      },
      "tiers": ["standard", "pro"],
      "default_tier": "pro",
      "tier_min_sats": { "standard": 10, "pro": 100 },
      "sats_per_credit": { "standard": 10, "pro": 100 },
      "bulk_bonus": [
        { "bonus": 0.1, "standard_sats": 500, "pro_sats": 5000 },
        { "bonus": 0.15, "standard_sats": 1000, "pro_sats": 10000 },
        { "bonus": 0.2, "standard_sats": 5000, "pro_sats": 50000 }
      ]
    }
  ]
}

cURL

curl https://nymbot.ai/api/v1/topup/payment-methods

Python

import requests

methods = requests.get("https://nymbot.ai/api/v1/topup/payment-methods").json()
print(methods["supported_methods"][0]["limits"])

JavaScript

const methods = await (await fetch("https://nymbot.ai/api/v1/topup/payment-methods")).json();
console.log(methods.supported_methods[0].limits);

Phatlalatšo

Go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma Moka Di hwetšwago gona

POST https://nymbot.ai/api/v1/topup/create/btc-lightning — Hlapi ye e hwetšwa API key.

MokaMokaMokaMoka
amountMokaEeMoka, Moka currencySebaka sa go gola.
currencyMokaMokaSATS (Tšhireletšo ya Mmasepala) USD Moka BTC. Dollars di hwetšwa ka bitcoins price.
tierMokaMokapro (Letlakala la go fihla) goba standard: Kgaolo ya tšhireletšo ya tšhireletšo ya tšhireletšo.

A bonolo ye 10 Sats and a Pro credit 100 Sats, plus le bonolo ya bulk; credits Di hwetšwago gona

Moka

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "payment_request": "lnbc100u1p5...",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": "2026-09-30T09:27:00Z",
  "status": "pending"
}
MokaWo ile
400Pitsi ye e tee (unsupported_method(Tšhireletšo ya Mmasepala)unsupported_currency) goba tier, dimilimetara tše dingwe, goba dimilimetara tše dingwe (amount_too_small), boima bja boima bja boima bja boima bja botšhotšhisi (amount_too_large) goba methalo ya Lightning wallet (amount_out_of_range).
429Phatlalatšo ya diphedi ya diphedi ya diphedi ya diphedi ya diphedi ya diphedi ya diphedi ya diphedi ya diphedi.rate_limit_exceededWago Retry-After).
502Tlhalošo ya Mohlala (invoice_unavailableWago Retry-After).

cURL

curl https://nymbot.ai/api/v1/topup/create/btc-lightning \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10000, "currency": "SATS", "tier": "pro"}'

Python

import os
import requests

res = requests.post(
    "https://nymbot.ai/api/v1/topup/create/btc-lightning",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
    json={"amount": 10000, "currency": "SATS", "tier": "pro"},
)
invoice = res.json()
print(invoice["payment_request"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/topup/create/btc-lightning", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.NYMBOT_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ amount: 10000, currency: "SATS", tier: "pro" }),
});
const invoice = await res.json();
console.log(invoice.payment_request);

Phatlalatšo

Di hwetšwago gona - Di hwetšwago gona - Di hwetšwago gona creditedPhatlalatšo ya go swana le tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho.

GET https://nymbot.ai/api/v1/topup/status/{invoice_id} — Neela ke ye nimo wa nimo wa setšhaba.

status Moka pending (Letlakala la go fihla diswantšho tše dingwe), paid (Letšatšikgwedi ye e hwetšwago gona, e hwetšwago gona) credited (O na le mmele wa setšhaba) goba expired (Tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo)

Moka

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "status": "credited",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": null,
  "balance_credits": 523.33,
  "balance_sats": 52333
}
MokaWo ile
400ID ke ye 64-character id ya setšhaba.
404Tshedimošo ya mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo wa mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo wa.invoice_not_found).

cURL

curl https://nymbot.ai/api/v1/topup/status/$INVOICE_ID \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os, time
import requests

headers = {"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]}
url = "https://nymbot.ai/api/v1/topup/status/" + invoice["invoice_id"]

while True:
    status = requests.get(url, headers=headers).json()["status"]
    if status in ("credited", "expired"):
        break
    time.sleep(3)
print(status)

JavaScript

const headers = { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY };
const url = "https://nymbot.ai/api/v1/topup/status/" + invoice.invoice_id;

let status;
do {
  await new Promise((r) => setTimeout(r, 3000));
  status = (await (await fetch(url, { headers })).json()).status;
} while (status !== "credited" && status !== "expired");
console.log(status);

Wago

E-maili ye e-maili ye e-maili ye e-maili ye e-maili ye e-maili ye e-maili

GET https://nymbot.ai/api/v1/queries/history — kudu ye nkgokolo ya API, e hwetšwa ke ye nkgokolo, goba a Phatlalatšo o na le nyam, o na le karolwana ye e hwetšwago

MokaMokaMokaMoka
pageMoka (Moka)MokaPhatlalatšo ya 1 ka 1000; Phatlalatšo ya 1 ka 400 invalid_value.
page_countMoka (Moka)MokaRows per page. Default 20, go feta 100.
start_date
end_date
Moka (Moka)MokaISO 8601 – Dates and Times (Matšatši a matšatši)
modelMoka (Moka)MokaMoka Moka
typeMoka (Moka)Mokachat, responses, messages, image, video, speech, transcription Moka embedding.
all_keysMoka (Moka)MokaSebaka sa se ke: true Phatlalatšo ya setšhaba false.
key_idMoka (Moka)MokaPhatlalatšo ya setšhaba, goba all_keys=trueE hwetšwago gona

Moka

{
  "data": [
    {
      "id": "q_71c4e9a0",
      "timestamp": "2026-09-30T08:12:00Z",
      "model": "anthropic/claude-sonnet-5",
      "type": "chat",
      "input_tokens": 1240,
      "output_tokens": 380,
      "cached_tokens": 0,
      "cost_sats": 16.2,
      "cost_usd": 0.01895,
      "balance": "pro",
      "key_id": "4f0c9a1be27d3856",
      "web_search": false,
      "status": "ok"
    }
  ],
  "pagination": { "page": 1, "page_count": 20, "total": 311, "total_pages": 16 }
}

cURL

curl "https://nymbot.ai/api/v1/queries/history?page_count=50&type=chat" \
  -H "Authorization: Bearer $NYMBOT_API_KEY"

Python

import os
import requests

res = requests.get(
    "https://nymbot.ai/api/v1/queries/history",
    headers={"Authorization": "Bearer " + os.environ["NYMBOT_API_KEY"]},
    params={"page_count": 50, "type": "chat"},
)
for row in res.json()["data"]:
    print(row["timestamp"], row["model"], row["cost_sats"])

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/queries/history?page_count=50&type=chat", {
  headers: { "Authorization": "Bearer " + process.env.NYMBOT_API_KEY },
});
for (const row of (await res.json()).data) console.log(row.timestamp, row.model, row.cost_sats);

Phatlalatšo

Thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa, thutlwa

Lapa Lapa Lapa Lapa Lapa Moka Sheet e na le methapo. E na le methapo e na le methapo. E na le methapo.

The signature is a Nostr event of kind 27235 (NIP-98), sent base64-coded in the Authorization Phatlalatšo Nostr Moka Moka

Moka

{
  "kind": 27235,
  "created_at": 1790726400,
  "tags": [
    ["u", "https://nymbot.ai/api/v1/keys"],
    ["method", "POST"],
    ["nonce", "9c4e21f07a3b...16 random bytes in hex"],
    ["payload", "3f1a0d7c8e2b...sha256 of the exact request body in hex"]
  ],
  "content": "",
  "pubkey": "your public key in hex",
  "id": "...",
  "sig": "..."
}
  • u is the full URL of the request, query string included, eksactly as sent.
  • method methode ya HTTP.
  • payload is the SHA-256 of the raw request body, in hex. POST le PATCH, and the body you send has to be byte for byte the one you hashed.
  • created_at Phatlalatšo e na le 60 ya mehuta ya diphedi ya server.
  • Moka Moka Moka Moka Moka Moka GET e ntsho, ka nako ye ntsho e hwetšwa. Tšhireletšo ye e hwetšwa. Tšhireletšo ya go nonce tag le go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma go thoma
  • The body of a signed request can be at a maximum of 64 KB, and a body needs Content-Type: application/json.

Moka Moka Moka Moka 401 missing_nostr_auth• O na le maleme a nkgethilwe, a nkgethilwe, a nkgethilwe, a nkgethilwe, a nkgethilwe, a nkgethilwe, a nkgethilwe invalid_nostr_auth, le boikgafo ya diphoofolo; a re-used one returns nostr_auth_replayedPhatlalatšo ya setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba. 429 Moka Retry-After.

Diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana (https://nymbot.ai, https://nymchat.app Phatlalatšo ya setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa OriginMaemo a se nago.

Moka Moka

Phatlalatšo e na le nngwe ke ye nngwe ya nngwe (the nsecDi hwetšwago gona, di hwetšwago gona, di hwetšwago gona

Phatlalatšo e na le bokgwana ye e le bokgwana ye e le bokgwana ye e le bokgwana. NOSTR_SECRET_HEX; le cURL one se lo Moka omo ile-command-line tool, e na le nsec goba hex key, le sha256sum (E hwetšwago gona) shasum -a 256).

cURL

nostr_auth() {
  method="$1"; url="$2"; body="$3"
  nonce=$(openssl rand -hex 16)
  if [ -n "$body" ]; then
    hash=$(printf '%s' "$body" | sha256sum | cut -d' ' -f1)
    event=$(nak event --sec "$NOSTR_SECRET_HEX" -k 27235 -t "u=$url" -t "method=$method" -t "nonce=$nonce" -t "payload=$hash")
  else
    event=$(nak event --sec "$NOSTR_SECRET_HEX" -k 27235 -t "u=$url" -t "method=$method" -t "nonce=$nonce")
  fi
  printf 'Nostr %s' "$(printf '%s' "$event" | base64 | tr -d '\n')"
}

Python

# pip install coincurve requests
import base64, hashlib, json, os, time
from coincurve import PrivateKey, PublicKeyXOnly

SECRET = bytes.fromhex(os.environ["NOSTR_SECRET_HEX"])

def nostr_auth(method, url, body=b""):
    pubkey = PublicKeyXOnly.from_secret(SECRET).format().hex()
    tags = [["u", url], ["method", method], ["nonce", os.urandom(16).hex()]]
    if body:
        tags.append(["payload", hashlib.sha256(body).hexdigest()])
    created_at = int(time.time())
    serialized = json.dumps([0, pubkey, created_at, 27235, tags, ""], separators=(",", ":"), ensure_ascii=False)
    event_id = hashlib.sha256(serialized.encode()).digest()
    event = {
        "id": event_id.hex(),
        "pubkey": pubkey,
        "created_at": created_at,
        "kind": 27235,
        "tags": tags,
        "content": "",
        "sig": PrivateKey(SECRET).sign_schnorr(event_id).hex(),
    }
    return "Nostr " + base64.b64encode(json.dumps(event).encode()).decode()

JavaScript

// npm install nostr-tools
import { createHash, randomBytes } from "node:crypto";
import { finalizeEvent } from "nostr-tools/pure";

const secret = Buffer.from(process.env.NOSTR_SECRET_HEX, "hex");

export function nostrAuth(method, url, body = "") {
  const tags = [["u", url], ["method", method], ["nonce", randomBytes(16).toString("hex")]];
  if (body) tags.push(["payload", createHash("sha256").update(body).digest("hex")]);
  const event = finalizeEvent(
    { kind: 27235, created_at: Math.floor(Date.now() / 1000), tags, content: "" },
    secret,
  );
  return "Nostr " + Buffer.from(JSON.stringify(event)).toString("base64");
}

Moka Moka

Ke ye e hwetšwa ka moka la API ya app: ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke e hwetšwa ke ke e hwetšwa ke e hwetšwa ke e hwetšwa ke e hwetšwa ke e hwetšwa ke e hwetšwa ke e hwetšwa Phatlalatšo Moka, goba null geo se se bonolo.

GET https://nymbot.ai/api/v1/account Moka a Phatlalatšo.

Moka

{
  "data": {
    "pubkey": "3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d",
    "balances": {
      "standard": { "credits": 120.4, "sats": 1204 },
      "pro": { "credits": 408.33, "sats": 40833 }
    },
    "keys_active": 3,
    "nwc_auto_topup": {
      "connected": true, "threshold_sats": 5000, "topup_sats": 20000, "tier": "pro",
      "last_topup_at": null, "last_topup_sats": null, "last_error": null
    }
  }
}

cURL

URL=https://nymbot.ai/api/v1/account
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/account"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/account";
const res = await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } });
console.log(await res.json());

Moka Moka

Phatlalatšo ya go ba le nkgetheng ya le nkgetheng ya go ba le nkgetheng ya go swana. Phatlalatšo. Tšhireletšo ya tšhireletšo e tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tšea diswantšho tša tšhireletšo:

Moka

{
  "id": "4f0c9a1be27d3856",
  "name": "laptop scripts",
  "hint": "sk-nymbot-Qm7x…c2Lw",
  "limit_sats": 20000,
  "reset_period": "monthly",
  "reset_at": "2026-10-01T00:00:00Z",
  "expire_at": null,
  "period_used_sats": 3412,
  "total_used_sats": 18230,
  "created_at": "2026-08-14T09:21:07Z",
  "updated_at": "2026-09-02T17:40:55Z",
  "last_used_at": "2026-09-30T08:12:00Z",
  "revoked_at": null
}

hint Di na le tokelo ya tšhireletšo yeo e tšerego sephetho ka tšhireletšo ya tšhireletšo yeo e tšerego sephetho ka tšhireletšo yeo e tšerego sephetho ka tšhireletšo yeo e tšerego sephetho ka tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo.

Pitsi keys

GET https://nymbot.ai/api/v1/keys WAGO

MokaMokaMokaMoka
include_revokedMoka (Moka)MokaTshepedišo ya Mmasepala false.

Moka

{ "data": [ { "id": "4f0c9a1be27d3856", "name": "laptop scripts", "hint": "sk-nymbot-Qm7x…c2Lw", "...": "..." } ] }

cURL

URL=https://nymbot.ai/api/v1/keys
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys"
for key in requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json()["data"]:
    print(key["id"], key["name"], key["period_used_sats"], key["limit_sats"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys";
const { data } = await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json();
for (const key of data) console.log(key.id, key.name, key.period_used_sats, key.limit_sats);

Phatlalatšo

POST https://nymbot.ai/api/v1/keys © 2019 metle 201.

MokaMokaMokaMoka
nameMokaEe1 go ya ka 40 ya diphoofolo, e hwetšwa go ya ka mešomo ya tšhireletšo ya tšhireletšo (tšhireletšo ya tšhireletšo).
limit_satsMokaMokaKapari ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona ya tšona.
reset_periodMokaMokadaily, weekly Moka monthlyMoka limit_sats. Tlhalošo ya go ya ka tšhoga yeo e tšhoga go ya ka tšhoga yeo e tšhoga.
expire_atTsepelovo goba TsepelovoMokaKgaolo ya tšhireletšo e tšhireletšo: a ISO 8601 time, goba miliseconds sedumedi 1970.

Pitsi (201)

{
  "data": {
    "id": "4f0c9a1be27d3856",
    "name": "laptop scripts",
    "hint": "sk-nymbot-Qm7x…c2Lw",
    "limit_sats": 20000,
    "reset_period": "monthly",
    "key": "sk-nymbot-Qm7x...c2Lw",
    "...": "the rest of the key object"
  }
}
MokaWo ile
400Tlhalošo ya tšhireletšo ya tšhireletšo goba tšhireletšo ya tšhireletšo ya tšhireletšo (duplicate_name); a cap ke ye nngwe ye nngwe ya dimilimetara tše 1; a reset ya go ba cap; a matšatši mo lewatleng; a field unknown (unknown_parameter); goba 25 ya dikhunkhwane (too_many_keys).
429Phatlalatšo ya setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa warate_limit_exceededWago Retry-After).

cURL

URL=https://nymbot.ai/api/v1/keys
BODY='{"name":"laptop scripts","limit_sats":20000,"reset_period":"monthly"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json
import requests

url = "https://nymbot.ai/api/v1/keys"
body = json.dumps({"name": "laptop scripts", "limit_sats": 20000, "reset_period": "monthly"}).encode()
res = requests.post(
    url,
    data=body,
    headers={"Authorization": nostr_auth("POST", url, body), "Content-Type": "application/json"},
)
print(res.json()["data"]["key"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys";
const body = JSON.stringify({ name: "laptop scripts", limit_sats: 20000, reset_period: "monthly" });
const res = await fetch(url, {
  method: "POST",
  headers: { "Authorization": nostrAuth("POST", url, body), "Content-Type": "application/json" },
  body,
});
console.log((await res.json()).data.key);

Moka Moka

GET https://nymbot.ai/api/v1/keys/{id} WAGO

Moka {"data": {…}} gomme ka methalo ya methalo, goba 404 key_not_found e ka se ke ye nngwe ke ye a nngwe le a nngwe

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json()["data"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
console.log((await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json()).data);

Phatlalatšo

PATCH https://nymbot.ai/api/v1/keys/{id} WAGO

Wo ile name, limit_sats, reset_period le expire_at, le methalo ya tšhireletšo yeo e sa le ka fase ga tšhireletšo ya tšhireletšo. null Phatlalatšo ya setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa400 key_revokedMoka {"data": {…}} methalo ya methalo.

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
BODY='{"limit_sats":50000,"expire_at":null}'
curl -X PATCH "$URL" \
  -H "Authorization: $(nostr_auth PATCH "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json
import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
body = json.dumps({"limit_sats": 50000, "expire_at": None}).encode()
res = requests.patch(
    url,
    data=body,
    headers={"Authorization": nostr_auth("PATCH", url, body), "Content-Type": "application/json"},
)
print(res.json()["data"])

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
const body = JSON.stringify({ limit_sats: 50000, expire_at: null });
const res = await fetch(url, {
  method: "PATCH",
  headers: { "Authorization": nostrAuth("PATCH", url, body), "Content-Type": "application/json" },
  body,
});
console.log((await res.json()).data);

Phatlalatšo

DELETE https://nymbot.ai/api/v1/keys/{id} WAGO

Phatlalatšo ya setšhaba, Phatlalatšo revoked_at geo, a ka se bonolo ka include_revoked=trueDi hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke ye e hwetšwa ke e hwetšwa ke ye e hwetšwa.

Moka

{ "data": { "id": "4f0c9a1be27d3856", "revoked": true } }

cURL

URL=https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856
curl -X DELETE "$URL" -H "Authorization: $(nostr_auth DELETE "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856"
print(requests.delete(url, headers={"Authorization": nostr_auth("DELETE", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/keys/4f0c9a1be27d3856";
const res = await fetch(url, { method: "DELETE", headers: { "Authorization": nostrAuth("DELETE", url) } });
console.log(await res.json());

Moka Moka Moka Moka

Phatlalatšo ya Lightning ka Nostr Wallet Connect le Nymbot ke sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka sephaphathi ka Phatlalatšo.

Phatlalatšo ya mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo mohuta wo Phatlalatšo Moka Moka

Moka Moka Moka

Nymbot o sephaphathi yeo e šomago, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo, e na le tokelo ya tšhireletšo. pay_invoice.

Phatlalatšo

POST https://nymbot.ai/api/v1/nwc-auto-topup/connect WAGO

MokaMokaMokaMoka
nwc_urlMokaEePhatlalatšo ya setšhaba nostr+walletconnect://. Nymbot mola ka lebaka la get_info E hwetšwa ka moka, e hwetšwa ka moka.
threshold_satsMokaEeTop up when the balance falls below these many sats. Mapheko a 1000.
topup_satsMokaEeDi na le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima ba le boima.
tierMokaMokapro (Letlakala la go fihla) goba standard: The balance to watch and top up.

Moka

{
  "data": {
    "connected": true,
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
    "last_topup_at": null,
    "last_topup_sats": null,
    "last_error": null
  }
}
MokaWo ile
400Tlhalošo ya Mohlala (invalid_nwc_url(Tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo)nwc_unreachable) goba le tšekga (nwc_rejected); le nkgethilwe ke ye nkgethilwe ka moka (nwc_missing_permission); goba go ya ka mmogo ye e itšego.
501Phatlalatšo ya Mmasepala (nwc_unavailableMelao le ka mehuta ya diphedi.

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup/connect
BODY='{"nwc_url":"nostr+walletconnect://...","threshold_sats":5000,"topup_sats":20000,"tier":"pro"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Python

import json, os
import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup/connect"
body = json.dumps({
    "nwc_url": os.environ["NWC_URL"],
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
}).encode()
res = requests.post(
    url,
    data=body,
    headers={"Authorization": nostr_auth("POST", url, body), "Content-Type": "application/json"},
)
print(res.json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup/connect";
const body = JSON.stringify({
  nwc_url: process.env.NWC_URL,
  threshold_sats: 5000,
  topup_sats: 20000,
  tier: "pro",
});
const res = await fetch(url, {
  method: "POST",
  headers: { "Authorization": nostrAuth("POST", url, body), "Content-Type": "application/json" },
  body,
});
console.log(await res.json());

Phatlalatšo

GET https://nymbot.ai/api/v1/nwc-auto-topup WAGO

Mohlakanelwa ke ye e itšego, ka connected: false ...be na le mešomo null when no wallet is connected. The connection string itself is never returned.

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup
curl "$URL" -H "Authorization: $(nostr_auth GET "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup"
print(requests.get(url, headers={"Authorization": nostr_auth("GET", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup";
console.log(await (await fetch(url, { headers: { "Authorization": nostrAuth("GET", url) } })).json());

Phatlalatšo

DELETE https://nymbot.ai/api/v1/nwc-auto-topup/connection WAGO

Phatlalatšo ya setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba kgotsa wa setšhaba.

Moka

{ "data": { "connected": false, "threshold_sats": null, "topup_sats": null, "tier": null, "last_topup_at": null, "last_topup_sats": null, "last_error": null } }

cURL

URL=https://nymbot.ai/api/v1/nwc-auto-topup/connection
curl -X DELETE "$URL" -H "Authorization: $(nostr_auth DELETE "$URL")"

Python

import requests

url = "https://nymbot.ai/api/v1/nwc-auto-topup/connection"
print(requests.delete(url, headers={"Authorization": nostr_auth("DELETE", url)}).json())

JavaScript

const url = "https://nymbot.ai/api/v1/nwc-auto-topup/connection";
const res = await fetch(url, { method: "DELETE", headers: { "Authorization": nostrAuth("DELETE", url) } });
console.log(await res.json());

Nako ya go gola: Nako ya go gola

Phatlalatšo ya tšhireletšo ya tšhireletšo ya tšhireletšo e ka tšhireletšo e ka tšhireletšo ya tšhireletšo e ka tšhireletšo e ka tšhireletšo ya tšhireletšo, ka tšhireletšo ya tšhireletšo ya tšhireletšo, ka tšhireletšo ya tšhireletšo ya tšhireletšo, ka tšhireletšo ya tšhireletšo ya tšhireletšo, ka tšhireletšo ya tšhireletšo ya tšhireletšo: POST /images/generations, POST /images/edits, POST /videos, POST /audio/speech, POST /audio/transcriptions, POST /audio/translations le POST /embeddings. Chat, Replies, and Messages always need a key. A requests that carry a key are billed to the balance as usual; the payment flow only starts when no key is sent.

Nymbot o thoma mehuta ya ditulo tše di ukangwego mošomo: Lightning Labs. Moka 402 (Letlakala le tšhireletšo ya tšhireletšo, LSAT) le draft ya IETF Moka HTTP authentication scheme lightning methode charge M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M. M.

Moka Moka Moka

Melao ka se bonolo ka nako ye e šomiša API_L402_SECRET manaka a 32 baiti ye ntsho, ka hex (64 karatšo) goba base64 (44). openssl rand -hex 32. Phatlalatšo goba diphatlalatšo ya tšhireletšo e tšhireletšo le tšhireletšo le tšhireletšo le tšhireletšo. API_L402_SECRET_PREVIOUS for a day: credentials, status URLs, and challenges made under it keep working until they expire.

Moka

Phatlalatšo le Phatlalatšo le No Authorization header. Kunga ke ye e hwetšwa, e hwetšwago 402 Payment Required Nako ya tšhireletšo go ya ka ditulo tše di ukangwego: ke ya tšhireletšo ya tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhirelet WWW-Authenticate Tšhireletšo ya Mmasepala:

HTTP/1.1 402 Payment Required
Content-Type: application/problem+json; charset=utf-8
Cache-Control: no-store
WWW-Authenticate: L402 macaroon="AgJC...", invoice="lnbc2370n1..."
WWW-Authenticate: LSAT macaroon="AgJC...", invoice="lnbc2370n1..."
WWW-Authenticate: Payment id="kM9x...", realm="nymbot", method="lightning", intent="charge",
    request="eyJhbW91bnQiOiIyMzciLC...", description="Nymbot API POST /images/generations (237 sats)",
    digest="sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:", expires="2026-09-30T12:15:00.000Z",
    opaque="eyJlbmRwb2ludCI6IlBPU1QgL2ltYWdlcy9nZW5lcmF0aW9ucyJ9"

{
  "type": "https://paymentauth.org/problems/payment-required",
  "title": "Payment Required",
  "status": 402,
  "detail": "This request costs 237 sats. Pay the Lightning invoice, then send the identical request again ...",
  "challengeId": "kM9x...",
  "amount_sats": 237,
  "invoice": "lnbc2370n1...",
  "payment_hash": "9db1370f...",
  "expires_at": "2026-09-30T12:15:00.000Z",
  "error": { "message": "This request costs 237 sats. ...", "type": "payment_required", "code": "payment_required", "param": null }
}

Moka request parameter ya base64url JSON: {"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.

Di hwetšwa ka fase, ka Content-Type (melao ya media le, ka dikgwedi tše dingwe, ya thoma) le ka SHA-256 ya diphoofolo tše ntšhi ke ye e šomago, e tšhireletša dimilimetara tše 15. Moka Moka Moka Content-Type (Letlakala le boima bja botšhotšhisi bja botšhotšhisi bja botšhotšhisi bja botšhotšhisi bja botšhotšhisi bja botšhotšhisi bja botšhisi bja botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi ya botšhisi)/images/edits, /audio/transcriptions, /audio/translations(HTTP) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library) (HTTP library)

Di na le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go swana le diphoofolo tša go 429 Moka Retry-AfterPhatlalatšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo. Content-Type Moka application/json Moka multipart/form-data (Tšhireletšo ya Mmasepala) 415 Maemo a na le a nko a nko a a nko a a nko a a nko a a nko a a nko a a nko a a nko a a a nko a a a nko a a a nko a a a nko a a a nko a a nko a a a nko a a a nko a a a a a a a a a a a

Diphoofolo di be di phatlaladitšwe ka boima bja token ka botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele. Moka.

Phatlalatšo

Di phatlaladitšwe ka moka le boima bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele bja botelele.

MokaMoka
Moka 402Authorization: L402 <macaroon>:<preimage> (LSAT Moka Moka
MokaAuthorization: Payment <base64url JSON>, donde le JSON {"challenge": {every parameter of the challenge, as sent}, "payload": {"preimage": "<hex>"}}

Di na le tokelo ya tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo e tšerego sephetho sa tšhireletšo yeo e tšerego sephetho sa tšhireletšo. nymbot objekta ke ye nngwe ya dimilimetara: {"payment": "l402", "tier": "pro", "paid_sats": 237, "charged_sats": 237}...be na le no X-Nymbot-Balance-Sats header. Kgaolo ya tšhireletšo ya tšhireletšo ya tšhireletšo e ka Payment-Receipt header (base64url JSON with the challenge id, the payment hash as reference, status le timestamp). Tshepedišo ya tšhireletšo yeo e tšhireletšo yeo e tšhireletšo yeo e tšhireletšo yeo e tšhireletšo yeo e tšhireletšo yeo e tšhireletšo yeo.

MokaWo ile
402 payment_already_usedPhatlalatšo e be di phatlaladitšwe ke diphoofolo tše dingwe tša diphedi tša diphedi tša diphedi. lnget a) Molaophetošwa Molaophetošwa
402 payment_mismatchPhatlalatšo ya setšhaba ya setšhaba, Content-Type o bodulo, goba o phatlaladitšwe mafelong a go swana le mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mohuta wa mo Moka (refund_token le refund_sats Di hwetšwago gona
402 payment_expiredPhatlalatšo ya dimilimetšo ya 15 ya diphedi. Phatlalatšo ya dimilimetšo e na le diphoofolo tše di ukangwego. Moka (refund_token le refund_sats (Tšhireletšo ya Tšhireletšo)
401 invalid_preimagePhatlalatšo ya tšhireletšo yeo e tšhireletšo ka tšhireletšo ya tšhireletšo yeo e tšhireletšo yeo e tšhireletšo.
401 invalid_payment_credentialPhatlalatšo e malformed, e be e fapana go ya ka Nymbot a tšhireletšo, goba e na le nomoro ya tšhireletšo ya tšhireletšo Nymbot a tšhireletšo a tšhireletšo a tšhireletšo a tšhireletšo.
429 rate_limit_exceededDi na le 30 ya diphoofolo goba dikhunkhwane tše di hwetšwa go ya ka mehuta ya diphedi di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše di swerwego ke diphoofolo tše dingwe. Retry-After.

cURL

BODY='{"model":"nano-banana","prompt":"a lighthouse at dusk","response_format":"b64_json"}'
URL=https://nymbot.ai/api/v1/images/generations

# 1. Get the challenge
CH=$(curl -s -D - -o /dev/null "$URL" -H "Content-Type: application/json" -d "$BODY" | grep -i '^www-authenticate: L402')
MAC=$(echo "$CH" | sed -E 's/.*macaroon="([^"]+)".*/\1/')
INVOICE=$(echo "$CH" | sed -E 's/.*invoice="([^"]+)".*/\1/')

# 2. Pay $INVOICE with your wallet and copy the preimage
PREIMAGE=...

# 3. Send the identical request with the credential
curl "$URL" -H "Content-Type: application/json" -H "Authorization: L402 $MAC:$PREIMAGE" -d "$BODY"

lnget

# lnget (Lightning Labs) pays L402 challenges from your own lnd node and retries for you
lnget -X POST -H "Content-Type: application/json" \
  -d '{"model":"nano-banana","prompt":"a lighthouse at dusk","response_format":"b64_json"}' \
  https://nymbot.ai/api/v1/images/generations

Python

import base64, json, re
import requests

url = "https://nymbot.ai/api/v1/images/generations"
body = json.dumps({"model": "nano-banana", "prompt": "a lighthouse at dusk", "response_format": "b64_json"}).encode()
headers = {"Content-Type": "application/json"}

challenge = requests.post(url, data=body, headers=headers)
assert challenge.status_code == 402
info = challenge.json()
print("Pay", info["amount_sats"], "sats:", info["invoice"])

preimage = pay_with_your_wallet(info["invoice"])  # 64 hex characters

# L402
mac = re.search(r'L402 macaroon="([^"]+)"', challenge.headers["WWW-Authenticate"]).group(1)
res = requests.post(url, data=body, headers={**headers, "Authorization": f"L402 {mac}:{preimage}"})
print(res.json()["nymbot"])

JavaScript

const url = "https://nymbot.ai/api/v1/images/generations";
const body = JSON.stringify({ model: "nano-banana", prompt: "a lighthouse at dusk", response_format: "b64_json" });
const headers = { "Content-Type": "application/json" };

const challenge = await fetch(url, { method: "POST", headers, body });
const www = challenge.headers.get("www-authenticate");

// The Payment scheme: echo every challenge parameter back with the preimage
const start = www.indexOf("Payment ");
const params = Object.fromEntries([...www.slice(start + 8).matchAll(/(\w+)="((?:[^"\\]|\\.)*)"/g)].map((m) => [m[1], m[2]]));
const { invoice } = JSON.parse(Buffer.from(params.request, "base64url").toString()).methodDetails;
const preimage = await payWithYourWallet(invoice);

const credential = Buffer.from(JSON.stringify({ challenge: params, payload: { preimage } })).toString("base64url");
const res = await fetch(url, { method: "POST", headers: { ...headers, Authorization: `Payment ${credential}` }, body });
console.log((await res.json()).nymbot, res.headers.get("payment-receipt"));

Moka Moka Moka mppx ka methode Lightning, hwetšwa le Thutlwa ya Tšweletšo ya Mmasepala; Phatlalatšo go ya ka Thutlwa ya Tšweletšo le tšweletšo e le tšweletšo e le tšweletšo e le tšweletšo.

Moka

Moka POST /videos Moka 202 a, a, a, a, a, a status_url: GET Di hwetšwago gona, di hwetšwago gona, di hwetšwago gona

{
  "id": "vid_...",
  "status": "in_progress",
  "status_url": "https://nymbot.ai/api/v1/videos/vid_...?exp=1790000000&sig=...",
  "nymbot": {
    "payment": "l402", "tier": "pro", "paid_sats": 4800, "charged_sats": 4800,
    "refund_token": "REFUND-5E0B..."
  }
}

Moka refund_token geo se bonolo: ke ye e šomišago, ke ye e šomišago (GET /api/v1/l402/refunds Moka "status": "pending"); goba o fao di hwetšwa di hwetšwa, dihlongwa ka dihlongwa tša tsona. refund_sats e le token, e na le token, e na le token e na le token e na le token e na le token e na le token e na le token e na le token.

Moka

Tshepidišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo ya tshepedišo charged_sats, sethokeng sa go phatlaladitšwe ke. Se ne e ka fao e bile, e ka phatlaladitšwe Moka E hwetšwago gona

{
  "error": {
    "message": "The image generator failed. Nothing was charged. Please try again. The 237 sats you paid are on refund token REFUND-...",
    "type": "api_error",
    "code": "upstream_error",
    "refund_token": "REFUND-0C15DBED145D59131BA70298A413ADEB3D9B9AB082C476EA70A5BD38FCA5DE6D",
    "refund_sats": 237,
    "refund_expires_at": "2026-10-30T12:00:00.000Z"
  }
}

Phatlalatšo ya setšhaba ya setšhaba ya setšhaba ya setšhaba ya setšhaba nymbot objekta e na le token ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo ya tšhireletšo yeo e tšhireletšo e tšhireletšo ka tšhireletšo ya tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo e tšhireletšo 413 e na le nkgetheng ye nkgetheng ye nkgetheng ye nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng ya nkgetheng.

Token ya dikgoba ke ye 256-bit code. Nymbot a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke a nkgethilwe ke:

  • O NAMA Moka Authorization: Bearer REFUND-… (Letšatšikgwedi) (Letšatšikgwedi) (Letšatšikgwedi) (Letšatšikgwedi)refund_token_sats Moka nymbot a. A token o ye aya a aya a aya aya aya aya aya aya aya 402 refund_insufficient; fao di beilwego ke molao wa tsebišwa go ya ka token.
  • Moka GET /api/v1/l402/refunds Moka Moka Moka Moka {"sats": 237, "status": "open", "expires_at": "..."}.
  • Token ka nako ya go fihla disentimetara tše 60.
  • Phatlalatšo go ya ka nym. Pitsi Phatlalatšo in Nymbot app, goba call POST /api/v1/l402/refunds/redeem gomme a Phatlalatšo le {"refund_token": "REFUND-...", "balance": "standard"} Moka "pro"). Tšweletšo ya diphoofolo di be di phatlaladitšwe ka mmala (10 diphoofolo tša diphoofolo tša diphoofolo, 100 diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo tša diphoofolo.

cURL

URL=https://nymbot.ai/api/v1/l402/refunds/redeem
BODY='{"refund_token":"REFUND-...","balance":"standard"}'
curl "$URL" \
  -H "Authorization: $(nostr_auth POST "$URL" "$BODY")" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Moka

{ "data": { "credited": 23, "tier": "standard", "balance_credits": 123, "remaining_sats": 7 } }