Lumaktaw sa nilalaman
Pagbalik sa Nymbot

Batayan ng kaalaman mga developer

Chat, mga reaksiyon at mensahe

Three ways to ask a model something, sa tatlong mga format ang mga kliyente na ngayon ay nagsasalita, ang lahat ay gumagana sa parehong mga modelo at inilathala sa parehong paraan.

Mga Kompleto ng Chat

Ang OpenAI chat format, at ang isa sa halos lahat ng tool suportahan. Ipadala ang konversasyon hanggang ngayon at makakuha ng next message back.

POST https://nymbot.ai/api/v1/chat/completions Kailangan mo ng isang API key.

lamang ang model at messages Ang isang sampling parameter na ang napili ng modelo ay hindi gumagana ay hinihintay nang walang error, kaya ang isang request body ay gumagana sa lahat ng mga modelo. supported_parametersAng kung ano ang ibig sabihin ay hindi maaaring gawin ng modelo sa lahat: mga larawan para sa isang modelo na hindi makikita, mga tool para sa isang modelo na hindi maaaring sabihin ang mga ito.

ang fieldTipongKailanganang description
modelang stringOonymbot/auto (Ang auto) para sa pag-routing ng Nymbot sa standard balance, o isang catalog model id tulad ng anthropic/claude-sonnet-5 sa Pro balance. Ang mga short names at aliases ng app ay nakatuon din. May nagsisimula sa isang ang suffix.
messagesang arrayOoAng mga ito. roles system, developer (Ang mga ito ay tinatawag na system), user, assistant at toolAng content ay isang string o isang listahan ng text at image_url mga bahagi; mga larawan lamang sa mga mensahe ng user. input_audio Ang mga file ay inihayag.
streamang booleanHindiMagbigay ng inspirasyon sa kontemporaryong designer ay maaaring gumawa ng kahit ano, kahit ano, at ang New Year - ay walang exception. ang streaming.
stream_optionsMga ObjectHindi{"include_usage": true} Ipinapakita ang isang final chunk na may mga token count at ang gastos.
max_tokens
max_completion_tokens
ang integerHindiAng karamihan ng tokens upang i-writ. Nagsimula sa maximum ng modelo kung mas mataas. Halimbawa ay nagtatagumpay kung ano ang nagtatagumpay mula sa iyong balanse, kaya ang isang mas maliit na bilang ay kailangan ng mas mababang credit upang magsimula.
temperature
top_p
ang numberHindiMga control ng sampling: temperature mula sa 0 hanggang 2, top_p mula sa 0 sa 1.
stopang string o arrayHindiAng teksto na nagsisimula sa pag-uusap: isang string o sa maximum 4 strings, bawat isa sa maximum 256 character. nymbot/auto.
seedang integerHindiPara sa repetitive sampling, kung saan ang modelo ay suportahan ito.
presence_penalty
frequency_penalty
ang numberHindiIpinapakita ang mga controls, bawat isa mula sa -2 sa 2.
response_formatMga ObjectHindi{"type": "json_object"} o sa {"type": "json_schema", "json_schema": {…}}kung saan ang modelo ay sumusuporta sa kanya. Hindi ginagamit ng nymbot/auto.
tools
tool_choice
parallel_tool_calls
array, string o object, booleanHindiIpinanganak ang function. see mga toolsa a web_search Ang tool ay tumutulong paghahanap WEBSa higit sa 128 mga tool at 512 KB ng mga definisyon, inilagay sa higit sa 64 mga antas ng karamihan; higit pa ay isang 400.
reasoning_effort
reasoning
Paglalarawan ng ObjectHindi"minimal", "low", "medium" o sa "high"o sa {"effort": "high"}. "none" o sa {"enabled": false} Tapos na ang klase. if you see. ang reasoning.
pluginsang arrayHindi[{"id": "web", "max_results": 5}] Always searches the web first. hanggang sa 10 mga resulta.
nang integerHindi1 Ang lahat ng iba't ibang ay bumalik 400.
logit_bias
user
metadata
Ang mga ito ay string, object.HindiNakatanggap at hindi inilathala. logit_bias mga mapa sa higit sa 300 token ids sa mga numero mula sa -100 hanggang 100; user Sa loob ng 256 characters; metadata Mayroong higit sa 16 na mga halaga ng string, mga keys ng hanggang sa 64 character at mga halaga ng hanggang sa 512.

Ang solusyon ay isang normal chat.completionDahil sa cost in usage.cost (Sa mga dollar) at sa mga nymbot ang object. model Ang maliliit na negosyo sa mga sumusunod na sektor ay kinakailangan: pagproseso ng produktong agrikultural ( message.reasoning_contentIyon ang separado mula sa answer.

Reaksiyon

{
  "id": "chatcmpl-5f1c0a9e27d84b3c",
  "object": "chat.completion",
  "created": 1790726400,
  "model": "anthropic/claude-sonnet-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A Lightning invoice is a one-time payment request..."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1240,
    "completion_tokens": 380,
    "total_tokens": 1620,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 0 },
    "cost": 0.01895
  },
  "nymbot": {
    "balance": "pro",
    "charged_credits": 0.162,
    "charged_sats": 16.2,
    "balance_credits": 412.425,
    "balance_sats": 41242.5
  }
}

