跳至内容
回到Nymbot

知识库 开发者

聊天,回复和消息

有三种方式来询问一个模型,在三个格式中客户已经说话,所有这些都运行在相同的模型上,并以相同的方式发票。

Chat 完成

OpenAI聊天格式,几乎每个工具都支持的格式. 发送到目前为止的对话并收到下一个消息。

POST https://nymbot.ai/api/v1/chat/completions 需要一个 API 密钥。

只有 model 和 messages 选择的模型不采取的样本参数没有出现错误,所以一个请求器官在模型之间工作。 supported_parameters被拒绝的,而不是被抛弃的,是模特根本做不到的东西:看不见的模特的照片,不能呼叫的模特的工具。

场地类型需要描述
model线条是的nymbot/auto (或 auto)对于Nymbot在标准平衡上的路由,或一个目录模型ID,如 anthropic/claude-sonnet-5 在 Pro 平衡上。应用程序的简称和副名称也被接受。 足够.
messages阿雷尔是的交谈,角色 system, developer (作为系统的处理), user, assistant 和 tool内容是一个字符串或列表 text 和 image_url 部分;图片仅在用户消息中。 input_audio 檔案部分被拒絕。
stream布莱尔没有答案正如它所写的那样发送。 流媒体.
stream_options对象没有{"include_usage": true} 添加了最后一部分与代币计数和成本。
max_tokens
max_completion_tokens
整體没有最多的代币写下来. 降至模型的最大值如果更高. 也设置了从你的余额中持有多少,所以较小的数字需要更少的信贷开始。
temperature
top_p
号码没有样品控制: temperature 从 0 到 2, top_p 从 0 到 1
stopstring 或 array没有答案结束的文本:一个字符串或最多4个字符串,每个字符最多256个字符。 nymbot/auto.
seed整體没有用于可重复采样,在模型支持时。
presence_penalty
frequency_penalty
号码没有重复控制,每个从 -2 到 2。
response_format对象没有{"type": "json_object"} 或 {"type": "json_schema", "json_schema": {…}},其中模型支持它. 未使用 nymbot/auto.
tools
tool_choice
parallel_tool_calls
数组,字符串或对象,布尔没有调用功能:见 工具呼叫」 A web_search 工具变成 网站搜索最多 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章 其他一切都回来了 400.
logit_bias
user
metadata
物体、字符串、物体没有已接收,未发送。 logit_bias 最多300个代币ID的地图到从 -100到100的数字; user 最多是256个字符。 metadata 包含最多 16 个字符串值、最多 64 个字符的键和最多 512 个值。

答案是普通的 chat.completion随着成本在 usage.cost (美元)和在 nymbot 对象。 model 是解决的模型id,所以一个短名返回为完整的。 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 总是 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 对一个不能合理的模型的补充(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,与 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: 线,和流结束与 data: [DONE]理性来到了 delta.reasoning_content答案在 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]
  • 线开始于 : 每15秒钟发送的评论,而模特正在思考。
  • 请求 "stream_options": {"include_usage": true} 要得到上面的最后一块,与一个空的 choices,代币计数,成本和 nymbot 对象。
  • 如果您提前关闭连接,模型不会停止:Nymbot会读取提供商的其余流量,长达25秒,以获得其代币数目,您会支付提供商报告的费用。
  • 在第一个片段之前的错误,如 401 或 402,以其状态代码作为普通的 JSON 返回,而不是作为流。 data: {"error": {…}} 事件,而流程没有结束 [DONE].
  • 使用工具的请求,以及OpenAI的响应传输上的模型,不会从提供商传输,他们仍然会用有效的流来响应,一旦答案完成,就会发送。

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

工具呼叫

描述函数在 tools 并且模型可以要求一个被调用而不是响应。你运行该函数,将其结果添加为一个 tool 同样的消息 tool_call_idNymbot 永遠不會執行您的功能;它將模型的要求傳回給您。

tool_choice 得 "auto", "none", "required" 或 {"type": "function", "function": {"name": "…"}}模型列表标记哪些模型可以调用工具(capabilities.tools) 工具被拒绝 400 unsupported_tool 是 nymbot/auto 以及在OpenAI的响应传输上运行的少数目录模型上,Nymbot无法传输工具。

