コンテンツにスキップ
Nymbot に戻る

知識ベース 開発者

チャット、回答とメッセージ

モデルに何かを尋ねる3つの方法、すでに3つのフォーマットでクライアントが話し、すべて同じモデルで実行され、同じ方法で請求されています。

チャット完成

OpenAIのチャット形式は、ほぼすべてのツールがサポートしているものですが、これまでの会話を送って次のメッセージを返してください。

POST https://nymbot.ai/api/v1/chat/completions APIキーが必要です。

たった model そして messages 選択したモデルが採取しないサンプリングパラメータはエラーなしで落とされますので、一つの要求体はモデル間で動作します。 supported_parameters捨てられたのではなく拒否されたものは、モデルが全くできないことである:見えないモデルの写真、呼べないモデルのツール。

フィールドタイプ必要描写
modelStringはいnymbot/auto (または auto) for Nymbot's routing on the standard balance, or a catalog model id such as anthropic/claude-sonnet-5 プロのバランスを表示します。アプリのショートネームおよびアライセンスも受け入れられます。 足りる.
messagesアレイはい会話・役割 system, developer (システムとして扱う) user, assistant そして toolコンテンツは、 string または list of text そして image_url パーツ; ユーザーメッセージの画像のみ。 input_audio ファイルの部分は拒否されます。
streambooleanノー答えは書いてあるように送ってください。 ストリーミング.
stream_options物体ノー{"include_usage": true} トークンカウントとコストの最終部分を追加します。
max_tokens
max_completion_tokens
インテルノー書くためのトークンが最も多い モデルの最大値に引き下げられ、もし高かったらどのくらいの金額があなたのバランスを保有しているかを設定しますので、より小さい数は開始するためにより少ないクレジットを必要とします。
temperature
top_p
番号ノーサンプルコントロール: temperature 0から2まで、 top_p 0から1まで。
stopstring または arrayノー答えを終わらせるテキスト: 1 文字列または最大 4 文字列、それぞれ最大 256 文字。 nymbot/auto.
seedインテルノーモデルがそれをサポートする繰り返しのサンプル化のために。
presence_penalty
frequency_penalty
番号ノーコントロールは2から2まで繰り返します。
response_format物体ノー{"type": "json_object"} または {"type": "json_schema", "json_schema": {…}}, where the model supports it. Not used by nymbot/auto.
tools
tool_choice
parallel_tool_calls
array, string or object, booleanノー呼び出し機能:見る ツールコール・A web_search ツールが変わる WEB 検索最大 128 ツールと 512 KB の定義で、最大 64 レベルの深さで埋め込まれます。 400.
reasoning_effort
reasoning
ストレッチ、オブジェクトノー"minimal", "low", "medium" または "high"あるいは {"effort": "high"}. "none" または {"enabled": false} 閉じろよ!見ろよ 理論.
pluginsアレイノー[{"id": "web", "max_results": 5}] 常に最初にウェブを検索します. 最大 10 の結果。
nインテルノー第1話 「Anything else returns」 400.
logit_bias
user
metadata
オブジェクト, String, Objectノー受け入れられ、送らなかった。 logit_bias 最大300個のトークンIDを -100から100までの数字にマップします。 user 最大256文字です。 metadata 最大 16 文字列の値、最大 64 文字のキー、最大 512 文字列の値を保持します。

答えは普通の chat.completion, with the cost in usage.cost (ドルで)および nymbot 客体 model is the resolved model id, so a short name comes back as the full one. If the model reasoned before answering, its reasoning is in message.reasoning_content答えから切り離す。

応答

