智枢网关NEXUSGATE
API 参考

Chat Completions

OpenAI 兼容的对话补全接口

POST https://netnexus.top/api/v1/chat/completions

请求参数

参数类型必填说明
modelstring是模型 ID,见模型广场
messagesarray是对话消息列表,结构见下文
streamboolean否是否流式返回,默认 false
stream_optionsobject否流式选项,如 {"include_usage": true} 返回用量
temperaturenumber否采样温度,越高越随机
top_pnumber否核采样概率阈值
max_tokensinteger否最多生成的 token 数
stopstring / array否遇到这些字符串时停止生成
toolsarray否可供调用的工具列表,见函数调用
tool_choicestring / object否工具调用策略,如 auto、none
response_formatobject否输出格式,见结构化输出
ninteger否生成的候选回答数量
presence_penaltynumber否话题新鲜度惩罚
frequency_penaltynumber否重复度惩罚
userstring否终端用户标识,便于排查问题

个别参数是否生效取决于具体模型,例如部分推理模型会忽略 temperature。

messages 结构

字段类型说明
rolestringsystem、user、assistant 或 tool
contentstring / array消息内容;多模态时为数组,见视觉理解
tool_callsarrayassistant 消息中模型发起的工具调用
tool_call_idstringtool 消息对应的工具调用 ID

请求示例

curl https://netnexus.top/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.7-plus",
    "messages": [{ "role": "user", "content": "你好" }],
    "temperature": 0.7,
    "max_tokens": 1024
  }'

返回示例

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1790000000,
  "model": "qwen3.7-plus",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "你好!有什么可以帮你?" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 10, "total_tokens": 19 }
}
字段说明
id本次请求的唯一 ID
object固定为 chat.completion
created创建时间(Unix 时间戳,秒)
model实际使用的模型
choices[].message模型生成的消息
choices[].finish_reason结束原因:stop、length、tool_calls 等
usagetoken 用量

流式返回

stream: true 时,按 SSE 格式逐块返回,每块的 object 为 chat.completion.chunk,增量内容在 choices[].delta 中:

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"你好"}}]}

data: [DONE]

本页目录

联系商务

为您的企业定制 AI 接入方案

微信同号,在微信中搜索手机号即可添加