与 "stream": true,一个有工具的请求运行在一个部分,然后作为一个正常的片段序列发送:角色,一个片段携带每个工具调用,其索引,ID,名称和参数,以及终端片段。

答案,部分

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

图片在请求中

模型与 capabilities.vision 可以阅读图片. 添加 image_url 分享到一个用户消息,与一个观众 https:// 链接或A data:image/…;base64, 网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网页网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);

理性

模型与 capabilities.reasoning 在回答之前,你可以想一想,或多或少地问。 reasoning_effort ("minimal", "low", "medium" 或 "high")或 "reasoning": {"effort": "high"},或添加 :thinking 到模型名称,这意味着高努力. 在没有推理的模型上,设置被忽略。 nymbot/auto, :thinking 将请求发送到标准推理路径。

在人类模型上,努力成为大约1000、2000、8000或16000个代币的思维预算,从不超过 max_tokens 允许!思考被抛弃时 tool_choice 强迫一个工具,当请求继续一个工具循环(其最后的消息是工具结果),因为Anthropic需要先前签署的思维来恢复它。

理性回归于 message.reasoning_content,或 delta.reasoning_content 当流时,从不混合到答案中. 理性是输出,并且作为这样被收取,内部 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搜索网页首先,如 plugins: [{"id": "web"}]看 网站搜索.
:thinking高度的理性努力;在 nymbot/auto,推理路径. 在一个不能推理的模型上, 400 model_not_found 与 “没有发现的终点”。
:nitro, :floor, :exacto, :extended每个目录模型都有一个路径,所以没有更快、更便宜或更长的路径可供选择,因此可以使用后缀,以便从其他服务中复制的模型名称仍然有效。

任何其他附加字符都被忽略了. 整个名称首先被尝试,所以一个模型,其ID确实包含一个结肠;如果不这样做,附加字符会随时取出结尾,直到一个模型匹配。 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搜索最后的用户消息(其前2000个字符),读取最好的页面,并将其交给模型有问题,标记为外部内容,模型不应该从中接收指示。

  • 总是寻找: "plugins": [{"id": "web", "max_results": 5}],或 A :online 足以在模型上。
  • 寻找当它有帮助: "tools": [{"type": "web_search", "parameters": {"max_results": 5}}]也被接受为 web_search_preview 或 openrouter:web_searchNymbot 只在问题看起来需要当前信息时进行搜索,这也是应用程序使用的测试。

max_results 5 是默认的,最多 10 是源返回 nymbot.web_search.sources,每一个与A title, snippet 和 url,并作为 url_citation 留言中的注释。

每个搜索运行成本为 $0.008,转换为 sats,在代币的顶部,它是持有的一部分. 它读到的页面也是输入代币,所以来自网络的答案比同一个问冷的问题更贵,有时是几倍。

答案,部分

"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 的更新的格式,由 OpenAI 代理商 SDK 和 Codex 使用,运行在与 Chat Completions 相同的模型、计费和功能上。

POST https://nymbot.ai/api/v1/responses 需要一个 API 密钥。

场地类型需要描述
model线条是的如为 Chat 完成添加了补充。
inputstring 或 array是的一个字符串或项目列表:消息(角色) user, assistant, system, developer)与 input_text, input_image 和 output_text 部分,以及 function_call 和 function_call_output 工具的物品。 input_image 拿一个 image_url 链接或数据 URL,而不是文件ID。 reasoning 和 web_search_call 物品被淘汰; item_reference 被拒绝。
instructions线条没有系统指示。
max_output_tokens整體没有写作最多的人
temperature
top_p
号码没有样本控制,模型将它们带到哪里。
tools
tool_choice
parallel_tool_calls
数组,字符串或对象,布尔没有功能工具,在答案格式({"type": "function", "name": …, "parameters": …}) A web_search 或 web_search_preview 工具变成 网站搜索 当它有帮助时,其他内置工具被拒绝。
reasoning对象没有{"effort": "minimal" | "low" | "medium" | "high"}. xhigh 和 max 意思 high; none 把它关掉。
text.format
response_format
对象没有结构化输出,如 JSON 方案或 json_object.
metadata对象没有返回不变的响应. 最多 16 个字符串值,最多 64 个字符和最多 512 个值的键。
stream布莱尔没有流式事件如下所述。
store布莱尔没有被忽略. 没有任何东西被储存,答案总是说 "store": false.
previous_response_id
conversation
background
字符串, 对象, 布尔没有不支持: 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 题与 call_id, name 和 arguments将结果返回为 a function_call_output 与相同的项目 call_id理性,当模型返回它时,是一个 reasoning 题与 reasoning_text 内容,先列出。 status 是 incomplete 当答案击中 max_output_tokens 或拒绝提供者。 incomplete_details.reason 设置为 max_output_tokens 或 content_filter该响应也响应了请求的设置(温度、工具、工具选择等),就像OpenAI所做的那样,并携带了 nymbot 物体成本。

流媒体,每一个事件都是一个 event: 线和A data: 线与A sequence_number,按照这个顺序: response.created, response.in_progress, response.output_item.added, response.content_part.added任何数量的 response.output_text.delta, response.output_text.done, response.content_part.done, response.output_item.done,最后 response.completed 使用和成本. 一个答案缩短的结尾与 response.incomplete 相反,在流量开始后,一个失败 response.failed理性流作为它自己的项目与 response.reasoning_text.delta 和 .done工具呼叫接到消息后,每一个作为一个项目 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 SDK 和 Claude Code. 它适用于目录中的每个模型,而不仅仅是 Claude:请求被翻译,通过相同的管道运行,并被翻译回来。

POST https://nymbot.ai/api/v1/messages 需要一个 API 密钥,如 x-api-key 或 Authorization: Bearer.

该 anthropic-version 和 anthropic-beta 人类模型名称与目录相匹配,因此 Claude Code 和 SDK 可以使用他们已经使用的名称:

  • 一个名称,目录知道,如 claude-sonnet-5 或 anthropic/claude-opus-5它是使用的,正如它是。
  • 另一个日期( )-20260514), -latest,一个版本标签,如 -v1,一个布拉克特的日期,如 [1m] 和一个 anthropic/ 或 anthropic. 图标和图标在两个版本中都被试图使用(claude-haiku-4-5 发现 claude-haiku-4.5).
  • 如果这仍然不匹配,则使用家族(Opus,Sonnet或Haiku),只要目录的版本与所请求的版本相同或更新。
  • 一个与没有匹配的名字返回 404 not_found_error.
场地类型需要描述
model线条是的目录模型ID,或人类模型名称。
max_tokens整體是的写作最多的人
messages阿雷尔是的user 和 assistant 转,与 text, image (base64 或 URL 源) tool_use 和 tool_result 区块。 thinking 以前轮回的块被接受和放弃。
systemstring 或 array没有系统提示,如字符串或文本块。
temperature
top_p
号码没有样本控制,模型将它们带到哪里。 top_k 被接受和放弃。
stop_sequencesArray 的 Strings没有答案结尾的文本 最多 4 个字符串,每个字符最多 256 个字符。
tools
tool_choice
,对象没有工具与 name, description 和 input_schema」 A web_search 服务器工具转换 网站搜索;Anthropic的其他内置工具(bash、文本编辑器、计算机使用)被拒绝使用 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或者高。
stream布莱尔没有在 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 是 Chat 完成; stop_sequence 总是 null,即使停止序列结束了答案。 input_tokens 新鲜输入仅计数;缓存输入在两个缓存字段中。 nymbot 对象和 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 区块,其全部输入在一个 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);

计数代币

估计一个消息请求会使用多少输入代币,以便客户端在发送之前可以检查。

POST https://nymbot.ai/api/v1/messages/count_tokens 需要一个 API 密钥。

身体是相同的为 信息,没有 max_tokens;模型名称必须解决。计数是一个估计:系统提示、消息、工具调用和工具定义的字符分为四个,加上每张图像的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 条入口

场地类型需要描述
type查询(Query)没有chat (缺陷) image, video, audio, embedding 或 all可以提供几种,如 image,video.

价格是你支付的,费用和利润已经在美元和在当前比特币价格的价格。 balance 表明模型花费的平衡。 nymbot_key 是 app 中的模型的简称。 created 總是0,因為目錄沒有記錄當一個模型被添加時。 per_request 反而。

nymbot/auto 总是第一,价格为 variable,与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 一百万个入口代币的价格。

标记价格 "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);