Te turanga matauranga Kaiwhakawhanake
Tāpaenga, whakakāinga, me ngā kī
Tirohia tō mea kei te pai, whakakī moni mā te Lightning, whakakī moni i te mea tonu i roto i tō kete moni, kite i te utu o ia tono, me te whakahaere i ngā tuhinga matua i te kōti.
He mihini tenei wharangi kia pai ai. Ko te reo Ingarihi taketake te putanga e tika ana.
E tiro ana i te tauira me te tūtohu mō te tauira i te akomanga.
Ko tō kōrua ingoa mōrearea katoa, me te nui o te kapa o tēnei tuāhua kua whakamahia.
GET https://nymbot.ai/api/v1/credits/balance — me he kupu raihirangi API. POST ka mahi hoki, mō ngā kaiwhakahaere e tūmanako ana i tēnā.
balance he whaihua rānei ngā tauira e rua katoa i roto i ngā tārau i te utu o Bitcoin i tēnei wā, mō
ngā taputai e tatari ana i tētahi tau kotahi (null ki te kore e taea te pānui i te utu). Ko te toetoe kei roto i ngā kōtieti me ngā sats, koinei te tikanga e pupuri ai i ngā tauira moni. key whakaatu ana i te tae
i pātai ai. He tae kua tae ki tōna tapu e taea tonu te tirotiro i te tauira.
Whakaaronga
{
"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"
}
}
| Tikanga Matua | Ahihi |
|---|---|
401 | Kua ngaro te tuau, he kore e mōhiotia, kua whakakorehia rānei, kua muta rānei te wā. |
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);
Ngā huarahi utu
Me pēhea e taea ai te whakataki ake, me ngā rārangi watea. Ko Lightning te tikanga kotahi anake.
GET https://nymbot.ai/api/v1/topup/payment-methods — kāore he kī e hiahiatia ana.
He whakakāinga katoa he 10 ki te 1,000,000 sats; he rerekē te whakakāhenga Pro me te hoko i tētahi tīpako Pro kia iti nhất, nō reira ka tīmata
i te 100 sats. Ko ngā taumata tāra e whai ana i te utu o te Bitcoin. bulk_bonus whakaaturia ngā tohu extra
credit i ngā top-up nui ake, pēnei i te app: 10%, 15% rānei ko te 20% kaha ake i ngā top-up ā-noa mai i
500, 1,000, te 5,000 rānei sats, ā, i ngā top-up Pro mai i te 5,000, 10,000, te 50,000 rānei sats.
Whakaaronga
{
"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);
Whakakapi i runga i a Lightning
Ka hangaia he invoice Lightning e whakakapi ana i te credit ki te nym e noho ana te wiki ki ia, Whakaiti i tēnā mai i tētahi wallet Lightning katoa, ka whakamutunga titiro kia kite kia whakatūpato te pūtea.
POST https://nymbot.ai/api/v1/topup/create/btc-lightning — me he kupu raihirangi API.
| Papa | Mahere | Kia hiahiatia ana | Whakaahua |
|---|---|---|---|
amount | tau | Ae | He aha te nui, i roto i currency. He tauira katoa mō ngā sats. |
currency | kōpaka | Kāore | SATS (te tirohanga matua), USD kei te mea anō BTC. Ka huri ngā raihara ki te utu Bitcoin o te wā nei. |
tier | kōpaka | Kāore | pro (te tūtohu) rānei standard: kei hea te tauira e haere ana te tairongo. |
Ko te tūtohu mātāmua he 10 sats, ā ko te tūtohu Pro he 100 sats, me ngā tohu nui anō;
credits e kī ana he aha tēnei puaki ka tāpiri.
Whakaaronga
{
"invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
"payment_request": "lnbc100u1p5...",
"amount_sats": 10000,
"credits": 115,
"tier": "pro",
"expires_at": "2026-09-30T09:27:00Z",
"status": "pending"
}
| Tikanga Matua | Ahihi |
|---|---|
400 | He another huarahi i te huarahi (unsupported_method), he moni kāore e mōhiotia (unsupported_currency) rānei tier, he rārangi koretē, he rārangi iti i raro i te iti rawa (amount_too_small), nui ake i te 1,000,000 sats (amount_too_large) rānei e whakahēria ana e te Lightning wallet (amount_out_of_range). |
429 | He nui ake i te 60 ngā pūtea kōpaki mō tēnei nym, tērā hoki ko te 120 i tēnei wāhi, i roto i tētahi haora (rate_limit_exceeded, me Retry-After). |
502 | Kāore e taea te hanga i te inofaiti i tēnei wā (invoice_unavailable, me 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);
Tirohia te whakakapi utu
Pātai ana rānei kua utu te fāitara, ā, ina oti ana, ka tāpiri te kōti. Ko te tirotiro te mea e whakawhiti ana i te kōti, nō reira, i muri i te utu, tirohia kia tae atu ki te ahua... credited. Te tirotiro anō
i muri i tēnā he haumaru: ka puta te tupeka e tahi atu, ahakoa te maha o te wuku ake e pātai ai koe.
GET https://nymbot.ai/api/v1/topup/status/{invoice_id} — me he wete i te nym i hanga i te invoice.
status he pending (kāore anō i utu), paid (kua oti te utu, engari kāore anō kia whai hua; tirohia anō), credited (i runga i tō tauira) rānei expired (kāore i utu
i te wā). Ko ngā pae tauuta mō te taumata e whakakakā ana te invoice.
Whakaaronga
{
"invoice_id": "b7d41e0c95a2f38e6c1d0e9a4b7f2c61d3e8a05f9b2c4d7e1a6f3b8c0d5e2a9f4",
"status": "credited",
"amount_sats": 10000,
"credits": 115,
"tier": "pro",
"expires_at": null,
"balance_credits": 523.33,
"balance_sats": 52333
}
| Tikanga Matua | Ahihi |
|---|---|
400 | Ehara te id i te id e 64-character ana i te karanga create. |
404 | Kāore he puarere i tēnei ID mō tō nym (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);
Hītori pātai
He rārangi mō ia tono: he aha ia, he aha te tauira, he maha ngā token, ā, he aha te utu. Kāore e tiakina ngā pātai rānei ngā whakautu, nō reira e kore e hoki mai. Ka tiakina ngā rārangi mō te 90 rā, te mea hou ki mua. Ko te kī kua tae ki tōna tapu ka taea tonu te pānui i tōna hītori.
GET https://nymbot.ai/api/v1/queries/history — me he kī API, e kite ana i ōna ake tono, he tāpiritia te tono mā te tōmua nuku, e kite ana i te kī o ia mea.
| Papa | Mahere | Kia hiahiatia ana | Whakaahua |
|---|---|---|---|
page | tau katoa (pātai) | Kāore | Tūtohu 1, kia kaua i te nui atu i te 1,000; he whāriki tiketike ake ko 400 invalid_value. |
page_count | tau katoa (pātai) | Kāore | Ngā rārangi mō ia whāpage. He 20 te tūmatanui, kia kaua i te 100. |
start_dateend_date | string (pātai) | Kāore | Ngā rā me ngā wā ISO 8601. |
model | string (pātai) | Kāore | Ko tenei noa te mahere. |
type | string (pātai) | Kāore | chat, responses, messages, image, video, speech, transcription kei te mea anō embedding. |
all_keys | boolean (tūtohu) | Kāore | Me tētahi kī: true ka whai i ngā kī katoa o te ingoa e tēnei ake ana. Default false. |
key_id | string (pātai) | Kāore | Mehemea he tono kua whakatūpatoa, mehemea rānei me all_keys=true: tēnei kī anake. |
Whakaaronga
{
"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);
Whakapuaki ingoa paku utu ake
Ko te hanga, te whakarerekē, me te whakakore i ngā tuaka, te whakarāpopoto i te akaunahi, me ngā whakaahuatanga mātua o te moni, e kore e whakaata i tētahi tuaka API. He whaihua te whakatūpato i tō nym, nō reira he tuaka i wehe atu e taea te whakatau i te kaha katoa o tōna rārangi engari e kore e taea te hanga i tētahi tuaka anō kia whakatūpato i tōna kaha ake.
Ka mahia tēnei e te tuhono mōu: te katoa i roto i tōna API ka whakamahia ēnei ngāherehere e te pepa. Ko tēnei waahanga anake e hiahiatia ana e koe hei whakahaere i ngā tuhinga i tō kōtiu ake.
Ko te tohu he mea Nostr event o te momo 27235 (NIP-98), i tuku i te hanga base64-encoded i roto i te
Authorization hea me te kupu Nostr i mua:
Te huiwhitinga
{
"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": "..."
}
uKo te URL katoa o te tono, tae atu ki te tautui tātari, koia tonu te mea i timata.methodko te huarahi HTTP.payloadko te SHA-256 o te rāwāhi ingoa kōpaki, i te hex. He hiaوية tēnei i runga iPOSTaPATCH, ā, me tahi te byte ki te byte te tinana e tuku ana koe ki te mea i whakatauira hash e koe.created_atme kei roto i roto i te 60 hāora o te taimenga a te pūkaha.- Ka mahi ia tūmatatenga i te wā kotahi, he
GETwhakamātau, kia kore ai e taea te whakamahi anō i tētahi tīpako i mauia. Whakahuatia tētahi hou mō ia tono. Tāpiria tētahinoncewhakamātau ki tētahi uara kōpaki kia rerekē tonu ngā tono rua i raro i te whaiakoranga i te wā kotahi. - Ka taea te tinana o he tono whāiti ki te 64 KB i te mea, me he tinana
Content-Type: application/json.
He tupu ngaro e hoki mai ana 401 missing_nostr_auth; he mea hangai hē, he tohu hē, he tawhito rawa, tēnei rānei mō tētahi URL, āhua, tēnei rānei tinana rerekē e hoki mai ana
invalid_nostr_auth, me te take kei roto i te karere; ka hoki mai tētahi kua whakamahia anō
nostr_auth_replayed. Ka whakahēria he kī API ka tuku ki ēnei ngāwhatu. Ka tirohia te tohu i mua i te pānui i te tinana, ā, ka taea te hapa i tēnā i ngā wā 30 i te miniti mā ia tauwhiro (e whai ana te tauwhiro IPv6 i tōna katoa /64); ka... 429 me
Retry-After.
Ka taea e ngā pūmanawa tūhono (browsers) te karanga i ēnei ngāwaere (endpoints) i te wāhanga noa i roto i ngā pae a Nymbot anake (https://nymbot.ai,
https://nymchat.app me te āhua o ā rānei subdomains). Ka kore he CORS
headers kei te whāriki i tētahi whāriki atu, nō reira e kore e taea te pānui i ngā mea e hoki mai ana. Ngā scripts me ngā pūmanawa tata, e kore e tuku i te mea kaore he
Origin, e kore e pā.
Me hiahia te tohu i te kī huna o tō nym (te nsec), e whakahaere ana i ngā mea katoa: tō ahua, tō hītori, me tō tāpae pūtea. Kia whakatūhia anake i roto i tētahi pūmanawa i runga i tētahi rorohiko e whakapono ana koe ki a ia, pānui mai i te taiao anake, kaua e tuhituhi ki roto i te pohoti, ā, whakamahia te app mēnā e taea.
Ko ēnei kaimātai e hanga ana i te tīhau. Ko ngā tauira i muri ake i tēnei whāpage e whakamahi ana i a rātou. Ka pānui rātou i te kī tūkino i roto i te hex i te NOSTR_SECRET_HEX; te cURL whakamahi i te
nak taputapu rārangi-ā-tapatahi, e tae ana i tētahi nsec rānei hex
key, me te sha256sum (ki runga i 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");
}
Te whakarāpopototanga o te ake
Ko te mea e whakaaturia ana e te pepa API o te pūmanawa i te taha o runga: tō kī mātua, ngā pūtea e rua, e hia ngā kī e mahi ana (kāore i whakakorehia, kāore hoki i muta te wā), me te whakakāinga i runga i te hungaHere ngā tautuhing, mehemea
null i te wā e kore e tuku ai te tauturū i ratou.
GET https://nymbot.ai/api/v1/account — he hiahia kei te pīrekere hou tāpiritia te tono.
Whakaaronga
{
"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());
Whakahaere ana i ngā tāea
Ngā mutunga i muri i te rārangi kī o te taupānga. Me hiahia katoa i tētahi whakapuaki kōpaki. Ka whakahokia ia kī i tēnei āhua, me ngā wā i te ISO 8601 me ngā nui i roto i ngā sats:
Taonga matua
{
"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 he iho noa te whakamārama i tētahi kī engari ehara i te whakamahi i tēnā. Ka tukuna te kī anake i te rā kotahi, i te wā e hangaia ai.
Whakawhiti ngā tuhingā matua
GET https://nymbot.ai/api/v1/keys — kua tūtohu.
| Papa | Mahere | Kia hiahiatia ana | Whakaahua |
|---|---|---|---|
include_revoked | boolean (tūtohu) | Kāore | Whakaatu i ngā taupāpaku kua whakakoretia. Tūmatanui false. |
Whakaaronga
{ "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);
Whakakaha i tētahi kī
POST https://nymbot.ai/api/v1/keys — whāitiatia. Hoki mai 201.
| Papa | Mahere | Kia hiahiatia ana | Whakaahua |
|---|---|---|---|
name | kōpaka | Ae | 1 ki te 40 ngā tohu, rerekē ki āu tuhinga i te wā katoa (kaua e whakatika te pūtake). |
limit_sats | tau kōpaka | Kāore | Ko te rāhui moni i ngā sats, kia 1 rawa atu. Waiho i te kore mō te kore rāhui. |
reset_period | kōpaka | Kāore | daily, weekly kei te mea anō monthly. Hiahia limit_satsTīmata kia kore e huri anō te rārangi i tō rānei. |
expire_at | tātai rānei he integer | Kāore | Ina mutu te mahi o te tuhinga: he wā ISO 8601, he rārangi wā i te rā 1970. |
Whakaaturanga (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"
}
}
| Tikanga Matua | Ahihi |
|---|---|
400 | He ingoa kua ngaro rānei he ingoa roa rawa; he ingoa kua whakamahia atu rānei (duplicate_name); he rāhui kāore ko te tau katoa i te iti i te 1; he wā whakatakoto anō kāore he rāhui; he wā mutu i te rā o mua; he papa kāore e mōhiotia (unknown_parameter); kia 25 ngā tuaka mahi tonu kei roto i te (too_many_keys). |
429 | He ake atu i te 60 ngā kī i hangaia e tenei nym, me te 120 i tenei horopaki, i roto i tētahi awātea (rate_limit_exceeded, me 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);
Pānui i te kī kotahi
GET https://nymbot.ai/api/v1/keys/{id} — kua tūtohu.
He hokinga mai {"data": {…}} me te whāriki kōhatu, i te mea ko 404
key_not_found mehemea kāore he tāpui āu e whai ana i taua 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);
Te huringa i te kī
PATCH https://nymbot.ai/api/v1/keys/{id} — kua tūtohu.
Tukuna tētahi o name, limit_sats, reset_period a
expire_at, me ngā tikanga e tēnei i te hanga i te kī. null whakaweti i tētahi
pepa: kāore he tapu, kāore he whakahoki, kāore he mutunga. Ka tīmata he wā hou ki te zero te whakarerekē i te wā whakahoki. Ka kore e taea te whakarerekē i tētahi tāwai kua whakakorea (400 key_revoked). Ngā hokinga
{"data": {…}} me te whakaoho i te whanonga o te kōtuhi hou.
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);
Whakakore i tētahi kī
DELETE https://nymbot.ai/api/v1/keys/{id} — kua tūtohu.
E whakamuatu ana i te tuapapa i te wā tonu, mō te roimata. Kei te noho tonu i roto i te rārangi me te revoked_at whakatū, ā, ka
kitea me te include_revoked=true. Ko te whakakore i tētahi tauihoki kua whakakorea i mua, ka puta mai te whakautu pēnei noa. Ka waiho noa i ngā tauihoki whakakorea e 50 hou rawa nei; ka mukuia ngā tauihoki tawhito ake ina whakakoretia tētahi tauihoki hou atu.
Whakaaronga
{ "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());
NWC tono-tono-utu-ā-otomatika
Whakamahia he wallet Lightning me te Nostr Wallet Connect, ā, ka whakakapi a Nymbot i te tauira i te wā e hōhā ana te tukunga API. Kei te rārangi API o te app nga tautuhinga pēnei; ēnei ngā taumata whakamahi kei muri i a ia. Mehemea he katoa... tāpiritia te tono.
He pēhea te mahi: i muri i te whakataunga o tētahi tono API ki te tauira i kōwhiria e koe hei tirotiro, mehemea kua heke tauira ki raro i tō tūtohu, ka hanga a Nymbot he pūtea utu mō tō kaha whakahou, ka pātai i tō pūtea kia utu ai, ā ka tāpiri te kura. Ka whakahou ia i te nui rawa ko kotahi i roto i te 5 meneti mō ia nym me ia tauira, kia kore ai he rārangi tono nui e w限り tō pūtea. Kāore te whakatau pūtea i roto i ngā pūmanawa e whakaoho i tēnei. Ko te wā me te nui o te whakahou i te rāmua, me te raru i te rāmua, kei roto i ngā tautuhinga; mehemea kua tae atu te utu i muri i tētahi raru, me tirohia tō pūtea utu ki te te ahua o te whakakapi moni ngā tohu katoa.
Ko te rārangi hononga e whakaaetia ana e te tangata kua whiwhi i a ia kia pātai i tō pūtea kia utu. Ka tiakina e Nymbot i te wā whakakāinga, ā, ka whakamahia anake hei utu i āna ingoa utu whakahou ake, engari hangia he hononga mō tēnei anake, me tētahi pūtea whakakāinga i roto i tō pūtea, kia pēnei ai ko te nui rawa e taea e ia te utu he tau i kōwhiria e koe. Me tautoko te pūtea i... pay_invoice.
Whakawhiti atu i te pūtea {{wallet}}
POST https://nymbot.ai/api/v1/nwc-auto-topup/connect — kua tūtohu.
| Papa | Mahere | Kia hiahiatia ana | Whakaahua |
|---|---|---|---|
nwc_url | kōpaka | Ae | Te rārangi hononga, te tīmatanga nostr+walletconnect://. E pātai ana a Nymbot ki te wallet mō get_info i mua i te tau i tēnei, ā, ka pupuri i tēnei i te whakakāpaka. |
threshold_sats | tau kōpaka | Ae | Whakakāinga i te wā ka heke te tāpui i raro i ēnei sats. Kia neke atu i te 1,000. |
topup_sats | tau kōpaka | Ae | He aha te nui e tāpirihia ana i ia wā. 1,000 ki te 1,000,000 sats. |
tier | kōpaka | Kāore | pro (te tūtohu) rānei standard: te pūtea hei tirotiro me te whakakapi. |
Whakaaronga
{
"data": {
"connected": true,
"threshold_sats": 5000,
"topup_sats": 20000,
"tier": "pro",
"last_topup_at": null,
"last_topup_sats": null,
"last_error": null
}
}
| Tikanga Matua | Ahihi |
|---|---|
400 | Ehara i te taura hononga (invalid_nwc_url); kāore te pūtea i whakautu i tana rēlay (nwc_unreachable) i whakarerekē rānei te tirohanga (nwc_rejected); e kore e taea e te hononga te whai utu i ngā piri kōresitera (nwc_missing_permission); i te rārangi wātea kore i roto i ngā whārangi. |
501 | Kāore i whakakāhia ngā utu ā-motone tēnei tūmatatū (nwc_unavailable). Ka pā ana tēnei ki ngā wāhi mutunga e rua atu. |
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());
Pānui i ngā tautuhing
GET https://nymbot.ai/api/v1/nwc-auto-topup — kua tūtohu.
Whakahoki i te taunaha pēnei i te hono atu, me connected: false me ngā kōnae kē atu
null i te kore e hono ana he pūtea. Kāore te rārangi hononga anake i puta mai i te wā katoa.
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());
Whakakore ana
DELETE https://nymbot.ai/api/v1/nwc-auto-topup/connection — kua tūtohu.
Momo atu i te rārangi hononga i pupurihia. Kāore he utu hou e mahia ana. Hei whakarite, ka taea hoki te whakakore i te hononga i roto i tō wallet.
Whakaaronga
{ "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());
Whakaiti utu mō ia tono me te kore kī
Ka taea te utu mō ngā tuhinga mutunga utu pūmau i te wā kotahi mō ia tono mā te Lightning, kāore he tāhuhu, kāore he akauniti, ā, kāore hoki he tauira utu: POST /images/generations, POST /images/edits,
POST /videos, POST /audio/speech, POST /audio/transcriptions,
POST /audio/translations a POST /embeddings. He tāpae rerekē tonu e hiahiatia ana mō ngā Kōrero, ngā Whakautu me ngā
Rongo. Ko te tono e whai ana i tētahi tāpae ka whakahia ki te tauira me te mea noa; ko te
huarahi utu ka timata anake i te wā e kore e timata he tāpae.
E kōrero ana a Nymbot i ngā whakamārama rua o te whakaaro kotahi, mai i te backend kotahi: Lightning Labs'
L402 (e whakaaea ana hoki i raro i tōna ingoa tawhito, LSAT) me te panui whakarite a te IETF
Utu He whakamahere whakamātau HTTP me te lightning ako me te
charge hiahia. Whakamahia te mea e mārama ana tō kaiwhakautu.
Ko te utu kore kī i te wā nei anake ina API_L402_SECRET e whai ana i te iti nhất i te 32 ngā raweke
hex (64 ngā tohu) rānei base64 (44). Hangia tētahi me openssl rand -hex 32.
He iti rawa te tauira, e taea rānei te whakaaro, ka whakakore i te āhua, ā, ka tuhi i te take. Hei huri i tēnā, whakahuatia te tauira tawhito ki te API_L402_SECRET_PREVIOUS mō tētahi rā: ngā kōrero tika, ngā URLs o te āhua me
ngā whakataki i hangaia i raro i tēnā ka mau tonu ki te mahi kia oti te wā o te whakamutunga.
Te whakangungu
Tukuna te tono me te kore Authorization taupāpā. Mehemea he tika, kāore he mea e rere ana, ā, ka whiwhi koe i 402 Payment Required te utu e rite ana ki te utu a te kī, kua huri ki te 10 sats mō te pūtea noa, he 100 sats mō te pūtea Pro
ā, kua whakatika ki te sat katoa (kia 1 sat i raro i te mea iti noa, ā, kia 0.05 credit te iti katoa). Ko te
whakautu e whai ana i te toru WWW-Authenticate ngā wero mō tēnei ingoa utu anō:
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 }
}
Te Utu request he JSON base64url te parameter:
{"amount":"237","currency":"sat","methodDetails":{"invoice":"lnbc...","network":"mainnet","paymentHash":"..."}}.
He whakangungu e tūpato ana ki te mutunga, ki te Content-Type (tōna momo media me, mō
te multipart, tōna boundary) me te SHA-256 o ngā taiu kei te tinana i ahu mai koe, ā, e roa ana i te 15
minitere. I muri i te utu, tumehia te Taurite tātai anō: te mea kotahi tonu
Content-Type me te puāwai JSON e rite ana, mō ngā pae mutunga multipart
(/images/edits, /audio/transcriptions, /audio/translations)
te mea katoa i roto i te rōpū e rua anō me te tūāhua rānei e tatau ana. Ka kōwhiri ētahi rōpū HTTP ki tētahi tūāhua hou i ia wā
e whakarite ana rātou i tētahi rōpū, nō reira whakaritehia kia kotahi anake, ka tuku i aua pātea e rua.
Ka taea te pātai i ngā whakatūnga 30 i te minute i ia wāhi (he tauira IPv6 te tauira /64 katoa).
Ko ngā pātai e kore e mōhiotia te wāhi e whai ake ana i te whakatūnga 10 i te minute, ā, he rāhui whānui
ngā whakatūnga ka tuku a Nymbot i roto i ngā wāhi katoa; he pātai e whakatūpatoa i mua i te
whakatūnga (hei tauira ki te tinana e kore e tika te JSON) e kore e tau ki reira. I muri i tēnā, ko te
whakautu ko 429 me Retry-After, i mua i te pānui i te tinana. He utu
ngā whakamutunga i karanga katoa me te kore he tuhinga rānei whakahāngā.
E tau ana hoki ki te whakahiu matua o te 120
whakakōpūhia i te mātāiti i ia minute mō ia wāhi. Ka tātarihia te tuhinga rānei i mua i te
pānui i te tinana, ā he tono e kua Content-Type kāore e application/json (or
multipart/form-data (mō ngā whakaeke) kei te whakahē me te 415 ā, kāore i te whiwhi
he pūnaha utu.
E whakatauhia ana te utu o ngā embeddings mai i te tūtohu o ngā token i roto i te whakauru, me te maramara 1.5×, nā te mea e mōhiotia ana anō te tika o te tauira i muri i te mahi. Ka utu koe mō ngā token i whakamahia i mua, ā ko te wāhanga kāore i whakamahia o te utu ka hoki mai hei a whakahoki moni tohu.
E tuku ana i te utu
Whakataunga i te pūrere invoice ki tētahi wallet Lightning katoa. Ka tukuna e te wallet ki a koe te preimage, he 64 hex characters. Ā, tuku i te tono pēnei tonu ki tētahi o ēnei:
| He Rautaki | Kokiri |
|---|---|
| L402 | Authorization: L402 <macaroon>:<preimage> (LSAT ka mahi hoki) |
| Utu | Authorization: Payment <base64url JSON>, kei hea te JSON {"challenge": {every parameter of the challenge, as sent}, "payload": {"preimage": "<hex>"}} |
He tono utu e whakautu ana e rite tonu ki tētahi i hangaia ki te kī, engari ko te nymbot
kāore he ngāāhi rauemi tauira: {"payment": "l402", "tier": "pro", "paid_sats": 237,
"charged_sats": 237}, ā, kāore he X-Nymbot-Balance-Sats header. A
he tono i whakamutatia ki te whakamahi i te Here Whakaputa Tooi ka whiwhi hoki i tētahi Payment-Receipt taupāpā (base64url
JSON me te id o te whakangaha, te hash o te utu hei reference, status a
timestamp). Kāore ngā tono kōwhiri e hono ana ki tētahi nym, nō reira e kore e kitea i roto i te
tauira hītori.
| Tikanga Matua | Ahihi |
|---|---|
402 payment_already_used | Ko ia utu e whai ake ana mō tētahi tono kotahi. Ko te whakautu he wero hou mō tēnei tono, nō reira he kaiwhakamahi e whakatūpato ana i tōna whakamahinga i tōna kōtuhi i mua (hei tauira lnget ka utu noa anei ia anō. |
402 payment_mismatch | I whakatūria te whakaaetanga mō tētahi rārangi wāhi kē, Content-Type te tinana, he iti ake i tēnei tono te utu ināianei. He wero hou kei roto i tēnei tono; mehemea he iti rawa te utu, ka hoki mai te mea i e taki atu koe hei a whakahoki moni tohu (refund_token a refund_sats i roto i te tinana). |
402 payment_expired | Kua taihoa atu i te 15 meneti i te wā i te whakataukiri. He whakataukiri hou ka tae mai ki a ia. Ki te whakaatu te preimage i te mea i whai pai koe, ka hoki mai te mea i whai pai koe hei a whakahoki moni tohu (refund_token a refund_sats i roto i te tinana), he taurangi; ka whakamahia anō te tohu i tērā wā. |
401 invalid_preimage | Kāore te preimage e huri ana ki te hash utu o te pūtea ingoa. Kāore te utu i whakamahia katoa. |
401 invalid_payment_credential | He hapa te hanganga o te whakaaetanga, i huri i muri i te tuku a Nymbot, te hānga hoki i tētahi whakamātau utu kāore i whakarite i te pūnaha invoice a Nymbot. He raru te macaroon me tētahi takatū kāore i mōhio a Nymbot, me tētahi takatū rerekē hoki, ka whakahokiia. |
429 rate_limit_exceeded | Kua puta mai i tēnei rārangi kōrero he rerekētanga tohu rānei kī i te nui atu i te 30 i roto i tētahi minute, i te tukuna rānei o tētahi tohu pengi i te nui atu i te 60 i roto i tētahi minute. Tatari mai 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"));
Kaitautoko hangaia ki runga i mppx mā te Lightning whakamahia te wero Whai Taki
rānei katoa; tukuna rātou ki te mutunga whakamahi kia utu ai rātou.
Whakaata
He utu ake POST /videos whakautu 202 pēnei i tētahi kua whakakāinga, me tētahi a
status_url: GET kia kore he tuāhua hei whai i te mahi. Kua tāpirihia te tohu
ā, e mahi ana mō te 24 ihoramā, inā kei te hāpai tonu te mahi.
{
"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..."
}
}
Kia mau ki te refund_token nō tēnei whakautu: kei konei anake e kitea ana. He kore i te wā
e hangaia ana te ataata (GET /api/v1/l402/refunds whakautu "status": "pending");
mehemea ka raru te whakamātau kore utu, ka whakatūngia te utu ki runga i a ia. Ka whakaatu te URL o te āhua i
refund_sats Mō tētahi mahi kua hoki moni engari kāore i tae te tohu, nō reira, kāore te tuku i te URL o te āhua e whakaatu ana i te hoki moni. Ko te tātaritanga i te tohu hoki ka whakatika i tētahi mahi kua hinga kāore i pātaihia e tētahi.
Whakaora moni
Ki te kore e taea te tono utu, ā, kua koha te kaiwhakarato i a Nymbot mō te whakamātau, ka mau te utu, ā, ka kī te raru i tērā, me te charged_sats, e rite tonu ana mō te tono whāiti. Ki te kore e taea
me kāore i whai utu, ka whai te hapa i tētahi whakahoki moni tohu He tika te utu i piria:
{
"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"
}
}
Ka hoki mai ngā wāhanga kua kore e whakamahia i te huarahi e tatea ana: ki te tono koe i ngā whakaahua rua, ā, ka raru tētahi i te kore utu,
te whakautu o te angitu kei te nymbot Kei te whakahau te mea i te tohu pengi mō te mea kua ngaro; he tuhituhinga e kore i taea te kite i te roa i mua ka whakatau te utu mō te roa uestia o te pūrere (kaua e neke i te 30 meneti), ā, ka hoki mai te rerekētanga ki te roa tika hei tohu pengi; mehemea he ake i te 30 meneti te roa, ka whakahamia ki te 413
ā, ka hoki te katoa o te utu. Ka hoki mai ngā embeddings i te mea i whakarere ai te whakaaturanga. He hoki utu hītori i te hītori hoko i te tōtika i tukuna mai.
He tohu hoki he rārangi kōti 256-bit kōpūhia. Ka tiaki anake a Nymbot i tōna hash, ā ka muta i muri i te 30 ngā rā. Kei roto i tērā tētahi tauira sat, ā ka taea e koe te:
- Whakataurite ki te mea. Tuku
Authorization: Bearer REFUND-…i runga i tētahi o ngā mutunga i runga i ahakoa (ka mauhia e tētahi OpenAI SDK hei API key). Ka puta te utu mai i te token, ā ka noho tonu te mea kua mahue ki runga i a ia (refund_token_satsi roto i tenymbotwhakaaro). He tohu he iti ake i te tono te whakahāngai ake.402refund_insufficient; he hē kāore i whakatauhia te utu e whakahoki i ngā sats ki te tohu kotahi. - Tirohia.
GET /api/v1/l402/refundsme te taupāpā e rite ana ka hoki{"sats": 237, "status": "open", "expires_at": "..."}. - Ka taea te whakamahia tētahi token i te nui rawa ko te 60 i roto i te minutuhara e toru.
- Whakakore atu ki tētahi nym. Whakauru ki roto i Whakaora he taonga i roto i te
app Nymbot, me wātea rānei te karanga
POST /api/v1/l402/refunds/redeemme he tāpiritia te tono a{"refund_token": "REFUND-...", "balance": "standard"}(or"pro"). Ka haere katoa ngā tuatahi ki te tāpaetanga (10 sats mō ia standard, 100 mō Pro); ngā sats kāore e whai i tētahi tuatahi katoa ka noho tonu ki te token mō ngā 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"
Whakaaronga
{ "data": { "credited": 23, "tier": "standard", "balance_credits": 123, "remaining_sats": 7 } }