నాలెడ్జ్ బేస్ డెవలపర్లు
బ్యాలెన్స్, టాప్-అప్స్ మరియు కీలు
మీ వద్ద ఏముందో తనిఖీ చేయండి, Lightning ద్వారా టాప్ అప్ చేయండి, మీ స్వంత వాలెట్ నుండి ఆటోమేటిక్గా టాప్ అప్ చేయండి, ప్రతి రిక్వెస్ట్ ఎంత ఖర్చవుతుందో చూడండి మరియు కోడ్ నుండి కీలను నిర్వహించండి.
ఈ పేజీ సౌలభ్యం కోసం యంత్రంతో అనువదించబడింది. ఆంగ్ల అసలైనది వర్తించే సంస్కరణ.
సంతులనం తనిఖీ
మీ ఇద్దరి బ్యాలెన్స్లు, మరియు ఈ కీ యొక్క సామర్థ్యంలో ఎంత వాడబడింది.
GET https://nymbot.ai/api/v1/credits/balance - ఒక API కీ అవసరం. POST ఇది ఆశించే ఖాతాదారులకు కూడా పనిచేస్తుంది.
balance ప్రస్తుత బిట్కాయిన్ ధర వద్ద డాలర్లలో రెండు బ్యాలెన్స్లు కలిసి ఉన్నాయా, ఒకే సంఖ్యను ఆశించే సాధనాల కోసం (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);
చెల్లింపు పద్ధతులు
మీరు ఎలా టాప్ అప్ చేయవచ్చు మరియు వాటి పరిమితులు ఏమిటి. లైట్నింగ్ (Lightning) మాత్రమే ఏకైక పద్ధతి.
GET https://nymbot.ai/api/v1/topup/payment-methods - కీ అవసరం లేదు.
ఒక టాప్-అప్ 10 నుండి 1,000,000 సాట్స్ వరకు ఉంటుంది; ఒక ప్రో టాప్-అప్ కనీసం ఒక ప్రో క్రెడిట్ను కొనుగోలు చేయాలి, కాబట్టి ఇది 100 సాట్స్ వద్ద ప్రారంభమవుతుంది. డాలర్ పరిమితులు బిట్కాయిన్ ధరను అనుసరిస్తాయి. bulk_bonus యాప్లో ఉన్నట్లే పెద్ద టాప్-అప్లపై అదనపు క్రెడిట్ను జాబితా చేస్తుందిః 500,1,000 లేదా 5,000 సాట్ల నుండి ప్రామాణిక టాప్-అప్లపై 10 శాతం, 15 శాతం లేదా 20 శాతం ఎక్కువ, మరియు 5,000,10,000 లేదా 50,000 సాట్ల నుండి ప్రో టాప్-అప్లపై.
ప్రతిస్పందన
{
"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);
మెరుపు మీద పైకి ఎక్కడం
మెరుపు ఇన్వాయిస్ తయారు చేస్తుంది, ఇది కీకి చెందిన నిమ్కు క్రెడిట్ను జోడిస్తుంది. ఏదైనా మెరుపు వాలెట్ నుండి చెల్లించండి, అప్పుడు తనిఖీ చేయండి క్రెడిట్ జోడించడానికి.
POST https://nymbot.ai/api/v1/topup/create/btc-lightning - ఒక API కీ అవసరం.
| ఫీల్డ్ | రకం | అవసరమైనది | వివరణ |
|---|---|---|---|
amount | సంఖ్య | అవును | ఎంత, లో currencysats కోసం ఒక సంపూర్ణ సంఖ్య. |
currency | స్ట్రింగ్ | లేదు | SATS (డిఫాల్ట్), USD లేదా BTCడాలర్లు ప్రస్తుత బిట్కాయిన్ ధర వద్ద మార్చబడతాయి. |
tier | స్ట్రింగ్ | లేదు | pro (డిఫాల్ట్) లేదా standard: క్రెడిట్ సంతులనం దేనికి వెళుతుంది. |
ఒక ప్రామాణిక క్రెడిట్ 10 సాట్స్ మరియు ఒక ప్రో క్రెడిట్ 100 సాట్స్, ఇంకా ఏదైనా భారీ బోనస్;
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), పైన 1,000,000 సాట్స్ (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);
టాప్-అప్ తనిఖీ చేయడం
ఇన్వాయిస్ చెల్లించబడిందా అని అడిగి, దాన్ని కలిగి ఉన్న తర్వాత, క్రెడిట్ను జోడిస్తుంది. చెకింగ్ అంటే అది క్రెడిట్ అవుతుందా అని, కాబట్టి చెల్లించిన తర్వాత, స్టేటస్ వచ్చే వరకు తనిఖీ చేయండి. creditedఆ తర్వాత మళ్లీ తనిఖీ చేయడం సురక్షితంః మీరు ఎన్నిసార్లు అడిగినా క్రెడిట్ ఒకసారి వస్తుంది.
GET https://nymbot.ai/api/v1/topup/status/{invoice_id} — ఇన్వాయిస్ను రూపొందించిన nym నుండి ఒక కీ అవసరం.
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 | ఐడి అనేది క్రియేట్ కాల్ నుండి వచ్చిన 64-అక్షరాల ఐడి కాదు. |
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);
ప్రశ్నల చరిత్ర
ప్రతి అభ్యర్థనకు ఒక వరుసః అది ఏమిటి, ఏ నమూనా, ఎన్ని టోకెన్లు మరియు దాని ధర ఎంత. ఎటువంటి ప్రాంప్ట్లు లేదా సమాధానాలు ఉంచబడవు, కాబట్టి ఏదీ తిరిగి ఇవ్వబడవు. వరుసలు 90 రోజుల పాటు ఉంచబడతాయి, మొదట సరికొత్తవి. దాని పరిమితికి చేరుకున్న కీ ఇప్పటికీ దాని చరిత్రను చదవగలదు.
GET https://nymbot.ai/api/v1/queries/history - దాని స్వంత అభ్యర్థనలను చూసే API కీ అవసరం, లేదా సంతకం చేసిన అభ్యర్థన మీ ఎన్ఐఎమ్ నుండి, ఇది ప్రతి కీని చూస్తుంది.
| ఫీల్డ్ | రకం | అవసరమైనది | వివరణ |
|---|---|---|---|
page | పూర్ణాంకం (ప్రశ్న) | లేదు | డిఫాల్ట్గా 1, గరిష్టంగా 1,000; అంతకంటే ఎక్కువ పేజీ ialah 400 invalid_value. |
page_count | పూర్ణాంకం (ప్రశ్న) | లేదు | ప్రతి పేజీకి వరుసలు. డిఫాల్ట్ 20, గరిష్టంగా 100. |
start_dateend_date | స్ట్రింగ్ (ప్రశ్న) | లేదు | ఐఎస్ఓ 8601 తేదీలు లేదా సమయాలు. |
model | స్ట్రింగ్ (ప్రశ్న) | లేదు | ఈ నమూనా మాత్రమే. |
type | స్ట్రింగ్ (ప్రశ్న) | లేదు | chat, responses, messages, image, video, speech, transcription లేదా embedding. |
all_keys | బూలియన్ (ప్రశ్న) | లేదు | ఒక కీతో: true అదే పేరు కలిగిన ప్రతి కీని కలిగి ఉంటుంది. డిఫాల్ట్ false. |
key_id | స్ట్రింగ్ (ప్రశ్న) | లేదు | సంతకం చేసిన అభ్యర్థనతో, లేదా 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);
ఖాతా అభ్యర్థనలపై సంతకం చేయడం
కీలను సృష్టించడం, మార్చడం మరియు రద్దు చేయడం, ఖాతా సారాంశం (account summary) మరియు ఆటోమేటిక్ టాప్-అప్లకు API కీ అవసరం లేదు. వాటికి మీ nym నుండి ఒక సంతకం (signature) అవసరం, కాబట్టి లీక్ అయిన కీ దాని పరిమితి (cap) వరకు ఖర్చు చేయగలదు కానీ మరే ఇతర కీని సృష్టించలేదు లేదా దాని స్వంత పరిమితిని పెంచుకోలేదు.
అనువర్తనం మీ కోసం ఇలా చేస్తుందిః దానిలోని ప్రతిదీ API షీట్ ఈ ముగింపు బిందువులను ఉపయోగిస్తుంది. మీ స్వంత కోడ్ నుండి కీలను నిర్వహించడానికి మీకు ఈ విభాగం మాత్రమే అవసరం.
The signature is a Nostr event of kind 27235 (NIP-98), sent base64-encoded 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 సెకన్లలోపు ఉండాలి.- ప్రతి సంఘటన ఒకసారి పనిచేస్తుంది, a
GETచేర్చబడింది, కాబట్టి క్యాప్చర్ చేసిన హెడర్ను రీప్లే చేయలేము. ప్రతి రిక్వెస్ట్కు కొత్త దానిని సంతకం చేయండి. ఒకదాన్ని జోడించండిnonceయాదృచ్ఛిక విలువతో ట్యాగ్ చేయండి కాబట్టి ఒకే సెకనులో సంతకం చేసిన రెండు అభ్యర్థనలు ఇప్పటికీ భిన్నంగా ఉంటాయి. - సంతకం చేసిన అభ్యర్థన యొక్క ప్రధాన భాగం గరిష్టంగా 64 కెబి కావచ్చు, మరియు ఒక శరీరానికి అవసరాలు ఉంటాయి.
Content-Type: application/json.
ఒక తప్పిపోయిన ఈవెంట్ తిరిగి వస్తుంది 401 missing_nostr_auth; సరిగ్గా లేనిది, తప్పుగా సంతకం చేయబడినది, చాలా పాతది, లేదా వేరే URL, పద్ధతి లేదా బాడీ కోసం ఉంటే అది తిరిగి ఇస్తుంది
invalid_nostr_auth, సందేశంలోని కారణంతో; తిరిగి ఉపయోగించినది తిరిగి వస్తుంది
nostr_auth_replayed. ఈ ఎండ్ పాయింట్లకు పంపిన API కీ తిరస్కరించబడుతుంది. బాడీ చదవడానికి ముందు సంతకం తనిఖీ చేయబడుతుంది, మరియు ప్రతి చిరునామా నిమిషానికి 30 సార్లు విఫలమవుతుంది (ఒక IPv6 చిరునామా దాని మొత్తం/64 గా లెక్కించబడుతుంది); ఆ తరువాత అది వస్తుంది. 429 తో
Retry-After.
బ్రౌజర్లు ఈ ఎండ్పాయింట్లను Nymbot యొక్క స్వంత సైట్ల నుండి మాత్రమే పిలవగలవు (https://nymbot.ai,
https://nymchat.app మరియు వాటి ఉప డొమైన్లు). మరే ఇతర సైట్లోని ఒక పేజీకి కోర్స్ శీర్షికలు తిరిగి లభించవు, కాబట్టి వారు తిరిగి ఇచ్చే వాటిని చదవలేరు. స్క్రిప్ట్స్ మరియు స్థానిక అనువర్తనాలు, అవి ఏ సందేశాన్ని పంపవు
Origin, ప్రభావితం కావు.
సంతకం చేయడానికి మీ నిమ్ యొక్క రహస్య కీ అవసరం ( nsec), ఇది అన్నింటినీ నియంత్రిస్తుంది: మీ గుర్తింపు, మీ చరిత్ర మరియు మీ బ్యాలెన్స్. దీనిని మీరు నమ్మే మెషీన్లోని స్క్రిప్ట్లో మాత్రమే ఉంచండి, ఫైల్లోకి వ్రాయడం కంటే ఎన్విరాన్మెంట్ (environment) నుండి చదవడం చేయండి, మరియు సాధ్యమైనప్పుడు యాప్కే ప్రాధాన్యత ఇవ్వండి.
ఈ సహాయకులు శీర్షికను నిర్మిస్తారు. ఈ పేజీలోని తరువాతి ఉదాహరణలు వాటిని ఉపయోగిస్తాయి. వారు హెక్స్లో రహస్య కీని చదువుతారు NOSTR_SECRET_HEXcURL ఒకటి ఉపయోగిస్తుంది
నక్ కమాండ్-లైన్ టూల్, ఇది nsec లేదా hex
కీని తీసుకుంటుంది, మరియు 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");
}
ఖాతా సారాంశం
యాప్ యొక్క API షీట్ పైన ఏమి చూపుతుంది అంటే: మీ పబ్లిక్ కీ, రెండు బ్యాలెన్స్లు, ఎన్ని కీలు
యాక్టివ్గా ఉన్నాయో (రద్దు చేయబడలేదు లేదా గడువు ముగియలేదు), మరియు ఆటోమేటిక్ టాప్-అప్ సెట్టింగులు, లేదా
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());
కీలను నిర్వహించడం
అనువర్తనం యొక్క ముఖ్య జాబితా వెనుక ఉన్న ముగింపు బిందువులు. వాటన్నింటికీ ఒక అవసరం ఉంది సంతకం చేసిన అభ్యర్థనప్రతి కీ ఈ రూపంలో తిరిగి ఇవ్వబడుతుంది, ISO 8601 లో సమయాలు మరియు సాట్స్ లో మొత్తాలుః
కీలక అంశం
{
"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 ఒక కీని గుర్తించడానికి సరిపోతుంది కానీ దాన్ని ఉపయోగించడానికి కాదు. కీని తయారు చేసినప్పుడు అది ఒక్కసారి మాత్రమే తిరిగి వస్తుంది.
జాబితా కీలు
GET https://nymbot.ai/api/v1/keys - సంతకం చేశారు.
| ఫీల్డ్ | రకం | అవసరమైనది | వివరణ |
|---|---|---|---|
include_revoked | బూలియన్ (ప్రశ్న) | లేదు | తీసివేసిన కీలను చేర్చండి. అప్రమేయంగా 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 | స్ట్రింగ్ | అవును | 1 నుండి 40 అక్షరాలు, మీ ఇతర క్రియాశీల కీలకు భిన్నంగా ఉంటాయి (కేసును విస్మరించడం). |
limit_sats | పూర్ణాంకం | లేదు | ఖర్చు పరిమితి, కనీసం 1. పరిమితి లేకుండా వదిలివేయండి. |
reset_period | స్ట్రింగ్ | లేదు | daily, weekly లేదా monthly. అవసరాలు. limit_satsదాన్ని ఎప్పటికీ రీసెట్ చేయని టోపీ కోసం వదిలివేయండి. |
expire_at | స్ట్రింగ్ లేదా పూర్ణాంకం | లేదు | కీ పనిచేయడం ఆగిపోయినప్పుడుః ఒక 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); కనీసం 1 మొత్తం సంఖ్య లేని క్యాప్; క్యాప్ లేకుండా రీసెట్ వ్యవధి; గతంలో గడువు ముగిసింది; తెలియని ఫీల్డ్ (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 మీ వద్ద ఉన్న ఏ కీ (key) కి కూడా ఆ ఐడి (id) లేకపోతే.
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ఇప్పటికే రద్దు చేయబడిన కీని ఉపసంహరించుకోవడం అదే విధంగా సమాధానం ఇస్తుంది. రద్దు చేయబడిన కొత్త 50 కీలు మాత్రమే ఉంచబడతాయి; మరొక కీని ఉపసంహరించుకున్నప్పుడు పాతవి తొలగించబడతాయి.
ప్రతిస్పందన
{ "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());
ఎన్. డబ్ల్యు. సి. ఆటో-టాప్-అప్
Connect a 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 the settings; if a payment went through after an error, checking its invoice with టాప్-అప్ స్థితి దానికి క్రెడిట్ ఇస్తుంది.
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 you chose. The wallet has to support pay_invoice.
వాలెట్ను అనుసంధానిస్తోంది
POST https://nymbot.ai/api/v1/nwc-auto-topup/connect - సంతకం చేశారు.
| ఫీల్డ్ | రకం | అవసరమైనది | వివరణ |
|---|---|---|---|
nwc_url | స్ట్రింగ్ | అవును | కనెక్షన్ స్ట్రింగ్, ప్రారంభం nostr+walletconnect://. Nymbot asks the wallet for get_info దానిని సేవ్ చేసే ముందు, దానిని ఎన్క్రిప్ట్ చేసి నిల్వ చేయండి. |
threshold_sats | పూర్ణాంకం | అవును | బ్యాలెన్స్ ఇంత సాట్స్ కంటే తక్కువగా ఉన్నప్పుడు టాప్ అప్ చేయండి. కనీసం 1,000. |
topup_sats | పూర్ణాంకం | అవును | ప్రతిసారీ ఎంత జోడించాలి. 1,000 నుండి 1,000,000 సాట్స్. |
tier | స్ట్రింగ్ | లేదు | 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). ఇదే మిగిలిన రెండు ఎండ్పాయింట్లకు కూడా వర్తిస్తుంది. |
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());
సెట్టింగ్లను చదువుతోంది
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());
కీ లేకుండా అభ్యర్థనకు చెల్లింపు
ఫిక్స్డ్-ప్రైస్ ఎండ్ పాయింట్లను ఒక సమయంలో ఒక అభ్యర్థనకు మెరుపు ద్వారా చెల్లించవచ్చు, కీ లేకుండా, ఖాతా లేకుండా మరియు బ్యాలెన్స్ లేకుండాః POST /images/generations, POST /images/edits,
POST /videos, POST /audio/speech, POST /audio/transcriptions,
POST /audio/translations మరియు POST /embeddings. చాట్, ప్రతిస్పందనలు మరియు సందేశాలకు ఎల్లప్పుడూ కీ అవసరం. కీని కలిగి ఉన్న అభ్యర్థన ఎప్పటిలాగే బ్యాలెన్స్కు బిల్ చేయబడుతుంది; కీ పంపనప్పుడు మాత్రమే చెల్లింపు ప్రవాహం ప్రారంభమవుతుంది.
Nymbot speaks two versions of the same idea, from one backend: Lightning Labs'
L402 (దాని పాత పేరుతో కూడా ఆమోదించబడింది, LSAT) మరియు ఐ. ఇ. టి. ఎఫ్. ముసాయిదా
చెల్లింపు HTTP ప్రామాణీకరణ విధానం యొక్క lightning పద్ధతి మరియు
charge ఉద్దేశం. మీ క్లయింట్ అర్థం చేసుకున్న దాన్ని ఉపయోగించండి.
కీ లేకుండా చెల్లింపు చేయడం అనేది ఎప్పుడు మాత్రమే అందుబాటులో ఉంటుంది API_L402_SECRET కనీసం 32 రాండమ్ బైట్లులను కలిగి ఉంటుంది, హెక్స్ (64 అక్షరాలు) లేదా base64 (44) రూపంలో. దీనితో ఒకటి చేయండి openssl rand -hex 32చిన్నది లేదా ఊహించదగిన విలువ ఫీచర్ను ఆపివేస్తుంది మరియు ఎందుకు అలా జరిగిందో నమోదు చేస్తుంది. దానిని మార్చడానికి (rotate), పాత విలువను ఇక్కడికి మార్చండి API_L402_SECRET_PREVIOUS ఒక రోజు కోసంః ఆధారాలు, స్థితి URL లు మరియు దాని కింద చేసిన సవాళ్లు గడువు ముగిసే వరకు పనిచేస్తూనే ఉంటాయి.
ఛాలెంజ్
అవసరం లేకుండా అభ్యర్థనను పంపండి Authorization header. అది చెల్లుబాటు అయ్యేదైతే, ఏదీ అమలు కాదు, మరియు
మీకు లభిస్తుంది 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 పారామీటర్ బేస్64 యుఆర్ఎల్ జెఎస్ఓఎన్ః
{"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.
ఒక సవాలు ముగింపు బిందువుకు కట్టుబడి ఉంటుంది, Content-Type (దాని మీడియా రకం మరియు, మల్టిపార్ట్ కోసం, దాని సరిహద్దు) మరియు మీరు పంపిన ఖచ్చితమైన బాడీ బైట్ల SHA-256 కు, మరియు 15 నిమిషాల పాటు ఉంటుంది. చెల్లించిన తర్వాత, పంపండి ఒకేలా ఉంటుంది. మళ్లీ అభ్యర్థించు: అదేది
Content-Type మరియు అదే JSON బైట్లు, లేదా మల్టీపార్ట్ ఎండ్పాయింట్ల కోసం
(/images/edits, /audio/transcriptions, /audio/translations) ఒకే సరిహద్దుతో ఒకే బహుళ భాగాలు. చాలా HTTP లైబ్రరీలు ఒక ఫారమ్ను ఎన్కోడ్ చేసిన ప్రతిసారీ కొత్త సరిహద్దును ఎంచుకుంటాయి, కాబట్టి దానిని ఒకసారి ఎన్కోడ్ చేసి, ఆ బైట్లను రెండుసార్లు పంపండి.
ప్రతి చిరునామా నిమిషానికి 30 సవాళ్లను అడగవచ్చు (ఒక IPv6 చిరునామా దాని పూర్తి /64 గా పరిగణించబడుతుంది).
తెలియని చిరునామా కలిగిన అభ్యర్థనలకు నిమిషానికి 10 సవాళ్లనే కఠినమైన పరిమితి ఉంటుంది, మరియు అన్ని చిరునామాలపై Nymbot జారీ చేసే సవాళ్లపై మొత్తం పరిమితి ఉంటుంది; సవాలు చేయకముందే తిరస్కరించబడిన అభ్యర్థన (ఉదాహరణకు చెల్లుబాటు అయ్యే JSON కాని బాడీతో) దాని పరిమితిలోకి రాదు. అంతకు మించి సమాధానం ఏమిటంటే 429 తో Retry-Afterబాడీ చదవడం కంటే ముందే పంపబడింది. కీ లేదా క్రెడెన్షియల్ లేకుండా పిలవబడిన పెయిడ్ ఎండ్పాయింట్లు కూడా ప్రతి అడ్రస్ కు నిమిషానికి 120 అన్అథెంటికేటెడ్ రిక్వెస్ట్ల సాధారణ పరిమితిలోకి వస్తాయి. బాడీని చదగడానికి ముందే క్రెడెన్షియల్ను తనిఖీ చేస్తారు, మరియు ఒక రిక్వెస్ట్ Whose Content-Type కాదు application/json (లేదా
multipart/form-data అప్లోడ్ల కోసం) అనేది దీనితో తిరస్కరించబడింది 415 మరియు ఎప్పుడూ
ఇన్వాయిస్ రాదు.
ఎంబెడింగ్లు ఇన్పుట్లోని టోకెన్ల అంచనా నుండి ధర నిర్ణయించబడతాయి, ఎందుకంటే వాస్తవ గణన తరువాత మాత్రమే తెలుస్తుంది. మీరు వాస్తవానికి ఉపయోగించిన టోకెన్లకు చెల్లిస్తారు, మరియు చెల్లింపులో ఉపయోగించని భాగం తిరిగి వస్తుంది రీఫండ్ టోకెన్.
చెల్లింపు పంపడం
ఏదైనా మెరుపు వాలెట్తో ఇన్వాయిస్ చెల్లించండి. వాలెట్ మీకు 64 హెక్స్ అక్షరాల ప్రీమేజ్ ఇస్తుంది. ఆపై వీటిలో ఒకదానితో అదే అభ్యర్థనను పంపండిః
| పథకం | శీర్షిక |
|---|---|
| L402 | Authorization: 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 హెడర్ (బేస్64 యుఆర్ఎల్ జెఎస్ఓఎన్ ఛాలెంజ్ ఐడితో, చెల్లింపు హాష్ ఇలా reference, status మరియు
timestamp). చెల్లించిన అభ్యర్థలు ఏ నిమ్ (nym) తోనూ అనుసంధానించబడవు, కాబట్టి అవి క్వెరీ హిస్టరీలో కనిపించవు.
| స్థితి | ఎప్పుడు? |
|---|---|
402 payment_already_used | ప్రతి చెల్లింపు ఒక అభ్యర్థన కోసం చెల్లిస్తుంది. ప్రతిస్పందన ఈ అభ్యర్థన కోసం ఒక కొత్త సవాలు, కాబట్టి తన చివరి క్రెడెన్షియల్ను క్యాష్ చేసుకునే క్లయింట్ (as lnget చేస్తుంది) కేవలం మళ్ళీ చెల్లిస్తుంది. |
402 payment_mismatch | క్రెడెన్షియల్ మరొక ఎండ్ పాయింట్ కోసం జారీ చేయబడింది, Content-Type లేదా బాడీ, లేదా ఈ అభ్యర్థన కంటే తక్కువ చెల్లించడం ఇప్పుడు ఖర్చవుతుంది. ఈ అభ్యర్థన కోసం ఒక కొత్త సవాలు దానితో వస్తుంది; చెల్లింపు చాలా తక్కువగా ఉంటే, మీరు చెల్లించినది తిరిగి వస్తుంది రీఫండ్ టోకెన్ (refund_token మరియు refund_sats శరీరంలో (in the body). |
402 payment_expired | సవాలు నుండి 15 నిమిషాల కంటే ఎక్కువ సమయం గడిచింది. దానితో పాటు ఒక కొత్త సవాలు వస్తుంది. ఒకవేళ preimage మీరు చెల్లించినట్లు చూపిస్తే, మీరు చెల్లించినది ఒక రీఫండ్ టోకెన్ (refund_token మరియు refund_sats శరీరంలో), ఒకసారి; క్రెడెన్షియల్ అప్పుడు ఉపయోగించబడుతుంది. |
401 invalid_preimage | ప్రీఇమేజ్ (preimage) ఇన్వాయిస్ యొక్క పేమెంట్ హాష్కి సమానంగా లేదు. పేమెంట్ ఇంకా వాడబడలేదు. |
401 invalid_payment_credential | దొరకబడిన ఆధారాలు (credential) తప్పుగా ఉన్నాయి, Nymbot వాటిని జారీ చేసిన తర్వాత మార్చబడ్డాయి, లేదా Nymbot ఎప్పుడూ ఇన్వాయిస్ను జారీ చేయని పేమెంట్ హాష్ను సూచిస్తున్నాయి. Nymbotకు తెలియని లేదా పరస్పర విరుద్ధమైన షరతులతో (caveats) ఉన్న మాకరూన్ (macaroon) తిరస్కరించబడుతుంది. |
429 rate_limit_exceeded | ఒక నిమిషంలో ఈ చిరునామా నుండి 30 కంటే ఎక్కువ క్రెడెన్షియల్స్ లేదా కీలు ధృవీకరణలో విఫలమయ్యాయి, లేదా ఒక రీఫండ్ టోకెన్ నిమిషానికి 60 సార్ల కంటే ఎక్కువ సార్లు పంపబడింది. వేచి ఉండండి 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 పద్ధతితో పేమెంట్ సవాలును వారే ఎదుర్కోవాలి; వారిని ఎండ్పాయింట్ వైపు నడిపించి వారు చెల్లించనివ్వండి.
వీడియోలు
చెల్లించిన 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");
ఒకవేళ render unbilled గా విఫలమైతే, చెల్లింపు దానిపై పడుతుంది. స్టేటస్ URL ఇలా చూపిస్తుంది
refund_sats తిరిగి చెల్లించిన ఉద్యోగం కోసం కానీ ఎప్పుడూ టోకెన్ కాదు, కాబట్టి స్థితి URL ను పంచుకోవడం అనేది తిరిగి చెల్లింపును పంచుకోదు. టోకెన్ను తనిఖీ చేయడం అనేది ఎవరూ పోల్ చేయని విఫలమైన పనిని కూడా పరిష్కరిస్తుంది.
తిరిగి చెల్లింపులు
If a paid request fails and the provider billed Nymbot for the attempt, the payment is kept and
the error says so, with 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"
}
}
ఉపయోగించని భాగాలు అదే విధంగా తిరిగి వస్తాయిః మీరు రెండు చిత్రాలను అడిగితే మరియు ఒకటి చెల్లించకుండా విఫలమైతే, విజయవంతమైన ప్రతిస్పందన nymbot వస్తువు తప్పిపోయినదానికి రీఫండ్ టోకెన్ను కలిగి ఉంటుంది; దీని పొడవును ముందు చదవలేని ట్రాన్స్క్రిప్షన్ ఫైల్ యొక్క పొడవైన ధర (ఎప్పుడూ 30 నిమిషాల కంటే ఎక్కువ కాదు), మరియు నిజమైన పొడవుకు వ్యత్యాసం రీఫండ్ టోకెన్గా తిరిగి వస్తుంది; అది 30 నిమిషాల కంటే ఎక్కువ అని తేలితే, దానితో తిరస్కరించబడుతుంది 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, and you can:
- దానితో చెల్లించండి. పంపండి.
Authorization: Bearer REFUND-…పైన పేర్కొన్న ఏదైనా ఎండ్ పాయింట్లపై (ఓపెన్ఏఐ ఎస్డీకే దానిని దాని ఏపీఐ కీగా తీసుకుంటుంది). ధర టోకెన్ నుండి వస్తుంది మరియు మిగిలి ఉన్నది దానిపైనే ఉంటుంది (refund_token_satsలోnymbotవస్తువు). అభ్యర్థన సమాధానాల కంటే తక్కువ విలువ గల టోకెన్402refund_insufficientబిల్ చేయని వైఫల్యం సాట్లను తిరిగి అదే టోకెన్లో ఉంచుతుంది. - దీన్ని తనిఖీ చేయండి.
GET /api/v1/l402/refundsఅదే శీర్షికతో తిరిగి వస్తుంది{"sats": 237, "status": "open", "expires_at": "..."}. - ఒక టోకెన్ను నిమిషానికి గరిష్టంగా 60 సార్లు ఉపయోగించవచ్చు.
- దానిని ఒక నిమ్ కు తరలించండి. దాన్ని అతికించండి బహుమతిని రిడీమ్ చేయండి in the
Nymbot app, or call
POST /api/v1/l402/refunds/redeemఎ తో సంతకం చేసిన అభ్యర్థన మరియు{"refund_token": "REFUND-...", "balance": "standard"}(లేదా"pro"). మొత్తం క్రెడిట్లు బ్యాలెన్స్కు వెళ్తాయి (ప్రామాణికంగా 10 సాట్లు, ప్రో మీద 100); మొత్తం క్రెడిట్ చేయని సాట్లు API అభ్యర్థనల కోసం టోకెన్లో ఉంటాయి.
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 } }