finish_reason Ito ay nagtatrabaho mula sa kung ano ang dumating, dahil ang mga provider ay inilathala ito sa iba't ibang paraan: tool_calls Kapag ang modelo ay nangangailangan ng mga tool, length kapag ang solusyon ay ginagamit ang lahat ng mga token na ibig sabihin (o ang modelo ay ginagamit ang lahat ng mga ito sa pag-argument at hindi na ibinigay ang isang solusyon), content_filter Kapag ang tagapagtatag ay hindi, at stop sa ibang tao. usage.completion_tokens_details.reasoning_tokens always 0: ang mga saklaw na token ng pag-argument ay inilathala, at inirerekomenda, sa completion_tokens.

Status ngkapag
400Hindi model o sa messages (missing_required_parameter); isang audio o file bahagi, o mga imahe para sa isang modelo na hindi maaaring makita ang mga ito (unsupported_content); higit sa 20 mga larawan (too_many_images(Tingnan ang mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod na mga sumusunod)invalid_value); isang larawan na link na hindi public (invalid_image_url(Tulad nila Tirso at Lyn ang mga anak nila, very friendly at magalang.unsupported_tool); n sa loob ng isang; a :thinking Ang maliliit na negosyo sa mga sumusunod na sektor ay kinakailangan (model_not_found(Tulad nila Tirso at Lyn ang mga anak nila, very friendly at magalang.upstream_rejected).
402Ang saldo na ginagamit ng modelo ay hindi makukuha ng hold.
403Ang maliliit na negosyo sa mga sumusunod na sektor (key_limit_reachedang lower max_tokens o pumunta ang cap.
404Walang modelo sa pangalan na ito (model_not_found).
429Ang mga sumusunod na mga sumusunod na mga sumusunod (upstream_rate_limited).
502, 503nagtatapos sa tuldok (upstream_error(Ito ay ang mga sumusunod na (upstream_overloadedDahil sa Retry-AfterWalang bagay ay inirerekomenda kung hindi ang provider inirerekomenda para sa pagsusuri.

Ang mga status codes ng bawat endpoint shares ay itinatag sa ilalim ng Mga error.

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "messages": [
      {"role": "system", "content": "Answer in one short paragraph."},
      {"role": "user", "content": "What is a Lightning invoice?"}
    ],
    "max_tokens": 400
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    messages=[
        {"role": "system", "content": "Answer in one short paragraph."},
        {"role": "user", "content": "What is a Lightning invoice?"},
    ],
    max_tokens=400,
)
print(reply.choices[0].message.content)
print(reply.usage.cost)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5",
  messages: [
    { role: "system", content: "Answer in one short paragraph." },
    { role: "user", content: "What is a Lightning invoice?" },
  ],
  max_tokens: 400,
});
console.log(reply.choices[0].message.content);
console.log(reply.usage.cost);

ang streaming

sa "stream": true ang solusyon ay dumating bilang mga events na ibinigay ng server habang ang modelo ay itinuturing ito. chat.completion.chunk ang a data: ang line, at ang stream ay nagsisimula sa data: [DONE]Ang pag-ibig ay dumating sa delta.reasoning_contentAt ang solusyon sa delta.content.

I-stream ang anumang bagay na maaaring magkaroon ng higit sa tungkol sa 100 segundo, tulad ng isang mahabang solusyon, isang malaking max_tokens o isang modelong pag-argument. Ang isang pangangailangan na hindi na-streamed ay hindi nagpadala ng anumang bagay hanggang sa ang solusyon ay kumpletong, at ang network sa pagitan ng iyo at Nymbot ay maaaring i-shut down ng isang idle na koneksyon pagkatapos ng tungkol sa 100 segundo; ang modelo ay patuloy na magsisimula at ang kung ano ang itinuturing nito ay naka-charge, ngunit ang solusyon ay nawala. Ang isang stream ay nagpadala ng keep-alives, kaya ito ay matatagpuan habang ang modelo ay itinuturing.

ang stream

data: {"id":"chatcmpl-5f1c0a9e27d84b3c","object":"chat.completion.chunk","created":1790726400,"model":"anthropic/claude-sonnet-5","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-5f1c0a9e27d84b3c","object":"chat.completion.chunk","created":1790726400,"model":"anthropic/claude-sonnet-5","choices":[{"index":0,"delta":{"content":"A Lightning invoice"},"finish_reason":null}]}

: keep-alive

data: {"id":"chatcmpl-5f1c0a9e27d84b3c","object":"chat.completion.chunk","created":1790726400,"model":"anthropic/claude-sonnet-5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"id":"chatcmpl-5f1c0a9e27d84b3c","object":"chat.completion.chunk","created":1790726400,"model":"anthropic/claude-sonnet-5","choices":[],"usage":{"prompt_tokens":1240,"completion_tokens":380,"total_tokens":1620,"cost":0.01895},"nymbot":{"balance":"pro","charged_credits":0.162,"charged_sats":16.2,"balance_credits":412.425,"balance_sats":41242.5}}

data: [DONE]
  • Lines na nagsisimula sa : Ang mga komento na ito ay tinatawag na "keeping-alive", na inilathala sa bawat 15 segundo habang ang modelo ay nag-iisip.
  • Ipinapakita ang "stream_options": {"include_usage": true} upang makakuha ng ang last chunk sa itaas, na may isang empty choicesAng mga sumusunod, ang gastos at ang nymbot ang object.
  • Ang karagdagang ito ay nagsisimula pagkatapos ng pag-uugali ng stream. Kung i-shut down ang koneksyon bago, ang modelo ay hindi na-stop: Nymbot i-read ang iba't-ibang stream ng provider, para sa hanggang sa 25 segundo, upang makakuha ng kanyang token count, at ikaw ay magbayad kung ano ang provider inihayag. Walang ito count ang karagdagang ay inihayag mula sa iyong input at kung ano ang inihayag, plus ang buong output allowance para sa isang modelo na mga dahilan.
  • Isang error bago ang unang chunk, tulad ng 401 o sa 402, bumalik bilang normal na JSON na may kanyang status code, hindi bilang isang stream. Ang isang error pagkatapos ng stream ay nagsimula ay dumating bilang isang last data: {"error": {…}} ang event, at ang stream ay nagsisimula nang walang [DONE].
  • Ang mga request na may mga tool, at mga modelo sa OpenAI's Responses transport, ay hindi stream mula sa provider.

cURL

curl -N https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nymbot/auto",
    "stream": true,
    "stream_options": {"include_usage": true},
    "messages": [{"role": "user", "content": "Write a haiku about sats."}]
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

stream = client.chat.completions.create(
    model="nymbot/auto",
    stream=True,
    stream_options={"include_usage": True},
    messages=[{"role": "user", "content": "Write a haiku about sats."}],
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)
    elif chunk.usage:
        print("\ncost:", chunk.usage.cost)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const stream = await client.chat.completions.create({
  model: "nymbot/auto",
  stream: true,
  stream_options: { include_usage: true },
  messages: [{ role: "user", content: "Write a haiku about sats." }],
});
for await (const chunk of stream) {
  if (chunk.choices.length) process.stdout.write(chunk.choices[0].delta.content || "");
  else if (chunk.usage) console.log("\ncost:", chunk.usage.cost);
}

Mga Tool

Paglalarawan ng mga function sa tools At kapag dump namin ang circuit, magkakaroon ka ng circuit. at kapag dump namin ang circuit. tool Mga mensahe sa parehong tool_call_idAng Nymbot ay hindi mai-execute ang iyong mga function; ito ay inilathala sa iyo ang request ng modelo.

tool_choice sa loob "auto", "none", "required" o sa {"type": "function", "function": {"name": "…"}}Ang maliliit na negosyo sa mga sumusunod ay kinakailangan: pagproseso ng produktong agrikultural (capabilities.toolsAng mga tool ay inihayag sa 400 unsupported_tool ang nymbot/auto at sa ilang mga modelo ng catalog na gumagana sa OpenAI's Responses transport, na kung saan ang Nymbot ay hindi maaaring magpasok ng mga tool.

sa "stream": true, isang request na may mga tool ay gumagana sa isang bidyo at pagkatapos ay inilathala bilang isang normal chunk sequence: ang role, isang chunk na may bawat tool call na may kanyang index, id, pangalan at arguments, at ang finish chunk.

Ang reaksyon, sa isang bahagi

"choices": [
  {
    "index": 0,
    "message": {
      "role": "assistant",
      "content": null,
      "tool_calls": [
        {
          "id": "call_7d2e",
          "type": "function",
          "function": { "name": "get_invoice_status", "arguments": "{\"invoice_id\":\"a41f\"}" }
        }
      ]
    },
    "finish_reason": "tool_calls"
  }
]

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "messages": [{"role": "user", "content": "Has invoice a41f been paid?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_invoice_status",
        "description": "Look up whether an invoice is paid.",
        "parameters": {
          "type": "object",
          "properties": {"invoice_id": {"type": "string"}},
          "required": ["invoice_id"]
        }
      }
    }]
  }'

Python

import json, os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

tools = [{
    "type": "function",
    "function": {
        "name": "get_invoice_status",
        "description": "Look up whether an invoice is paid.",
        "parameters": {
            "type": "object",
            "properties": {"invoice_id": {"type": "string"}},
            "required": ["invoice_id"],
        },
    },
}]
messages = [{"role": "user", "content": "Has invoice a41f been paid?"}]

reply = client.chat.completions.create(model="anthropic/claude-sonnet-5", messages=messages, tools=tools)
call = reply.choices[0].message.tool_calls[0]
args = json.loads(call.function.arguments)

messages.append(reply.choices[0].message)
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps({"paid": True})})

final = client.chat.completions.create(model="anthropic/claude-sonnet-5", messages=messages, tools=tools)
print(final.choices[0].message.content)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const tools = [{
  type: "function",
  function: {
    name: "get_invoice_status",
    description: "Look up whether an invoice is paid.",
    parameters: {
      type: "object",
      properties: { invoice_id: { type: "string" } },
      required: ["invoice_id"],
    },
  },
}];
const messages = [{ role: "user", content: "Has invoice a41f been paid?" }];

const reply = await client.chat.completions.create({ model: "anthropic/claude-sonnet-5", messages, tools });
const call = reply.choices[0].message.tool_calls[0];
const args = JSON.parse(call.function.arguments);

messages.push(reply.choices[0].message);
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ paid: true }) });

