גיין צו די אינהאַלט
צוריק צו נומער

וויסן באַזע אַוועקלייגן

דעריבער, Top-ups and keys

טשעקען וואָס איר האָבן, אַרויף אויף Lightning, אַרויף אויף אַוטומטיש פון דיין פּערזאָנט, זען וואָס יעדער אָפּשטימונג קויסט, און רעגירונג קייַז פון קוד.

דעריבער איז איז

ביידע פון דיין סוואַך, און יעדער פון דעם קלייַן פון קאַפּ איז געניצט.

GET https://nymbot.ai/api/v1/credits/balance יעדער איינער האט א API Key. POST עס איז דא א באקאנטע לקוח שמצפה לו.

balance איז די צוויי סוואַליזזז ביחד אין דולר אין די פּרייַז פון Bitcoin, פֿאַר אַרומז וואָס צופרידן אַ יחיד נומער (null די שאר איז אין קרעדיט און סאטס, וואָס איז איך די סוואַך זענען למעשה געניצט. key און דעריבער, איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך

תגובה

{
  "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"
  }
}
סטאַטןאיך
401דער מפתח איז אבדוק, נודע, רעקאָד אָדער פעלד.

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);

שיטות תשלום

איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב.

GET https://nymbot.ai/api/v1/topup/payment-methods אין מפתח נדרש.

A top-up is 10 to 1,000,000 sats; a Pro top-up has to buy at least one Pro credit, so it starts at 100 sats. bulk_bonus דערגרייכט די אַטראַקלייגן קרעדיט אויף Major Top-ups, ווי אין די אַפּ: 10%, 15% אָדער 20% more on Standard Top-ups from 500, 1,000 or 5,000 sats, and on Pro Top-ups from 5,000, 10,000 or 50,000 sats.

תגובה