{
  "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 プロバイダが異なるように報告しているため、戻ってきたものから取り組まれています: tool_calls 道具を求めてみると、 length 答えが許可されたすべてのトークンを使用した場合(またはモデルがそれらをすべて推論し、答えを書かなかった場合)、 content_filter プロバイダーが拒否した場合、 stop 別に usage.completion_tokens_details.reasoning_tokens is always 0: hidden reasoning tokens are counted, and charged, in 常に0である。 completion_tokens.

ステータスいつ
400ノー model または messages (missing_required_parameter);それらを見ることができないモデルのオーディオまたはファイルの部分、または画像(unsupported_content(写真20枚以上)too_many_images); サンプルパラメータの間違ったタイプまたは範囲外(invalid_value); 公開されていない画像リンク(invalid_image_url); 彼らを呼ぶことができないモデル上のツール(unsupported_tool); n 1以外のもの:A :thinking 理性ができないモデル(A Model That Can't Reason)model_not_found)または、プロバイダが要求を拒否した場合(upstream_rejected).
402モデルが支出するバランスは、保有をカバーすることはできません。
403最悪の場合、キーのキャップに合わない(key_limit_reached(下) max_tokens もしくはキャップを上げる。
404(この名前のモデルはありません)model_not_found).
429プロバイダの価格制限、またはプロバイダの価格制限(upstream_rate_limited).
502, 503プロバイダが失敗した(upstream_error)または過剰に積み重ねられている(upstream_overloaded, with Retry-After) プロバイダーが試みを請求していない限り、何も請求されません。

各エンドポイント株のステータスコードは、以下に記載されています。 ミス.

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

ストリーミング

同 "stream": true 答えは、サーバーが送信するイベントとして到着し、モデルがそれを書き込みます。 chat.completion.chunk Aさん data: line, and the stream ends with data: [DONE]理性がやってくる delta.reasoning_content答えは in delta.content.

長い答え、大きな答えなど、約100秒以上かかるものをストリーミングする。 max_tokens リクエストがストリーミングされない場合は、回答が完了するまで何も送信されず、あなたとNymbotの間のネットワークは約100秒後に無線接続を終了することがあります; モデルはまだ終了し、書いたものは充電されますが、答えは失われます。

ストリーム

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 BEGINNING WITH : モデルが考えている間、15秒ごとに送信されるコメントです。
  • 頼む "stream_options": {"include_usage": true} to get the last chunk above, with an empty choices, the token counts, the cost and the nymbot 客体
  • ストリームが終了した後で充電が決まります。早期に接続を終了する場合、モデルは停止されません: Nymbot は最大 25 秒間、プロバイダのストリームの残りの部分を読み、そのトークン数を取得し、プロバイダが報告するものを支払います。
  • 最初のエラーは、例えば、 401 または 402, は、ストリームとしてではなく、その状態コードと共に通常の JSON として戻ります. An error after the stream has started arrives as a last data: {"error": {…}} イベント, and the stream ends without [DONE].
  • ツールとモデルによるリクエストは、OpenAIのResponsesの輸送では、プロバイダーから送信されません。

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

ツールコール

機能を表す in tools モデルは、応答する代わりに呼び出されることを要求することができます. You run the function, add its result as a tool 同じメッセージで tool_call_idNymbot は決してあなたの機能を実行しません; モデルの要求をあなたに返します。

tool_choice 取る "auto", "none", "required" または {"type": "function", "function": {"name": "…"}}モデルリストは、どのモデルがツールを呼ぶことができるかをマークします(capabilities.tools) ツールは拒否されます。 400 unsupported_tool は nymbot/auto また、OpenAIのResponsesの輸送で動作する数少ないカタログモデルでは、Nymbotがツールを渡すことができない。

同 "stream": true, a request with tools runs in one piece and is then sent as a normal chunk sequence: the role, one chunk carrying each tool call with its index, id, name and arguments, and the finish chunk. ストリーミングツール呼び出しを読んだクライアントはいつものように処理します。

答えは、部分的に

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

リクエスト中の写真

モデル with capabilities.vision 画像を追加できます♪ image_url part to a user message, with either a public. ユーザーのメッセージに https:// リンク A data:image/…;base64, 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度 平成30年度400 invalid_image_url) オプション detail は auto, low または high.

同 nymbot/auto画像を含むリクエストは、見ることができる標準モデルにルーティングされます。 capabilities.vision 写真を拒否する 400 unsupported_content画像はユーザーのメッセージにのみ表示できます. リンクは公開ホストを指さなければなりません; Nymbot は画像をモデルのプロバイダーに転送し、保存しません。

画像は、リクエストの残りのものと同様に、プロバイダがそれに数える入力トークンとして請求されます。

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

理性

モデル with capabilities.reasoning 答えられる前に考えることができるか?それ以上、それ以上、それ以上を求められるか? reasoning_effort ("minimal", "low", "medium" または "high")または "reasoning": {"effort": "high"}もしくは追加 :thinking モデル名に、これは高い努力を意味します。理由なしのモデルでは、設定が無視されます。 nymbot/auto, :thinking リクエストを標準推論ルートに送信します。

Anthropic モデルでは、努力は約 1,000、2000、8000、または 16,000 トークンの思考予算になります。 max_tokens 考える 考える 考える 考える 考える 考える tool_choice ツールを強制し、リクエストがツールループを継続するとき(その最後のメッセージはツールの結果である)、Anthropic はそれを再開するために以前署名された思考が必要だからです。

論理が戻ってくる message.reasoning_contentあるいは delta.reasoning_content ストリーミング時に、決して答えに混ざることはありません. Reasoning is output and is charged as such, inside completion_tokens一部のプロバイダは、論理テキストを全く返しませんし、それでも請求されます。

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

サプリメントモデル

モデル名のサフィックスは、別のフィールドなしに、リクエストの処理方法を変更します。 anthropic/claude-sonnet-5:online.

足りる効果
:online最初にWebを検索すると、例えば、 plugins: [{"id": "web"}]見る WEB 検索.
:thinking強力な論理的努力; on nymbot/auto理屈ができないモデルで、 400 model_not_found 「“no endpoints found”」
:nitro, :floor, :exacto, :extendedすべてのカタログモデルには1つのルートがありますので、より速く、より安く、またはより長く選択することはありません。

他のいかなる補足も無視されます。 全名は最初に試してみるので、実際のIDにコロンが含まれているモデルはまだ機能します。 それがなければ、補足は、モデルが一致するまで一度ずつ端から取り除かれます。 モデル名は最大200文字の長さで、最大4補足で、より長いものは拒否されます。 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);

Nymbot は最後のユーザー メッセージ (最初の 2,000 文字) を検索し、最高のページを読み、それらを質問されたモデルに渡し、モデルが指示を受けるべきではない外部コンテンツとしてマークします。

  • 常に検索: "plugins": [{"id": "web", "max_results": 5}]あるいはA :online モデルに足りる。
  • 役立つときの検索: "tools": [{"type": "web_search", "parameters": {"max_results": 5}}], also accepted as web_search_preview または openrouter:web_searchNymbot は、質問が現在の情報を必要としているように見えるときにのみ検索します。

max_results 5 はデフォルトで、最大で 10 です。 nymbot.web_search.sources, each with a title, snippet そして url, and as url_citation メッセージへの注釈

実行する各検索コストは0.008ドルで、トークンの上に、トークンに変換され、それはホールドの一部です。読むページも入力トークンです。

答えは、部分的に

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

火の答え

OpenAI Agents SDKとCodexによって使用されるOpenAIの新しいフォーマットで、Chat Completionsと同じモデル、請求および機能で実行されます。

POST https://nymbot.ai/api/v1/responses APIキーが必要です。

フィールドタイプ必要描写
modelStringはいとして チャット完成補足も含まれています。
inputstring または arrayはいA string, or a list of items: messages (roles) メッセージ(ロール) user, assistant, system, developer)と input_text, input_image そして output_text 部品、そして function_call そして function_call_output ツールのための項目 input_image 取る an image_url リンクまたはデータ URL、ファイルIDではありません。 reasoning そして web_search_call アイテムが飛び交う; item_reference 断られています。
instructionsStringノーシステムの指示
max_output_tokensインテルノー書くためのトークンが最も多い。
temperature
top_p
番号ノーサンプルコントロール、モデルがそれらを取る場所。
tools
tool_choice
parallel_tool_calls
array, string or object, booleanノータイトルは「FUNCTION TOOLS」です。{"type": "function", "name": …, "parameters": …}) A web_search または web_search_preview ツールが変わる WEB 検索 ほかの内蔵ツールは拒否されます。
reasoning物体ノー{"effort": "minimal" | "low" | "medium" | "high"}. xhigh そして max 意味 high; none オフにします。
text.format
response_format
物体ノー構造化された出力、JSON スケジュールまたは json_object.
metadata物体ノー最大 16 文字列の値で、最大 64 文字のキーと最大 512 文字の値を返します。
streambooleanノー下記のようにストリームイベント。
storebooleanノー何も保存されていない、そして答えは常に言う。 "store": false.
previous_response_id
conversation
background
String、Object、Booleanノーサポートされていない: 400 unsupported_parameter回答は保存されませんので、会話全体を送信してください。 input 毎回