const final = await client.chat.completions.create({ model: "anthropic/claude-sonnet-5", messages, tools });
console.log(final.choices[0].message.content);

Mga larawan sa isang request

Mga modelo sa capabilities.vision Dapat i-read ang mga imahe. add a image_url sa isang user message, na may isang publiko https:// ang link na a data:image/…;base64, Ang mga ito ay mayroong 20 na mga imahe sa bawat request. mga imahe ng SVG ay inihayag, at ang link ay may higit sa 4,096 character o isa na may isang user name o password sa itaas (400 invalid_image_urlAng isang optional detail ay auto, low o sa high.

sa nymbot/auto, isang request na may isang larawan sa kanya ay na-routing sa isang standard na modelo na maaaring makita. capabilities.vision Reject ang mga larawan 400 unsupported_contentAng mga imahe ay maaaring lamang sa mga mensahe ng gumagamit. Ang isang link ay dapat ipinakita sa isang publikong host; Nymbot ay nagpasya ang imahe sa provider ng modelo at hindi itinatag ito.

Ang isang imahe ay naka-charge bilang ang input tokens na tinanggap ng provider para sa kanya, tulad ng iba pang mga request.

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "What is in this picture?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/receipt.jpg"}}
      ]
    }]
  }'

Python

import base64, os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

