VibeAPIVibeAPI 开发者文档

OpenAI Responses

全部 31 个请求参数、响应字段与流式事件类型。OpenAI 家族模型的推荐入口

POST /v1/responses

OpenAI 对新项目推荐这个端点而不是 Chat Completions,Chat 仍受支持但不再是首选。 公开理由集中在几点:推理模型上表现更好、提示缓存命中率显著更高(因而更便宜)、 可用 previous_response_id 跨轮保留推理与工具上下文、内置工具只在这一侧提供。

在 VibeAPI 上,GPT 系模型的推荐入口就是这里。 走这个端点的模型见 模型与入口;Claude 系请去 Messages

基本调用

建议用官方 SDK 而不是自己拼 HTTP——SSE 解析、工具参数分片拼接、超时与重试都由它处理,能避开大部分常见问题。安装与环境变量配置见快速开始

curl -N -X POST "https://www.vibeapi.cn/v1/responses" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-astra",
    "instructions": "你是一个简洁的助手。",
    "input": "用一句话解释什么是幂等。",
    "stream": true
  }'
from openai import OpenAI

client = OpenAI(base_url="https://www.vibeapi.cn/v1", api_key="YOUR_API_KEY")

stream = client.responses.create(
    model="gpt-6-astra",
    instructions="你是一个简洁的助手。",
    input="用一句话解释什么是幂等。",
    stream=True,
)

for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://www.vibeapi.cn/v1",
  apiKey: "YOUR_API_KEY",
});