応答

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

ツールリクエストが表示される output Aとして function_call ポイント with call_id, name そして arguments結果を A として返す function_call_output 同じ項目と同一項目 call_idReasoning, when the model returns it, is a reasoning ポイント with reasoning_text コンテンツは先にリストアップ。 status は incomplete 答えがヒットしたとき max_output_tokens あるいは、供給者が拒否し、 incomplete_details.reason セット 2 max_output_tokens または content_filter答えはまた、OpenAIが行うように、リクエストの設定(温度、ツール、ツールの選択など)に反響し、 nymbot コスト対象

ストリーミング:Every event is a event: ラインとA data: line with a sequence_numberこの順序で: response.created, response.in_progress, response.output_item.added, response.content_part.added, any number of response.output_text.delta, response.output_text.done, response.content_part.done, response.output_item.doneそして、ついに response.completed 使い方とコストと共に. A answer cut short ends with response.incomplete 代わりに、そして流れが始まってから失敗したときには、 response.failedストリームを自分のアイテムとして合理化する response.reasoning_text.delta そして .doneTool calls come after the message, each as an item with the message. ツール呼び出しは、メッセージの後で、それぞれが response.function_call_arguments.delta そして .done.

ステータスいつ
400ノー model または input; previous_response_id, conversation, background あるいは item_reference (unsupported_parameter);サポートされていないツールまたはコンテンツタイプ。
402, 403, 404, 429, 502, 503チャットの完成について

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