with open("receipt.jpg", "rb") as f:
    data_url = "data:image/jpeg;base64," + base64.b64encode(f.read()).decode()

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What is in this picture?"},
            {"type": "image_url", "image_url": {"url": data_url}},
        ],
    }],
)
print(reply.choices[0].message.content)

JavaScript

import { readFile } from "node:fs/promises";
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const dataUrl = "data:image/jpeg;base64," + (await readFile("receipt.jpg")).toString("base64");

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What is in this picture?" },
      { type: "image_url", image_url: { url: dataUrl } },
    ],
  }],
});
console.log(reply.choices[0].message.content);

ang reasoning

Mga modelo sa capabilities.reasoning Pero kapag nalaman niyang nakilala mo siya dahil binasa mo ang diary... get ready for the consequences. reasoning_effort ("minimal", "low", "medium" o sa "high"• o "reasoning": {"effort": "high"}o magbigay ng :thinking sa pangalan ng modelo, na kung saan ang ibig sabihin ng mataas na effort. Sa isang modelo nang walang pag-argument ang setting ay inilabas. nymbot/auto, :thinking I-send ang request sa standard reasoning route.

Sa Anthropic mga modelo ang pag-iisip ay isang budget ng tungkol sa 1,000, 2,000, 8,000 o 16,000 tokens, hindi higit sa max_tokens at malapit na ding maging isang trahedya tool_choice Pumunta sa isang tool, at kapag ang request ay nagtatag ng isang tool loop (ang kanyang huling mensahe ay isang tool result), dahil ang Anthropic ay kailangan ng mga nakaraang-signed na pag-iisip upang ipatupad ito.

Ang argumento ay bumalik sa message.reasoning_contento sa delta.reasoning_content Pero kapag nalaman niyang nakilala mo siya dahil binasa mo ang diary... get ready for the consequences. completion_tokensAng ilang mga provider ay hindi mag-return ang text ng pag-argument sa lahat, at ito ay patuloy na naka-charge.

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "reasoning_effort": "high",
    "messages": [{"role": "user", "content": "Is 2^61 - 1 prime? Show why."}]
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    reasoning_effort="high",
    messages=[{"role": "user", "content": "Is 2^61 - 1 prime? Show why."}],
)
message = reply.choices[0].message
print(getattr(message, "reasoning_content", None))
print(message.content)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5",
  reasoning_effort: "high",
  messages: [{ role: "user", content: "Is 2^61 - 1 prime? Show why." }],
});
console.log(reply.choices[0].message.reasoning_content);
console.log(reply.choices[0].message.content);

Mga modelo ng suffixes

Ang isang sufix sa pangalan ng modelo ay gumagana kung paano ang request ay nagtatrabaho, nang walang iba pang field. Ang mga ito ay gumagana sa full id at short names pati na, tulad ng sa anthropic/claude-sonnet-5:online.