{
  "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);

געפירט אויף Lightning

דעריבער, איר קענען באַקומען אַ קרעדיט צו באַקומען אַ קרעדיט צו באַקומען אַ קרעדיט. באַקומען די קרעדיט צו דערגרייכן.

POST https://nymbot.ai/api/v1/topup/create/btc-lightning יעדער איינער האט א API Key.

פעלדאוןדרושיםתיאור
amountמספריאאיך בין, אין currencyער איז געווען א מספר שלם.
currencyאון StringאיןSATS און זייער זייער מינדערוויכטיג. USD און BTCדולר זענען קאַנווערינג בייַ די נייַך Bitcoin פּרייַז.
tierאון Stringאיןpro (מיין האט געשריבן: או standard: וואָס איז דער קרעדיט.

אַ סטאַנדאַרד קרעדיט איז 10 sats און אַ פּראָ קרעדיט 100 sats, פלוס יעדער באָנוס באָנוס; credits דעריבער, איך האב די צוגעשטעלט.

תגובה

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "payment_request": "lnbc100u1p5...",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": "2026-09-30T09:27:00Z",
  "status": "pending"
}
סטאַטןאיך
400און זייער זייער מינדערוויכטיג (unsupported_methodעס איז דא א באקאנטע אויסדרוק (unsupported_currencyכ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.amount_too_small(מיטן דרייווער) זאלן מארך ימים זיין.amount_too_largeכ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.amount_out_of_range).
429מער ווי 60 רעקאָרדיז פֿאַר דעם נימ, אָדער 120 פון דעם אַדרעס, אין אַ שעה (rate_limit_exceededאון Retry-After).
502אין זײַן עת אין זײַן עת (invoice_unavailableאון 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);

באַקומען אַ Top-Up

באַקומען ווי איר קענען באַקומען אַ קרעדיט, איר קענען באַקומען אַ קרעדיט, איר קענען באַקומען אַ קרעדיט, איר קענען באַקומען אַ קרעדיט. creditedטשעקונג שוב לאחר מכן איז בטוח: די קרעדיט דאַרדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדדד

GET https://nymbot.ai/api/v1/topup/status/{invoice_id} - זקוקן אַ מפתח פון די נימ אַז געמאכט די פאַקטיש.

status און pending אין די משכנתא, paid און מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט! credited און זייער זייער מינדערוויכטיג. expired כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.

תגובה

{
  "invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
  "status": "credited",
  "amount_sats": 10000,
  "credits": 115,
  "tier": "pro",
  "expires_at": null,
  "balance_credits": 523.33,
  "balance_sats": 52333
}
סטאַטןאיך
400די ID איז לא די 64-קאַרפּער ID פון די Create Call.
404עס איז געווען א טעלעפאָנירן (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);

דעריבער היסטוריה

א שורה פּער באַזוכן: וואָס עס איז, וואָס מאָדעל, כמה טאָקן און וואָס עס קויסט. No prompts or answers are kept, so none are returned. Rows are kept for 90 days, latest first. A key that has reached its cap can still read its history.

GET https://nymbot.ai/api/v1/queries/history — זקוקן אַ API קליי, וואָס זען זייַן פּרייַז, אָדער אַ דרישה צו און מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט!

פעלדאוןדרושיםתיאור
pageדעריבער (Query)איןדערגרייכט 1, אין די מאַקסימום 1,000; אַ מער עמוד איז 400 invalid_value.
page_countדעריבער (Query)איןאַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן.
start_date
end_date
דעריבער (QueryאיןISO 8601 דאַטן אָדער שעה.
modelדעריבער (Queryאיןאין די מודל.
typeדעריבער (Queryאיןchat, responses, messages, image, video, speech, transcription און embedding.
all_keysאַוועקלייגן (Query)איןאון א מפתח: true כל מפתח איז באקאנט פון אותו נימ. false.
key_idדעריבער (Queryאיןאון א באקאנטע אויסדרוק being a signature request, or all_keys=trueרק א מפתח.

תגובה

{
  "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);

דרישות צו חשבון

געגרינדעט, געגרינדעט און געגרינדעט קלייז, די חשבון סאַמינג און אַוטומטיש טאָופ-אַפּס באַקומען אין אַ API קליי. They take a signature from your nym, so a leaked key can spend up to its cap but can never make another key or raise its own cap.

די אַפּלעס איז עס פֿאַר איר: everything in its און זײַנען די זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען.

דער חתימה איז אַ נוסטר געשעפט פון מין 27235 (NIP-98), שטעלן base64-coded in the Authorization זיי זענען מיט די מילה Nostr און א קדמה:

דער אירוע

{
  "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 איז די גאַנץ URL פון די באַזוכן, באַזוכן באַזוכן שרייַבן, בדיוק ווי צוגעשטעלט.
  • method עס איז HTTP.
  • payload איז די SHA-256 פון די רוי דרישה גוף, אין hex. POST און PATCHאון מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט!
  • created_at אין 60 סענטימעטער פון דער שרייַבן.
  • יעדער אַוועקלייגן עס איז א GET עס איז געפונען אין די ענטפער, און עס איז געפונען אין די ענטפער, און עס איז געפונען. nonce עס איז געווען א טעמפּעראַטור, און די טעמפּעראַטור איז א טעמפּעראַטור, און עס איז א טעמפּעראַטור.
  • דער קאַסע פון אַ סימנע באַשטימען קענען זיין אין מאַקסימום 64 KB, און אַ קאַסע זקוקן. Content-Type: application/json.

א באקאנטע אירוע חוזר 401 missing_nostr_authאון דעריבער, דעריבער, און דעריבער, און דעריבער, און דעריבער, און דעריבער, און דעריבער, און דעריבער, און דעריבער, און דעריבער. invalid_nostr_authאון מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט! nostr_auth_replayedאַ API key sent to these endpoints is rejected.The signature is checked before the body is read, and each address can fail it 30 times a minute ( אַ IPv6 address counts as its whole /64); נאָך דעם, עס באַקומען 429 און Retry-After.

עס איז געווען א באקאנטע באקאנטע באקאנטע באקאנטע (https://nymbot.ai, https://nymchat.app אַ פּרייַז אויף יעדער אנדערע site באַקומען אין CORS headers back, so it cannot read what they return. Script and native apps, which send no Originאין די השפעה.

א סוד מפתח

זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען זײַנען. nsecאון דעריבער, איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך

און דעריבער, איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך האָבּ איך NOSTR_SECRET_HEXאון זייער זייער מינדערוויכטיג. און עס איז געגרינדעט מיט א nsec או hex key. sha256sum און די macOS. 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");
}

חשבון סיכום

וואָס די אַפּי אַפּי צופריד אויף דער אַפּ: דיין פאַקטיש קייַן, both balances, how many keys are active (not revoked or expired), and the אַוטומאַטיש טאָפאָפּ אַוועקלייגן או null אין די שורה פון צוזאַמען.

GET https://nymbot.ai/api/v1/account דרושים א דרישה צו.

תגובה

{
  "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());

באַקומען Key

די אַפּענדינג סענטימעטער זענען די אַפּענדינג סענטימעטער.All of them need a דרישה צויעדער קליי איז רעקאָרד אין דעם פורמט, מיט times in ISO 8601 and amounts in sats:

און א אובייקט

{
  "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 די מפתח איז געפירט אין די מפתח, און די מפתח איז געפירט אין די מפתח.

רעקאָרדינג Key

GET https://nymbot.ai/api/v1/keys און חתום.

פעלדאוןדרושיםתיאור
include_revokedאַוועקלייגן (Query)איןדערגרייכט דעם מפתח.Default false.

תגובה

{ "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);

געגרינדעט א מפתח

POST https://nymbot.ai/api/v1/keys געגרינדעט - חוזר 201.

פעלדאוןדרושיםתיאור
nameאון Stringיא1 צו 40 דאַרקז, פאַרשידענע פון דיין אנדערע אַקטיוו קלייז (גאַנקרונג קאַסע).
limit_satsאיןאיןעס איז געפונען אין 1 סענטימעטער, אין 1 סענטימעטער.
reset_periodאון Stringאיןdaily, weekly און monthlyדרושים limit_satsעס איז געווען א טעמפּעראַטור שאַכט לעולם.
expire_atדעריבער און אינטארגןאיןWhen the key stops working: אַ ISO 8601 טעג, אָדער מיליסענדינט פון 1970.

און ענטפער (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"
  }
}
סטאַטןאיך
400כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.duplicate_name(מיטן דרייווער) זאלן מארך ימים זיין, און זיי וועלן דרש בּײַ די אובות [אִטּי], און בּײַ די אובות [אוֹב], און בּײַ די אובות [אוֹב], און בּײַ די אובות [אוֹב], און בּײַ די אובות [אוֹב].unknown_parameter); אָדער 25 אַקטיוו קלייז אַוועקלייגן (too_many_keys).
429מער ווי 60 קלייז געגרינדעט דורך דעם נימ, אָדער 120 פון דעם אַדרעס, אין אַ שעה (rate_limit_exceededאון 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);

לייענען א מפתח

GET https://nymbot.ai/api/v1/keys/{id} און חתום.

און חזרה {"data": {…}} און די אובייקט, או 404 key_not_found אין די זאך אין די זאך.

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);

ער האט א מפתח

PATCH https://nymbot.ai/api/v1/keys/{id} און חתום.

יעדער איינער פון name, limit_sats, reset_period און expire_atאון איך בין איך גענומען א מפתח. null עס איז געווען געווען א באקאנטע טעמפּעראַטור, און עס איז געווען א באקאנטע טעמפּעראַטור.400 key_revokedאון חזרה {"data": {…}} עס איז א מעגלעך אובייקט.

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);

דערגרייכט אַ מפתח

DELETE https://nymbot.ai/api/v1/keys/{id} און חתום.

דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער revoked_at דעריבער, און אפשר לראות include_revoked=trueאון מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט!

תגובה

{ "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());

טעלעפאָנירן Auto-top-up

באַצאָלן אַ Lightning wallet with Nostr Wallet Connect and Nymbot tops up a balance by itself when API spending runs it low. The app's API sheet has the same settings; these are the endpoints behind it. All of them need a דרישה צו.

How it works: After an API request is charged to the balance you chose to watch, if that balance has fallen below your threshold, Nymbot makes an invoice for your top-up amount, asks your wallet to pay it, and adds the credit. It tops up at most once every 5 minutes for each nym and balance, so a burst of requests cannot drain the wallet. Spending in the apps does not trigger it. The time and size of the last top-up, and the last error, are in settings; if a payment went through after an error, checking its invoice with און דער top-up קרעדיט די

לפני שאתה באַקומען אַ קוואָר

A connection string lets whoever holds it ask your wallet to pay. Nymbot stores it encrypted and only ever uses it to pay its own top-up invoices, but make a connection just for this, with a spending budget in your wallet, so the most it could ever pay is a number chose you. pay_invoice.

געפונען אַ וואַרע

POST https://nymbot.ai/api/v1/nwc-auto-topup/connect און חתום.

פעלדאוןדרושיםתיאור
nwc_urlאון Stringיאגעפונען דעם קייט, starting nostr+walletconnect://אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן. get_info און מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט!
threshold_satsאיןיאאַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן אַוועקלייגן.
topup_satsאיןיאאיך בין 1,000 צו 1,000, און איך בין 1,000 צו 1,000.
tierאון Stringאיןpro (מיין האט געשריבן: או standardאון איך האב איך געקומען און העלפן.

תגובה

{
  "data": {
    "connected": true,
    "threshold_sats": 5000,
    "topup_sats": 20000,
    "tier": "pro",
    "last_topup_at": null,
    "last_topup_sats": null,
    "last_error": null
  }
}
סטאַטןאיך
400עס איז דא א געשעפט (invalid_nwc_urlכ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.nwc_unreachableכ'האף די ווען (מיטן דרייווער).nwc_rejected(מיטן דרייווער) זאלן מארך ימים זיין.nwc_missing_permission(א) אַ סומע פון די גאַמעס.
501עס איז געווען א באקאנטע געשעפט (nwc_unavailableאון א באקאנטע אויסדרוק being the same for the other two endpoints.

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());

לייענען די settings

GET https://nymbot.ai/api/v1/nwc-auto-topup און חתום.

עס איז געווען א באקאנטע אובייקט, מיט connected: false און שאר שדות null אין די רעקאָרדינג, אין די רעקאָרדינג אין די רעקאָרדינג.

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());

אַוועקלייגן

DELETE https://nymbot.ai/api/v1/nwc-auto-topup/connection און חתום.

דעריבער, איר קענען באַקומען אין די בלעטער פון אַוועקלייגן.

תגובה

{ "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());

באַצאָלן אויף באַצאָלן אין מפתח

די fixed-price endpoints can be paid for one request at a time over Lightning, without no key, no account and no balance: POST /images/generations, POST /images/edits, POST /videos, POST /audio/speech, POST /audio/transcriptions, POST /audio/translations און POST /embeddingsצ אט, ענטפערז און Messages always need a key. A request that carries a key is billed to the balance as usual; the payment flow only starts when no key is sent.

Nymbot דען צוויי ווערסיעס פון די אותו רעיון, פון אַ אַקאַנדינג: Lightning Labs' און 402 כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין. LSATאון די IETF תשלום HTTP Authentication Scheme מיט די lightning א שיטה charge דעריבער, איר קענען באַקומען יעדער משפּחה.

דערגרייכט דעם Server

באַצאָלן אין אַ מפתח איז געווען רק כאשר API_L402_SECRET עס זענען 32 בייטס, ווי hex (64 דייקטערז) אָדער base64 (44). openssl rand -hex 32און מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט! API_L402_SECRET_PREVIOUS פֿאַר אַ טאָג: credentials, status URLs and challenges made under it keep working until they expire.

און האתגר

באַקומען צו No request Authorization דעריבער, אין דעריבער, אין דעריבער, אין דעריבער 402 Payment Required מיט אַ פאַקטיש פֿאַר די פּרייַז אַז באַזוכן קעלס: די ווידעק פּרייַז אַ קייַז וועט באַזוכן, קאַמפּערד אין 10 סאַט אַ סטאַרדס אַ קרעדיט אָדער 100 סאַט אַ פּראָ קרעדיט און אַרום צו אַ נייַן סאַט (מינימום 1 סאַט, און מינימום 0.05 קרעדיט מינימום). WWW-Authenticate דערגרייכט די באקאנטע חשבונות:

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 }
}

די תשלום request אַפּעראַמעטער איז base64url JSON: {"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.

עס איז געגרינדעט צו די סוף, צו Content-Type (האָצוואַנאַ Pula צו ייראָ באָצוואַנאַ Pula צו ייראָ באָצוואַנאַ Pula צו יו באָצוואַנאַ Pula צו ביטקאָין באָצוואַנאַ Pula צו ביטקאָין באָצוואַנאַ Pula צו יען און זהה ער האט געשריבן: The same Content-Type כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין./images/edits, /audio/transcriptions, /audio/translationsבאָצוואַנאַ Pula צו ישראל נייַ שעקעל באָצוואַנאַ Pula צו ייראָ באָצוואַנאַ Pula צו יו באָצוואַנאַ Pula צו ביטקאָין באָצוואַנאַ Pula צו יואַן באָצוואַנאַ Pula צו יען

יעדער אַדרעס קענען פאָרויסזאָגן פֿאַר 30 challenges אַ מינוט (אַ IPv6 address counts as its whole /64). Requests whose address is not known share a stricter 10 per minute, and there is a overall cap on the challenges Nymbot issues across all addresses; a request rejected before a challenge is made (למשל, with a body that is not valid JSON) does not count towards it. 429 און Retry-Afterאון דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, דעריבער, און דעריבער. Content-Type אין application/json און multipart/form-data כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין. 415 לעולם אין די מעשה.

מאַרעדינגס זענען פּרייסיד פון אַ יקספּערימענט פון די טאָקאַנץ אין די ינטע, מיט אַ 1.5× מאַרעדינג, אַזאַ ווי די ראַקטיוו קאָנטראָל איז נאָר געפֿינען נאָך. You pay for the tokens actually used, and the unused part of the payment comes back as a באַקומען טאָקיין.

באַקומען באַקומען Payment

באַקומען אַ פאַרווודיק אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּערייטינג אַפּעריי

מערכותאון Header
און 402Authorization: L402 <macaroon>:<preimage> (LSAT און א מעשה)
תשלוםAuthorization: Payment <base64url JSON>וואס איז JSON? {"challenge": {every parameter of the challenge, as sent}, "payload": {"preimage": "<hex>"}}

אַ פאַקטיש באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג באַהאַנדלונג nymbot אין אַוועקלייגן אין אַוועקלייגן: {"payment": "l402", "tier": "pro", "paid_sats": 237, "charged_sats": 237}און אין X-Nymbot-Balance-Sats עס איז געפירט מיט די באַזוכן צו באַזוכן. Payment-Receipt אַוועקלייגן (base64url JSON with the challenge id, די פּאַרטייז אַוועקלייגן) reference, status און timestampPayout requests are not bound to any nym, so they don't appear in the query history.

סטאַטןאיך
402 payment_already_usedיעדער באַצאָלונג באַצאָלן פֿאַר אַ פאָרשונג. The answer is a new challenge for this request, so a client that caches its last credential (as lnget און פשוט נישט שוב.
402 payment_mismatchאון מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט! Content-Type או גופו, או לשלם פחות ווי דעם בקשה נייַעס. A fresh challenge for this request comes with it; if the payment was too small, what you paid comes back as a reward. באַקומען טאָקיין (refund_token און refund_sats אויף די גוף)
402 payment_expiredמער ווי 15 מינוט געפֿונען פון די יטע. A fresh challenge comes with it. If the preimage shows you paid, what you paid comes back as a reward. באַקומען טאָקיין (refund_token און refund_sats כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.
401 invalid_preimageדי פּרימאַמינג אין hash to the invoice's payment hash. The payment is not used up.
401 invalid_payment_credentialדי קרעדינאַל איז מאַלפאָרמאַט, איז געניצט נאָך נימבאָט געניצט עס, אָדער געניצט אַ באַצאָלונג הייש Nymbot never issued an invoice for. A macaroon with a caveat Nymbot does not know, or with conflicting caveats, is rejected.
429 rate_limit_exceededמער ווי 30 credentials or keys that failed to verify came from this address in a minute, or one refund token was sent more than 60 times in a minute. 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"));

קענסט געגרינדעט אויף mppx מיט אַ Lightning מעטהאָדס באַהאַנדלונג די Payment challenge עצמאותן; פּינק אותם אין די סוף פּינט און לייענען זיי באַקומען.

וידאו

און משולם POST /videos תשובה 202 כ'האף די ווען (מיטן דרייווער) זאלן זיין. status_url: GET עס איז געגרינדעט און אַרבעט פֿאַר 24 שעה, אַזאַ ווי די אַרבעט איז געגרינדעט.

{
  "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..."
  }
}

ער האט refund_token עס איז געווען א באקאנטע טעלעפאָנירן, און א באקאנטע טעלעפאָנירן (GET /api/v1/l402/refunds תשובה "status": "pending"און מיך [חלילה, נישט מיך - איך מיין די רעכטע] אויך נישט! refund_sats פֿאַר אַ רעפּענדיקטע אַרבעט but never the token, so sharing the status URL does not share the refund. Checking the token also settles a failed job that no one polled.

אַוועקלייגן

If a paid request fails and the provider invoiced Nymbot for the attempt, the payment is retained and the error says so, with the error. charged_satsאיך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב איך האָב באַקומען טאָקיין ער איז די משולם:

{
  "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"
  }
}

אין געניצט פּאַרטייז געניצט באותו צורה: if you asked for two pictures and one failed unfaced, the success response's nymbot א אובייקט האָבן אַ ראַפאָד טאָקיין פֿאַר די מייַכן; אַ טרנספּריסיפאָד whose length could not be read up front is priced for as long as the file could be (never more than 30 minutes), and the difference to the real length comes back as a refund token; if it turns out to be longer than 30 minutes, it is refused with 413 און עס איז געווען א טעלעפאָנירן געשעפט, און עס איז געווען א טעלעפאָנירן געשעפט, און א טעלעפאָנירן געשעפט.

A refund token is a random 256-bit code. Nymbot stores only its hash, and it expires after 30 days. It holds a sat balance, און איר קענען:

  • באַצאָלן מיט עס. לייענען Authorization: Bearer REFUND-… כ'האף די ווען (מיטן דרייווער) זאלן מארך ימים זיין.refund_token_sats אין די nymbot אַ טאָקן ווערט מער ווי די ביקוע ענטפער. 402 refund_insufficientעס איז געווען א טעמפּעראַטור אין די טעמפּעראַטור.
  • איז עס. GET /api/v1/l402/refunds און באהאלטענער נעמט א באהבה חזרה {"sats": 237, "status": "open", "expires_at": "..."}.
  • אַ טאָקאָין קענען זיין נוצן אין אַקסימום 60 טעג פּער מינוט.
  • ער איז געווען א נימ. געפירט דעם באַקומען אַ מתנה אין די אַפּ, או Call POST /api/v1/l402/refunds/redeem און א דרישה צו און {"refund_token": "REFUND-...", "balance": "standard"} און "pro"כ'האף די קרעדיטעס זענען באקומען צו דער סאַלאַגן (10 sats each on standard, 100 on Pro); sats that don't make a whole credit stay on the token for API requests.

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"

תגובה

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