ANTHROPIC メッセージ

Anthropicのフォーマットは、Anthropic SDKs と Claude Code で、カタログ内のすべてのモデルだけでなく、Claude だけでなく、リクエストが翻訳され、同じパイプラインを通じて実行され、再度翻訳されます。

POST https://nymbot.ai/api/v1/messages API キーが必要ですが、 x-api-key または Authorization: Bearer.

THE anthropic-version そして anthropic-beta Anthropic model names are matched to the catalog, so Claude Code and the SDKs work with the names they already use: Anthropic model names are matched to the catalog, so Claude Code and the SDKs work with the names they already use. Anthropic model names are matched to the catalog, so Claude Code and the SDKs work with the names they already use:

  • カタログが知っている名前は、 claude-sonnet-5 または anthropic/claude-opus-5使われているように使われています。
  • 日付(-20260514), -latest, a version tag such as -v1, a bracketed tag such as [1m] そして、A anthropic/ または anthropic. オリジナルタイトルは「TOPS」と「TOPS」の2つです。claude-haiku-4-5 発見 claude-haiku-4.5).
  • それがまだ一致しない場合は、カタログのバージョンが要求されたバージョンと同じまたはより新しい限り、ファミリー(Opus、Sonnet、Haiku)を使用します。
  • 何にも合わない名前が返ってくる。 404 not_found_error.
フィールドタイプ必要描写
modelStringはいカタログ モデル id または Anthropic モデル名
max_tokensインテルはい書くためのトークンが最も多い。
messagesアレイはいuser そして assistant ターン、With text, image (base64またはURLソース) tool_use そして tool_result ブロック thinking 以前のターンからのブロックは受け入れられ、落とされます。
systemstring または arrayノーSystem prompt は、文字列またはテキストブロックとして
temperature
top_p
番号ノーサンプルコントロール、モデルがそれらを取る場所。 top_k 受け入れられ、捨てられています。
stop_sequencesARRAY OF STRINGSノー答えを終わらせるテキスト. 最大4つの文字列、それぞれ最大256文字。
tools
tool_choice
アーレイ、オブジェクトノーツール with name, description そして input_schema・A web_search サーバーツールが起動 WEB 検索; Anthropic の他の内蔵ツール(バッシュ、テキストエディター、コンピュータ使用)は、 unsupported_tool. tool_choice 取る auto, any, tool または noneそして、 disable_parallel_tool_use.
thinking物体ノー{"type": "enabled", "budget_tokens": 8192}, {"type": "adaptive"} または {"type": "disabled"}予算は、努力レベルを選択します: 最低2048以下、低2048から、中間8192から、高16384から。 output_config.effortあるいは高い。
streambooleanノーAnthropicのイベント形式でストリーム。
metadata物体ノー受け入れられ、無視される。