const stream = await client.responses.create({
  model: "gpt-6-astra",
  instructions: "你是一个简洁的助手。",
  input: "用一句话解释什么是幂等。",
  stream: true,
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") process.stdout.write(event.delta);
}

认证

Authorization: Bearer <API_KEY>base_urlhttps://www.vibeapi.cn/v1。 官方 SDK 换掉 base_url 即可。

流式要求

请求超时上限 120 秒。非流式请求在生成完成前没有数据下行,单次生成超过这个时间会被 中断。短输出不受影响;推理模型要等整段推理结束才返回首字节,容易触发上限。 建议默认开启流式,需要完整文本时在客户端聚合 response.output_text.delta

与 Chat 的差异

从 Chat 迁过来最容易卡在这里,先看懂再往下写代码。

Chat 的输入输出都是 Message 数组;Responses 用 Item。Item 是联合类型, message 只是其中一种,function_callfunction_call_outputreasoning 各是独立的 一种——不再像 Chat 那样把多种含义塞进同一个对象。

响应形状也跟着变:Chat 返回 choices 数组、每项裹一个 message;Responses 返回一个 带自己 idresponse 对象,产出在 output 数组里。Chat 用 n 一次要多个结果的 能力在这里去掉了,一次只有一个生成结果。

Chat CompletionsResponses
输入单位messages(Message)input(Item,也可直接给字符串)
系统指引messages 里的 system 角色instructions
产出位置choices[0].message.contentoutput 数组 / output_text
输出上限max_completion_tokensmax_output_tokens
多轮自己把历史拼回 messagesprevious_response_id
推理强度reasoning_effortreasoning.effort

请求参数

参数名、类型与语义对齐 OpenAI Responses API。每个参数先给官方定义,再以「网关」标注本网关的实测行为。 GPT 系模型的请求体不经改写,整个参数面照单转发;标注含义:支持=有可观测证据生效;接受=正常受理、效果取决于模型本身;无效=本网关不提供这项能力。

核心

modelstring必填

用于生成响应的模型 ID。走这个端点的模型见模型与入口

inputstring | array必填

给模型的文本、图片或文件输入。单轮问答直接给字符串;多轮、带工具结果或多模态时给 Item 数组。

instructionsstring

插入模型上下文的系统(或 developer)消息。与 previous_response_id 同用时,上一轮的 instructions 不会带到下一轮,便于在多轮间替换指令——需要每轮都带。

多轮与状态

previous_response_idstring

上一次响应的唯一 ID,用于构建多轮对话:推理与工具上下文跨轮保留。不能与 conversation 同用。

网关 · 支持。 这是相对 Chat Completions 最实际的收益。

conversationstring | object

本次响应所属的会话:会话里的 Item 会前置到本次输入,本次的输入输出也会自动追加进会话。

网关。 依赖服务端存储,不保证可用。

storeboolean默认 true

是否保存生成的响应,供之后通过 API 取回;用 previous_response_id 串多轮时需要为 true

includearray

要求响应额外带回的数据,如 reasoning.encrypted_contentmessage.output_text.logprobs、内置工具调用的中间产物。接受。

context_managementarray

上下文管理配置,目前只有 compaction:达到 compact_threshold 个 token 时触发压缩。接受。

输出控制

streamboolean默认 false

true 时以 server-sent events 边生成边返回。

网关。 单次请求上限 120 秒,推理模型建议设为 true,见流式要求

stream_optionsobject

流式选项,仅在 stream: true 时设置(如 include_obfuscation)。接受。

max_output_tokensinteger

本次响应可生成的 token 上限,包含可见输出与推理 token。不够时返回 status: "incomplete"incomplete_details.reasonmax_output_tokens,且可能一个可见字符都没产出就已计费。给推理模型留足空间。

textobject

文本响应的配置:纯文本或结构化 JSON。结构化输出写在 {"format": {"type": "json_schema", ...}};能否严格遵守取决于模型。

truncationstring默认 disabled

auto 时输入超出上下文窗口会从对话开头丢弃 Item 以适配;disabled 时超出即报 400。接受。

backgroundboolean默认 false

以后台任务方式运行响应,之后轮询取结果。

网关 · 无效。 不提供后台任务接口。

推理

reasoningobject

推理模型的配置。effort 约束推理投入(none / minimal / low / medium / high / xhigh / max,支持的取值与默认值随模型而异);summary 要求返回推理摘要(auto / concise / detailed)。

工具调用

toolsarray

模型可调用的工具数组:内置工具(联网搜索、文件检索、代码解释器、图像生成、远程 MCP 等)、函数工具、自定义工具。用 tool_choice 指定使用方式。

网关。 函数工具完整;内置工具不保证可用,也不保证与官方一致。

tool_choicestring | object

模型如何选择工具:none / auto / required,或指定某个函数、某类内置工具。

parallel_tool_callsboolean默认 true

是否允许模型并行执行工具调用。接受。

max_tool_callsinteger

一次响应内内置工具调用的总次数上限,跨所有内置工具计数,超出的调用被忽略。接受。

提示缓存

promptobject

引用服务端保存的提示模板及其变量(idversionvariables)。

网关。 依赖服务端存储,不保证可用。

prompt_cache_keystring

用于把相似请求路由到同一缓存,提高提示缓存命中率;取代 user 字段的缓存用途。

网关 · 支持。 相同前缀的请求 usage.input_tokens_details.cached_tokens 能读到命中量,auto 与官方满血两类 key 都可用。Responses 相对 Chat 的省钱优势主要来自缓存,值得用起来。

prompt_cache_optionsobject

提示缓存选项,gpt-5.6 及以后支持:mode: "explicit" 关闭隐式断点,ttl 目前只支持 30m接受。

prompt_cache_retentionstring

已弃用,改用 prompt_cache_options.ttl。设为 24h 延长缓存保留。接受。

采样与标识

temperaturenumber默认 1

采样温度,02。越高越随机,越低越集中;一般只调它或 top_p 之一。

网关。 部分推理模型忽略它或只接受默认值,取决于模型。

top_pnumber默认 1

核采样,替代温度:只考虑累计概率达到 top_p 的那部分 token。

top_logprobsinteger

每个位置返回最可能的 020 个 token 及其对数概率,需在 include 里加 message.output_text.logprobs接受。

metadataobject

最多 16 对键值,键 ≤ 64 字符、值 ≤ 512 字符,随对象存储、可供查询。接受。

safety_identifierstring

帮助识别可能违反使用政策的终端用户的稳定标识,≤ 64 字符,建议用用户名或邮箱的哈希。接受。

userstring

终端用户的稳定标识,正被 safety_identifierprompt_cache_key 取代。接受。

service_tierstring

处理类型:auto / default / flex / priority 等。

网关。 由网关自行路由,该字段无意义。

moderationobject

对输入与输出运行内容审核的配置(modelpolicy)。接受。

响应字段

{
  "id": "resp_...",
  "object": "response",
  "status": "completed",
  "model": "gpt-6-astra",
  "output": [
    { "type": "reasoning", "id": "rs_...", "summary": [] },
    {
      "type": "message",
      "id": "msg_...",
      "role": "assistant",
      "content": [{ "type": "output_text", "text": "同一个操作执行多次和执行一次效果相同。" }]
    }
  ],
  "usage": {
    "input_tokens": 32,
    "output_tokens": 18,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 50
  }
}
idstring

本次响应的 id,多轮时作为下一轮的 previous_response_id

statusstring

completed / incomplete / in_progress / failed

incomplete_details.reasonstring

statusincomplete 时的原因,最常见是 max_output_tokens

outputarray

产出的 Item 数组。类型是混排的——reasoningmessagefunction_call 都可能出现, 取正文务必按 type 过滤,不要直接取 output[0]

output_textstring

官方 SDK 提供的便捷字段,把所有 output_text 片段拼好。裸 HTTP 调用时没有这个字段, 需要自己从 output 里取。

usage.output_tokens_details.reasoning_tokensinteger

不可见的推理 token 数,计费但不出现在正文里。推理模型上对账要看这个。

流式事件

事件是有类型的,按 type 分发,不像 Chat 那样只有一种 chunk:

event: response.created
data: {"type":"response.created","response":{"id":"resp_...","status":"in_progress"}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"同一个"}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_...","status":"completed"}}

常见事件类型:

response.created生命周期

响应已创建,此时能拿到 id

response.output_item.added生命周期

新增一个输出 Item(一条消息、一次函数调用、一段推理)。

response.output_text.delta内容

正文增量。只认这一种就够取全文了。

response.function_call_arguments.delta内容

函数调用参数的增量 JSON 片段,需自行累积拼接。

response.reasoning_summary_text.delta内容

推理摘要增量,需在 include 里要求才会出现。

response.completed生命周期

结束,带完整的 response 对象与 usage

response.failed / response.incomplete生命周期

异常结束。要处理这两种,否则失败会表现为「流断了但没报错」。

参数改写规则

模型触发条件网关的动作
grok-*tools 里含 web_search 类型的内置工具移除该工具,其余工具保留
grok-*reasoning.effortnone改写为 low

Claude 系模型也有一组改写规则(thinkingtemperaturetop_p),见 Messages 页——从本页调用 Claude 时同样适用。

分组差异

key 分两类:auto(可以调用全部模型)和 Claude 官方满血版对 GPT 系模型,两类 key 实测没有差异——提示缓存与内置工具在两边都可用。 差异只出现在 Claude 系模型上,见 Messages 页。

真实响应示例

下面是从生产网关真实抓取、脱敏后的流式响应(中间的增量事件已省略):

请求 POST /v1/responses

{  "model": "gpt-6-astra",  "input": "用一句话解释幂等",  "max_output_tokens": 120,  "stream": true}

响应

event: response.createddata: {"type": "response.created", "response": {"id": "resp_XXXXXXXX", "object": "response", "created_at": 1788981580, "status": "in_progress", "background": false, "completed_at": null, "error": null, "frequency_penalty": 0.0, "incomplete_details": null, "instructions": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended goal is … }event: response.in_progressdata: {"type": "response.in_progress", "response": {"id": "resp_XXXXXXXX", "object": "response", "created_at": 1788981580, "status": "in_progress", "background": false, "completed_at": null, "error": null, "frequency_penalty": 0.0, "incomplete_details": null, "instructions": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended goa … }event: response.output_item.addeddata: {"type": "response.output_item.added", "item": {"id": "msg_XXXXXXXX", "type": "message", "status": "in_progress", "content": [], "phase": "final_answer", "role": "assistant"}, "output_index": 0, "sequence_number": 2}event: response.content_part.addeddata: {"type": "response.content_part.added", "content_index": 0, "item_id": "msg_0c0a8e4ee5a08f72016aa1b14db0e887d1b120b6aab675b83e", "output_index": 0, "part": {"type": "output_text", "annotations": [], "logprobs": [], "text": ""}, "sequence_number": 3}event: response.output_text.deltadata: {"type": "response.output_text.delta", "content_index": 0, "delta": "幂", "item_id": "msg_0c0a8e4ee5a08f72016aa1b14db0e887d1b120b6aab675b83e", "logprobs": [], "obfuscation": "gWRDTzx6xQymvmA", "output_index": 0, "sequence_number": 4}… 中间的增量事件省略 …event: response.output_item.donedata: {"type": "response.output_item.done", "item": {"id": "msg_XXXXXXXX", "type": "message", "status": "completed", "content": [{"type": "output_text", "annotations": [], "logprobs": [], "text": "幂等是指同一个操作执行一次或多次,对系统产生的最终效果相同,比如把状态设为“已完成”。"}], "phase": "final_answer", "role": "assistant"}, "output_index": 0, "sequence_number": 35}event: response.completeddata: {"type": "response.completed", "response": {"id": "resp_XXXXXXXX", "object": "response", "created_at": 1788981580, "status": "completed", "background": false, "completed_at": 1788981582, "error": null, "frequency_penalty": 0.0, "incomplete_details": null, "instructions": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended g … }

真实调用抓取并脱敏 · 2026-09-09

非流式的完整响应对象:

请求 POST /v1/responses

{  "model": "gpt-6-astra",  "input": "用一句话解释幂等",  "max_output_tokens": 120}

响应

{  "id": "resp_XXXXXXXX",  "object": "response",  "created_at": 1788981584,  "status": "completed",  "background": false,  "completed_at": 1788981586,  "error": null,  "frequency_penalty": 0.0,  "incomplete_details": null,  "instructions": "You are Codex, an agent based on GPT-6. You and the user share one workspace, and your job is to collaborate with them until their intended goal is completely handled.\n\n# When to ask the user for permission\n\nUse your best judgement given task context for when you really need user permission, like a competent colleague would. Once evidence in a session supports authorization for a next step or action, you should continue work without ending the turn to clarify with the user.\n\nUser authorization and preferences persist across turns. Do not request permission again when the user has already autho …",  "max_output_tokens": null,  "max_tool_calls": null,  "model": "gpt-6-astra",  "moderation": null,  "output": [    {      "id": "msg_XXXXXXXX",      "type": "message",      "status": "completed",      "content": [        {          "type": "output_text",          "annotations": [],          "logprobs": [],          "text": "幂等是指同一个操作执行一次或多次,产生的效果相同,例如把某个值设为 0,无论执行多少次,结果都是 0。"        }      ],      "phase": "final_answer",      "role": "assistant"    }  ],  "parallel_tool_calls": true,  "presence_penalty": 0.0,  "previous_response_id": null,  "prompt_cache_key": "9b88df7e-a1fe-4340-a349-670193d095df",  "prompt_cache_retention": "24h",  "reasoning": {    "context": "all_turns",    "effort": "medium",    "mode": "standard",    "summary": null  },  "safety_identifier": "user-tsre293Bt6famG6fWo23ds3L",  "store": false,  "temperature": 1.0,  "text": {    "format": {      "type": "text"    },    "verbosity": "medium"  },  "tool_choice": "auto",  "tool_usage": {    "image_gen": {      "input_tokens": 0,      "input_tokens_details": {        "image_tokens": 0,        "text_tokens": 0      },      "output_tokens": 0,      "output_tokens_details": {        "image_tokens": 0,        "text_tokens": 0      },      "total_tokens": 0    },    "web_search": {      "num_requests": 0    }  },  "tools": [],  "top_logprobs": 0,  "top_p": 0.98,  "truncation": "disabled",  "usage": {    "attribution": {      "items": {        "msg_035dea8bac625f7d016aa1b150627487d18e3ca303c0a9261a": {          "cache_write_tokens": 0,          "cached_tokens": 0,          "content": [            {              "cache_write_tokens": 0,              "cached_tokens": 0,              "input_tokens": 11,              "output_tokens": 0            }          ],          "input_tokens": 11,          "output_tokens": 0        },        "msg_035dea8bac625f7d016aa1b15156c887d1ad47e2f302ba5ca6": {          "cache_write_tokens": 0,          "cached_tokens": 0,          "content": [            {              "cache_write_tokens": 0,              "cached_tokens": 0,              "input_tokens": 2,              "output_tokens": 43            }          ],          "input_tokens": 2,          "output_tokens": 43        }      },      "request_fields": {        "instructions": {          "cache_write_tokens": 0,          "cached_tokens": 3968,          "input_tokens": 4114,          "output_tokens": 0        }      }    },    "input_tokens": 4127,    "input_tokens_details": {      "cache_write_tokens": 0,      "cached_tokens": 3968    },    "output_tokens": 43,    "output_tokens_details": {      "reasoning_tokens": 0    },    "total_tokens": 4170  },  "user": null,  "metadata": {}}

真实调用抓取并脱敏 · 2026-09-09

能力边界

  • Claude 与 Gemini 系没有这个端点。 原生入口分别是 Messages 和 Gemini 的 generateContent
  • 服务端存储类字段不保证可用conversationpromptbackground 依赖官方的 服务端状态,本网关不提供对应的管理接口。
  • 内置工具不保证可用,也不保证与官方一致。
  • reasoning_tokens 不可用于对账。 实测中这个字段多数情况下返回 0,即使 reasoning.effort 设为 high。它反映的是该字段是否被上报,不代表模型没有推理, 所以不要拿它核算推理成本。
  • 非流式不适合推理模型。

在线调试

填入你自己的 API Key 即可直接发起请求,参数表与响应结构由接口定义生成。

POST
/v1/responses

Authorization

BearerAuth

AuthorizationBearer <token>

使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx

In: header

Request Body

application/json

model*string
input?string|

输入内容,可以是字符串或消息数组

instructions?string
max_output_tokens?integer
temperature?number
top_p?number
stream?boolean
tools?
tool_choice?string|
reasoning?
previous_response_id?string
truncation?string
Value in"auto" | "disabled"

Response Body

application/json

curl -X POST "https://www.vibeapi.cn/v1/responses" \  -H "Content-Type: application/json" \  -d '{    "model": "string"  }'
{
  "id": "string",
  "object": "response",
  "created_at": 0,
  "status": "completed",
  "model": "string",
  "output": [
    {
      "type": "string",
      "id": "string",
      "status": "string",
      "role": "string",
      "content": [
        {
          "type": "string",
          "text": "string"
        }
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "text_tokens": 0,
      "audio_tokens": 0,
      "image_tokens": 0
    },
    "completion_tokens_details": {
      "text_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0
    }
  }
}

官方文档

本页只写与本网关有关的部分,参数语义的权威定义以官方为准: