NezhaGateNezhaGate
doubao-seed-2-1-pro

Doubao Seed 2.1 Pro · API

POST https://nezhagate.com/v1/chat/completions

OpenAI 兼容的对话补全接口,承载字节跳动豆包 Doubao Seed 2.1 Pro —— Seed 2.1 系列旗舰,面向推理、代码与 Agent。默认开启思考,思考过程在 message.reasoning_content 返回,思考 token 按输出价计入 usage.completion_tokens;传 reasoning_effort: "minimal" 通常会跳过思考(实测 10 次中 8 次,不保证;thinking 参数无效)。max_tokens 不限制输出长度,按 usage 实际计费。支持工具调用、JSON 输出、流式输出与图片输入(base64 或公网链接);长回答建议 stream=true。只需把 model 设为 doubao-seed-2-1-pro;目前仅提供 /v1/chat/completions。

在 Playground 试用 →

认证

Header
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

在控制台创建 API Key 后即可调用。

请求参数

参数类型必填说明
model string 是 模型 ID,此处为 doubao-seed-2-1-pro。
messages array 是 对话消息数组,每项含 role(system/user/assistant)与 content。content 可为字符串,或由 {type:text} 与 {type:image_url} 组成的数组以识别图片(多模态/Vision)。
stream boolean 否 是否以 SSE 流式返回。默认 false。
temperature number 否 采样温度,0–2,越高越随机。
max_tokens integer 否 可以传,但不会限制输出长度(实测设为 60 或 100 时仍输出了数百到数千 token),按 usage 实际计费;想要短回答请在提示词里要求简洁。
web_search boolean 否 设为 true 开启联网搜索:网关会先用实时搜索补充资料、再让模型作答并附来源链接(也可在 tools 里传 {"type":"web_search"} 触发)。
reasoning_effort string 否 推理强度。传 "minimal" 通常会跳过思考、直接作答(实测 10 次中 8 次不思考,不保证);不传时默认先思考。thinking 参数对该模型无效。

请求示例

cURL
curl https://nezhagate.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "doubao-seed-2-1-pro", "messages": [{"role": "user", "content": "Hello"}], "stream": false}'

响应示例

200 · JSON
{
  "id": "chatcmpl_xxx",
  "object": "chat.completion",
  "model": "doubao-seed-2-1-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "reasoning_content": "The user is greeting me, so a short friendly reply fits...",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 42,
    "total_tokens": 51,
    "completion_tokens_details": {"reasoning_tokens": 31}
  }
}

图片识别(Vision)

在 messages 的 content 数组里传入图片,即可让模型识别图片内容(看图问答、读图中文字/OCR 等)。image_url 支持公网图片链接,或 base64 内联(data:image/png;base64,...)。多模态模型可用(gpt-5.5、gemini 系列等)。

curl · 图片识别(Vision)
curl https://nezhagate.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "doubao-seed-2-1-pro", "messages": [{"role": "user", "content": [{"type": "text", "text": "这张图里有什么?"}, {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}]}]}'

错误码

错误体统一为 error.message / error.type / error.code / error.param;请按 code 分支,完整清单见接入指南。

HTTPcode说明
401invalid_api_keyAPI Key 缺失或无效
402insufficient_quota余额不足或 Key 超出限额
400invalid_request模型或参数不支持
429rate_limit_exceeded上游限流
502upstream_error所有上游线路失败