応答

{
  "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 持つこともできる tool_use ブロック A thinking ブロック、誰の signature 空っぽです。 stop_reason は end_turn, max_tokens, tool_use または refusal同じように働き、 finish_reason は チャット完成; stop_sequence 常に nullたとえ一つの停止シーケンスが答えを終わらせたとしても。 input_tokens 新鮮な入力のみがカウントされます; キャッシュされた入力は、2つのキャッシュフィールドにあります。 nymbot Object and the X-Nymbot-Cost-Sats ヘッダー

ストリーミング、イベントはAnthropicのもの: message_start, content_block_start, ping, content_block_delta (text_delta, input_json_delta または thinking_delta), content_block_stop, message_delta 停止の理由、使用および nymbot コストオブジェクト、そして message_stop・A ping モデルが動作している間も15秒ごとに送信されます。ツール呼び出しはテキストの後に到着します。 tool_use block with its entire input in one. ブロックとそのすべての入力 1 input_json_delta.

このエンドポイントのエラーは Anthropic のフォーマットを使用します: {"type": "error", "error": {"type": "not_found_error", "message": "…"}}短いバランスは 402 billing_error過剰な供給者 503 overloaded_errorストリームが始まってからエラーが送信されます。 error イベント

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

トークン数

Messages リクエストで使用する入力トークンの数を推定し、クライアントが送信する前にチェックできるようにします。

POST https://nymbot.ai/api/v1/messages/count_tokens タグ : タグ : タグ : タグ : 無料

身体は、それと同じように、 メッセージ無し max_tokensモデル名は解決しなければなりません。カウントは推定です:システムプロンプト、メッセージ、ツール呼び出し、ツール定義の文字は4つに分かれ、それぞれの画像のための1600を加えて。

応答

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

モデルリスト

API が受け入れるすべてのモデルとジェネレータは、そのコストとともに、アプリのピッカーと同じライブカタログから読み取られますので、サーバーが常に実行するものです。

GET https://nymbot.ai/api/v1/models 鍵は必要ありませんが、5分間隠しておきます。

GET /api/v1/models/{id} 1 入力を返す

フィールドタイプ必要描写
typeString(クエリー)ノーchat (デフォルトは、 image, video, audio, embedding または allいくつかは与えられますが、例えば、 image,video.

価格はあなたが支払うものであり、手数料とマージンは既に、ドルで、現在のビットコイン価格で割り当てられている。 balance モデルがどのバランスを費やしているかを示す。 nymbot_key アプリ内のモデルの短い名前です。 created 常に0であるため、カタログはモデルが追加されたときに記録しません。 per_request その代わり。

nymbot/auto 常に最初に、価格として variable, with a routes 各標準ルートの料金を示すリスト ビジョンと推論をリストしますが、ツールではありません。

GET /api/v1/models/{id} 同一の名前とアライセンスをリクエストとして受け入れ、リクエストしたモデルのエントリを返します。

応答

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

その他のタイプ:

  • 画像 入場有 capabilities (accepts_image_url, requires_image_url, edit)および価格 per_generation.
  • 動画 入場有 max_duration_seconds そして resolutionsそして、価格は per_second それぞれの決議について
  • オーディオ 入場有 audio_type speech または transcription価格 per_1k_chars または per_minute.
  • 組み込む 入場有 dimensions, context_length, max_inputs 入力トークンの100万枚当たりの値段

マーク価格 "estimated": true 価格が公表されていないジェネレーターのアプリの推定値です。 type 復帰 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);