ang suffixang effect
:onlinePagkatapos ng paghahanap ng web, tulad ng plugins: [{"id": "web"}]ang paghahanap WEB.
:thinkingAng maliliit na negosyo ay kinakailangan: pagproseso ng produktong agrikultural ( nymbot/autoSa isang modelo na hindi makakakuha ng pag-iisip, 400 model_not_found sa pamamagitan ng “no endpoints found”.
:nitro, :floor, :exacto, :extendedAng bawat modelo ng catalog ay may isang ruta, kaya walang mas mabilis, mas madali o mas mabilis na isa upang piliin; ang mga sumusunod ay pinapayagan upang ang mga pangalan ng modelo na kopya mula sa iba pang mga serbisyo ay patuloy na gumagana.

Any other suffix is ignored. The entire name is tried first, so a model whose id really contains a colon still works; kung hindi ito, suffixes are taken off the end one at a time until a model matches. A model name can be at maximum 200 characters long with at maximum 4 suffixes; a longer one is refused with 400 invalid_value.

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5:thinking",
    "messages": [{"role": "user", "content": "Plan a three-day trip to Lisbon."}]
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5:thinking",
    messages=[{"role": "user", "content": "Plan a three-day trip to Lisbon."}],
)
print(reply.choices[0].message.content)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5:thinking",
  messages: [{ role: "user", content: "Plan a three-day trip to Lisbon." }],
});
console.log(reply.choices[0].message.content);

Any chat model can answer from the live web. Nymbot searches for the last user message (ang kanyang unang 2,000 character), read ang pinakamahusay na mga pahina at ibinigay ang mga ito sa model na may tanong, na markado bilang external content na ang model ay hindi dapat makuha instructions mula.

  • Always ang search: "plugins": [{"id": "web", "max_results": 5}]o sa a :online suffix sa modelo.
  • Paghahanap kung ano ang tulong: "tools": [{"type": "web_search", "parameters": {"max_results": 5}}]Dahil dito ay nakuha ako web_search_preview o sa openrouter:web_searchNymbot searches lamang kapag ang tanong ay kinakailangan ng kasalukuyang impormasyon, ang parehong test na ginagamit ang app.

max_results ay 5 sa default at sa maximum 10. ang mga source ay bumalik sa nymbot.web_search.sourcesLahat ng mga ito ay a title, snippet at urlat ang as url_citation ang mga anotasyon sa mensahe.

Ang bawat paghahanap na gumagana ay nagkakahalaga ng $ 0.008, i-convert sa sats, sa itaas ng mga token, at ito ay bahagi ng hold. Ang mga pahina na ito nabasa ay input tokens din, kaya ang isang solusyon mula sa web ay nagkakahalaga ng higit pa kaysa sa parehong tanong na inihayag, karaniwang ilang beses higit pa.

Ang reaksyon, sa isang bahagi

"nymbot": {
  "balance": "pro",
  "charged_credits": 0.431,
  "charged_sats": 43.1,
  "balance_credits": 411.994,
  "balance_sats": 41199.4,
  "web_search": {
    "sources": [
      { "title": "Lightning Network - Wikipedia", "snippet": "The Lightning Network is a payment protocol...", "url": "https://en.wikipedia.org/wiki/Lightning_Network" }
    ]
  }
}

cURL

curl https://nymbot.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "plugins": [{"id": "web", "max_results": 5}],
    "messages": [{"role": "user", "content": "What changed in the latest Bitcoin Core release?"}]
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

reply = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    messages=[{"role": "user", "content": "What changed in the latest Bitcoin Core release?"}],
    extra_body={"plugins": [{"id": "web", "max_results": 5}]},
)
print(reply.choices[0].message.content)
for source in reply.model_extra["nymbot"]["web_search"]["sources"]:
    print(source["url"])

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const reply = await client.chat.completions.create({
  model: "anthropic/claude-sonnet-5",
  plugins: [{ id: "web", max_results: 5 }],
  messages: [{ role: "user", content: "What changed in the latest Bitcoin Core release?" }],
});
console.log(reply.choices[0].message.content);
for (const source of reply.nymbot.web_search.sources) console.log(source.url);

Mga Reply sa API

Ang mas bagong format ng OpenAI, ginagamit sa OpenAI Agents SDK at sa Codex. Ito ay gumagana sa parehong mga modelo, billing at mga tampok na Chat Completions.

POST https://nymbot.ai/api/v1/responses Kailangan mo ng isang API key.

ang fieldTipongKailanganang description
modelang stringOoPara sa Mga Kompleto ng Chatang mga suffixes.
inputang string o arrayOoAng isang string, o isang listahan ng mga item: mensahe (roles user, assistant, system, developer(Ang mga input_text, input_image at output_text Ang mga bahagi, at function_call at function_call_output Mga item para sa mga tool. input_image Magkaroon ng isang image_url link o data URL, hindi isang file id. reasoning at web_search_call Ang mga item ay nakalimutan; item_reference ay ibig sabihin.
instructionsang stringHindiMga Instruction sa System
max_output_tokensang integerHindiAng pinakamataas na mga tokens upang i-writing.
temperature
top_p
ang numberHindiSampling controls, kung saan ang modelo ay may mga ito.
tools
tool_choice
parallel_tool_calls
array, string o object, booleanHindiPumili ng kategorya, gaya ng mga gasolinahan o grocery. ({"type": "function", "name": …, "parameters": …}ang a web_search o sa web_search_preview Ang tool ay tumutulong paghahanap WEB Kapag bumalik na ako sa UP, i'll start building a new me.
reasoningMga ObjectHindi{"effort": "minimal" | "low" | "medium" | "high"}. xhigh at max Siguro high; none Gawin ito off.
text.format
response_format
Mga ObjectHindiStructured output, tulad ng isang JSON scheme o json_object.
metadataMga ObjectHindiIbalik na walang pagbabago sa pag-response. Sa higit sa 16 na mga halaga ng string, ang mga keys ay hanggang sa 64 na karakter at ang mga halaga ay hanggang sa 512.
streamang booleanHindiMag-stream ng mga events tulad ng inilarawan sa ibaba.
storeang booleanHindiWalang bagay ay ibinigay, at ang solusyon ay palagi "store": false.
previous_response_id
conversation
background
Mga pahinang tumuturo sa Object, BooleanHindiWala pang suporta: 400 unsupported_parameterAng mga reaksiyon ay hindi ibinigay, kaya magpadala ang buong konversasyon sa input Lahat ng oras.

Reaksiyon

{
  "id": "resp_8c1e4b0f9a2d4e61",
  "object": "response",
  "created_at": 1790726400,
  "status": "completed",
  "model": "anthropic/claude-sonnet-5",
  "output": [
    {
      "type": "message",
      "id": "msg_2b7f",
      "role": "assistant",
      "status": "completed",
      "content": [{ "type": "output_text", "text": "A Lightning invoice is...", "annotations": [] }]
    }
  ],
  "output_text": "A Lightning invoice is...",
  "usage": {
    "input_tokens": 1240,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 380,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 1620
  },
  "incomplete_details": null,
  "error": null,
  "instructions": null,
  "store": false,
  "previous_response_id": null,
  "metadata": {},
  "nymbot": { "balance": "pro", "charged_credits": 0.162, "charged_sats": 16.2, "balance_credits": 412.425, "balance_sats": 41242.5 }
}

Ang isang tool request ay nagpapakita sa output Ako ay function_call Mga item sa call_id, name at argumentsI-send ang resulta bilang a function_call_output Mga item sa parehong call_idAng pag-iisip, kapag ang modelo ay bumalik ito, ay isang reasoning Mga item sa reasoning_text Ipinanganak ang listahan na unang. status ay incomplete Kapag ang answer hits max_output_tokens o sa mga sumusunod, ayon sa incomplete_details.reason I-set ang max_output_tokens o sa content_filterAng solusyon ay din ayon sa mga setting ng request (temperatura, mga tool, tool choice at iba pa) tulad ng OpenAI ay gawin, at mangyaring ang nymbot Ang object ay mahal.

I-streamed, ang bawat event ay isang event: ang line at a data: Lines sa A sequence_numbersa order na ito: response.created, response.in_progress, response.output_item.added, response.content_part.addedAng anumang bilang ng response.output_text.delta, response.output_text.done, response.content_part.done, response.output_item.doneat pagkatapos ay response.completed Mga pahinang tumuturo sa pag-ibig at kapayapaan response.incomplete sa loob ng isang taon na ang nakalipas response.failedI-reason ang mga streams bilang kanyang sarili na item sa response.reasoning_text.delta at .doneTool calls ay dumating pagkatapos ng mensahe, ang bawat isa ay isang item na may response.function_call_arguments.delta at .done.

Status ngkapag
400Hindi model o sa input; previous_response_id, conversation, background o isang item_reference (unsupported_parameter); isang hindi sumusuportahan na tool o uri ng content.
402, 403, 404, 429, 502, 503Sa pamamagitan ng chat completions.

cURL

curl https://nymbot.ai/api/v1/responses \
  -H "Authorization: Bearer $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5",
    "instructions": "Answer in one short paragraph.",
    "input": "What is a Lightning invoice?"
  }'

Python

import os
from openai import OpenAI

client = OpenAI(base_url="https://nymbot.ai/api/v1", api_key=os.environ["NYMBOT_API_KEY"])

response = client.responses.create(
    model="anthropic/claude-sonnet-5",
    instructions="Answer in one short paragraph.",
    input="What is a Lightning invoice?",
)
print(response.output_text)

JavaScript

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://nymbot.ai/api/v1", apiKey: process.env.NYMBOT_API_KEY });

const response = await client.responses.create({
  model: "anthropic/claude-sonnet-5",
  instructions: "Answer in one short paragraph.",
  input: "What is a Lightning invoice?",
});
console.log(response.output_text);

Mga mensahe ng Anthropic

Ang format ng Anthropic, para sa Anthropic SDKs at Claude Code. Ito ay gumagana sa lahat ng mga modelo sa catalog, hindi lamang Claude: ang request ay inilathala, inilathala sa pamamagitan ng parehong pipeline, at inilathala back.

POST https://nymbot.ai/api/v1/messages — kailangan ng isang API key, tulad ng x-api-key o sa Authorization: Bearer.

ang anthropic-version at anthropic-beta Ang mga anthropic model names ay matatagpuan sa catalog, kaya ang Claude Code at ang SDK ay gumagana sa mga pangalan na ginagamit nila ngayon:

  • Isang pangalan na alam ang catalog, tulad ng claude-sonnet-5 o sa anthropic/claude-opus-5Ito ay ginagamit tulad ng ito.
  • nagtatapos sa tuldok (-20260514), -latestisang version tag tulad ng -v1Ang isang tag ay tulad ng [1m] at isang anthropic/ o sa anthropic. Nagtatapos sa tuldok, nagtatapos sa tuldok, nagtatapos sa tuldok, (claude-haiku-4-5 Maghanap claude-haiku-4.5).
  • Kung hindi pa ito matatagpuan, ginagamit ang pamilya (Opus, Sonnet o Haiku), habang ang bersyon ng catalog ay pareho o mas bagong kaysa sa isa na nangangailangan.
  • Ang isang pangalan na walang katumbas ay bumalik 404 not_found_error.
ang fieldTipongKailanganang description
modelang stringOoAng isang catalog model id, o isang anthropic model name.
max_tokensang integerOoAng pinakamataas na mga tokens upang i-writing.
messagesang arrayOouser at assistant Ipinanganak, sa text, image (base64 o url source) tool_use at tool_result ang mga bloke. thinking Ang mga block mula sa mga nakaraang turn ay nakuha at umalis.
systemang string o arrayHindiSystem prompt, tulad ng isang string o text blocks.
temperature
top_p
ang numberHindiSampling controls, kung saan ang modelo ay may mga ito. top_k Ito ay nakuha at nawala.
stop_sequencesTungkol sa StringsHindiAng text na nagsisimula ng mga solusyon ay may maximum na 4 strings, sa maximum na 256 characters.
tools
tool_choice
Paglalarawan ng ObjectHindiMga tool na name, description at input_schemasa a web_search Ang server tool ay tumutulong sa paghahanap WEBAng iba pang mga built-in na mga tool ng Anthropic (bash, text editor, paggamit ng computer) ay inihayag sa unsupported_tool. tool_choice sa loob auto, any, tool o sa noneat ang disable_parallel_tool_use.
thinkingMga ObjectHindi{"type": "enabled", "budget_tokens": 8192}, {"type": "adaptive"} o sa {"type": "disabled"}Ang budget ay pumili ng isang antas ng effort: sa ilalim ng 2,048 minimum, mula sa 2,048 low, mula sa 8,192 medium, mula sa 16,384 high. output_config.effortO ang high.
streamang booleanHindiI-stream ang event format ng Anthropic.
metadataMga ObjectHindiNakalimutan at ignorado ang

Reaksiyon

{
  "id": "msg_01c7a2f93e5b4d08",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-5",
  "content": [{ "type": "text", "text": "A Lightning invoice is..." }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 1240,
    "output_tokens": 380,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  },
  "nymbot": { "balance": "pro", "charged_credits": 0.162, "charged_sats": 16.2, "balance_credits": 412.425, "balance_sats": 41242.5 }
}

content Pwede kang mag-hire ng tool_use Ang mga block at a thinking Block, kung saan ang signature Siya ay empty. stop_reason ay end_turn, max_tokens, tool_use o sa refusalNagtatapos sa tuldok, tulad ng finish_reason ang Mga Kompleto ng Chat; stop_sequence Always ang null, kahit na ang isang stop sequence ay nagsisimula ang solusyon. input_tokens Ang pag-iisip ng mga ito ay magkakaiba lamang sa mga bagong input; ang pag-iisip ng cache ay sa dalawang mga field ng cache. nymbot Ang object at ang X-Nymbot-Cost-Sats ang header.

I-streamed, ang mga events ay ang Anthropic's: message_start, content_block_start, ping, content_block_delta (text_delta, input_json_delta o sa thinking_delta), content_block_stop, message_delta At dahil diyan, ang paggamit at ang nymbot Ang mga object cost, at message_stopsa a ping sa loob ng isang taon na ang nakalipas ay inilathala sa loob ng isang taon na ang nakalipas tool_use sa pamamagitan ng lahat ng input sa isang input_json_delta.

Ang mga error sa endpoint na ito ay gumagamit ng format ng Anthropic: {"type": "error", "error": {"type": "not_found_error", "message": "…"}}Ang isang short balance ay 402 billing_errorisang overloaded provider 503 overloaded_errorAng isang error pagkatapos ng stream ay nagsimula ay inilathala bilang isang error ang event.

cURL

curl https://nymbot.ai/api/v1/messages \
  -H "x-api-key: $NYMBOT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "What is a Lightning invoice?"}]
  }'

Python

import os
import anthropic

client = anthropic.Anthropic(base_url="https://nymbot.ai/api", api_key=os.environ["NYMBOT_API_KEY"])

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "What is a Lightning invoice?"}],
)
print(message.content[0].text)

JavaScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://nymbot.ai/api", apiKey: process.env.NYMBOT_API_KEY });

const message = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "What is a Lightning invoice?" }],
});
console.log(message.content[0].text);

Tungkol sa Tokens

Ang isang estimate ng antas ng input tokens na ginagamit ng isang Messages request, kaya ang isang client ay maaaring i-check bago ito ay nagpadala.

POST https://nymbot.ai/api/v1/messages/count_tokens — Kailangan ng isang API key. Libre.

Ang katawan ay sama sa mga mensahesa walang max_tokensAng bilang ay isang estimate: ang mga character ng system prompt, mensahe, tool calls at tool definitions divided sa dalawang, plus 1,600 para sa bawat larawan. Ito ay hindi ang provider's own tokenizer, kaya ang tunay na bilang ay maaaring magkakaiba. Ang isang key na nakuha ang kanyang cap ay maaaring gumagamit nito.

Reaksiyon

{ "input_tokens": 318 }

cURL

curl https://nymbot.ai/api/v1/messages/count_tokens \
  -H "x-api-key: $NYMBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5",
    "messages": [{"role": "user", "content": "What is a Lightning invoice?"}]
  }'

Python

import os
import anthropic

client = anthropic.Anthropic(base_url="https://nymbot.ai/api", api_key=os.environ["NYMBOT_API_KEY"])

count = client.messages.count_tokens(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "What is a Lightning invoice?"}],
)
print(count.input_tokens)

JavaScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://nymbot.ai/api", apiKey: process.env.NYMBOT_API_KEY });

const count = await client.messages.countTokens({
  model: "claude-sonnet-5",
  messages: [{ role: "user", content: "What is a Lightning invoice?" }],
});
console.log(count.input_tokens);

Listahan ng mga modelo

Ang listahan ay nabasa mula sa parehong live catalog na ang app's picker, kaya ito ay palagi na kung ano ang server ay gumagana.

GET https://nymbot.ai/api/v1/models — walang kinakailangan ng key. Hide para sa limang minuto.

GET /api/v1/models/{id} Ibalik ang isang entry.

ang fieldTipongKailanganang description
typeMga Tiket sa Paglipad (Hindichat (Ang mga sumusunod ay image, video, audio, embedding o sa allMay mga bagay na dapat gawin, tulad ng image,video.

Ang mga presyo ay kung ano ang ibinibigay mo, na may bayad at margin na magkaroon na, sa dolyar at sa sats sa kasalukuyang presyo ng Bitcoin. balance Sabi ko kung ano ang gastos ng modelo. nymbot_key ang short name ng modelo sa app. created Ito ay always 0, dahil ang catalog ay hindi nag-record kapag isang modelo ay idinagdag. Ang isang modelo na walang na-publish token rates ay priced per_request sa halip.

nymbot/auto Always first, ang hinaharap na variableDahil sa a routes Ang listahan na nagbibigay ng mga rate ng bawat standard na ruta. Itinatag ang visyon at pag-argument, ngunit hindi ang mga tool.

GET /api/v1/models/{id} Nag-akcept ang parehong mga pangalan at alias bilang isang request, at i-returns ang entry para sa modelo na ginagamit nila.

Reaksiyon

{
  "object": "list",
  "data": [
    {
      "id": "anthropic/claude-sonnet-5",
      "object": "model",
      "type": "chat",
      "owned_by": "anthropic",
      "name": "Claude Sonnet 5",
      "created": 0,
      "context_length": 1000000,
      "max_output_tokens": 64000,
      "architecture": { "input_modalities": ["text", "image"], "output_modalities": ["text"] },
      "supported_parameters": ["max_tokens", "temperature", "tools", "tool_choice", "reasoning", "response_format", "stop"],
      "capabilities": { "vision": true, "video": false, "tools": true, "reasoning": true, "web_search": true },
      "balance": "pro",
      "pricing": {
        "type": "per_token",
        "currency": "USD",
        "input_per_1M_tokens": 4.725,
        "output_per_1M_tokens": 23.625,
        "cache_read_per_1M_tokens": 0.4725,
        "sats_input_per_1M_tokens": 4038,
        "sats_output_per_1M_tokens": 20192
      },
      "description": "...",
      "nymbot_key": "claude-sonnet"
    }
  ]
}

Ang iba pang mga tip:

  • Imahe Ang mga entries ay capabilities (accepts_image_url, requires_image_url, edit(Ang isang presyo per_generation.
  • ang video Ang mga entries ay max_duration_seconds at resolutionsat isang presyo per_second Para sa lahat ng resolusyon.
  • ang audio Ang mga entries ay audio_type speech o sa transcriptionang price per_1k_chars o sa per_minute.
  • Mga Embedded Ang mga entries ay dimensions, context_length, max_inputs at isang presyo sa bawat milyong input tokens.

Ang mga presyo ay "estimated": true ang estimate ng app para sa isang generator na ang presyo ay hindi na-publish. type Pagbalik 400.

cURL

curl "https://nymbot.ai/api/v1/models?type=chat"

Python

import requests

models = requests.get("https://nymbot.ai/api/v1/models", params={"type": "chat"}).json()["data"]
for m in models:
    print(m["id"], m["balance"], m["pricing"].get("input_per_1M_tokens"))

JavaScript

const res = await fetch("https://nymbot.ai/api/v1/models?type=chat");
const { data } = await res.json();
for (const m of data) console.log(m.id, m.balance, m.pricing.input_per_1M_tokens);