Responses API

POST https://llmoxy.com/v1/responses 接收 JSON 请求。请求头:

Authorization: Bearer <LLMOXY_API_KEY>
Content-Type: application/json

网关把正文解析成固定结构。model 为空,或正文里没有 input,请求会被拒绝。max_output_tokens 大于 1,073,741,823 时也会被拒绝。background 不在这个结构里。

没有打开请求体透传时,只保留下表字段,并默认去掉 service_tier、safety_identifier 和 stream_options.include_obfuscation。store 默认保留。可空数字写成 0、stream 写成 false 时仍会发出。stream_options 里的布尔值在重新组包时,false 会被省略。表以外的字段不会发出。

请求字段

字段类型必填网关行为
modelstring是非空模型 ID。
inputstring 或 array是必须出现。字符串按一段输入文本计。数组元素可带 role。content 为字符串时按输入文本计;为数组时识别 input_text、input_image、input_file。image_url 和 file_url 可以是字符串,或带 url 的对象。
includeJSON否原样保留。
conversationJSON否原样保留。
context_managementJSON否原样保留。
instructionsJSON否原样保留。常见写法是字符串。
max_output_tokensnumber否可空。显式 0 会保留。
top_logprobsnumber否可空。显式 0 会保留。
metadataJSON否原样保留。
parallel_tool_callsJSON否原样保留。显式 false 会保留。
previous_response_idstring否空字符串省略。
reasoning.effortstring否空字符串省略。网关不校验取值。
reasoning.summarystring否空字符串省略。网关不校验取值。
service_tierstring否默认去掉。
storeJSON否默认保留。显式 false 会保留。
prompt_cache_keyJSON否原样保留。
prompt_cache_retentionJSON否原样保留。
safety_identifierJSON否默认去掉。
streamboolean否缺省按非流式处理。显式 false 会保留。
stream_options.include_usageboolean否重新组包时 false 省略。
stream_options.include_obfuscationboolean否默认去掉。重新组包时 false 省略。
temperaturenumber否可空。显式 0 会保留。
textJSON否原样保留。
tool_choiceJSON否原样保留。
toolsJSON否原样保留。
top_pnumber否可空。显式 0 会保留。
truncationJSON否原样保留。
userJSON否原样保留。
max_tool_callsnumber否可空。显式 0 会保留。
promptJSON否原样保留。
enable_thinkingJSON否原样保留。
presetJSON否原样保留。

grok-4.6 与 grok-4.7

2026-10-03 对 https://llmoxy.com/v1/responses 的流式调用里,grok-4.6 和 grok-4.7 都返回 HTTP 200,并完成同一组事件。

模型HTTP响应里的 modelstatus正文input / output / total
grok-4.6200grok-4.6completedpong212 / 98 / 310
grok-4.7200grok-4.7completedpong1248 / 55 / 1303

grok-4.6 的 input_tokens_details.cached_tokens 为 128,output_tokens_details.reasoning_tokens 为 97。grok-4.7 分别为 1152 和 54。

正文位于 output 中 type 为 message 的项,content 里 type 为 output_text 的 text。两个模型都会先输出 type 为 reasoning 的项。response.completed 里该 reasoning 项的 status 仍是 in_progress。

当前这两个模型的请求打开了请求体透传,所以下一节的最小 JSON 按客户端原文发出。

最小成功请求

grok-4.6 使用同一正文,只把 model 换成 grok-4.6。

curl https://llmoxy.com/v1/responses \
  -H "Authorization: Bearer <LLMOXY_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.7",
    "input": "Reply with exactly: pong",
    "max_output_tokens": 64,
    "stream": true
  }'
BASH

响应的 Content-Type 为 text/event-stream。每条事件是一行 event: 和一行 data:。网关转发已解析事件的原始 JSON,事件名取自 JSON 里的 type。结束标记是最后一条 response.completed。

两个模型的事件名顺序相同:

response.created,response.in_progress,response.output_item.added,response.reasoning_summary_part.added,response.reasoning_summary_text.delta,response.reasoning_summary_text.delta,response.reasoning_summary_text.done,response.reasoning_summary_part.done,response.output_item.done,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。

下面是 grok-4.7 的实测事件。响应 ID 和输出项 ID 已换成占位符,其余字段与当次响应一致。

event: response.created
data: {"type":"response.created","sequence_number":0,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[],"status":"in_progress"},"output_index":0}

event: response.in_progress
data: {"type":"response.in_progress","sequence_number":1,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[],"status":"in_progress"},"output_index":0}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":2,"output_index":0,"item":{"id":"item_reasoning","type":"reasoning","status":"in_progress","summary":[]}}

event: response.reasoning_summary_part.added
data: {"type":"response.reasoning_summary_part.added","sequence_number":3,"output_index":0,"item_id":"item_reasoning","part":{"type":"summary_text","text":""},"summary_index":0}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","sequence_number":4,"output_index":0,"item_id":"item_reasoning","delta":"The user wants a reply","summary_index":0}

event: response.reasoning_summary_text.delta
data: {"type":"response.reasoning_summary_text.delta","sequence_number":5,"output_index":0,"item_id":"item_reasoning","delta":" of exactly \"pong\".","summary_index":0}

event: response.reasoning_summary_text.done
data: {"type":"response.reasoning_summary_text.done","sequence_number":6,"output_index":0,"item_id":"item_reasoning","text":"The user wants a reply of exactly \"pong\".","summary_index":0}

event: response.reasoning_summary_part.done
data: {"type":"response.reasoning_summary_part.done","sequence_number":7,"output_index":0,"item_id":"item_reasoning","part":{"type":"summary_text","text":"The user wants a reply of exactly \"pong\"."},"summary_index":0}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":8,"output_index":0,"item":{"id":"item_reasoning","type":"reasoning","summary":[{"text":"The user wants a reply of exactly \"pong\".","type":"summary_text"}]}}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":9,"output_index":1,"item":{"id":"item_message","type":"message","role":"assistant","content":[],"status":"in_progress"}}

event: response.content_part.added
data: {"type":"response.content_part.added","sequence_number":10,"output_index":1,"item_id":"item_message","content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","sequence_number":11,"output_index":1,"item_id":"item_message","content_index":0,"delta":"pong"}

event: response.output_text.done
data: {"type":"response.output_text.done","sequence_number":12,"output_index":1,"item_id":"item_message","content_index":0,"text":"pong"}

event: response.content_part.done
data: {"type":"response.content_part.done","sequence_number":13,"output_index":1,"item_id":"item_message","content_index":0,"part":{"type":"output_text","text":"pong","annotations":[]}}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":14,"output_index":1,"item":{"id":"item_message","type":"message","role":"assistant","content":[{"type":"output_text","annotations":[],"text":"pong"}],"status":"completed"}}

event: response.completed
data: {"type":"response.completed","sequence_number":15,"response":{"object":"response","id":"resp_example","created_at":1791015238,"model":"grok-4.7","output":[{"id":"item_reasoning","type":"reasoning","status":"in_progress","summary":[{"text":"The user wants a reply of exactly \"pong\".","type":"summary_text"}]},{"id":"item_message","type":"message","role":"assistant","content":[{"type":"output_text","text":"pong"}],"status":"completed"}],"status":"completed","usage":{"input_tokens":1248,"input_tokens_details":{"cached_tokens":1152},"output_tokens":55,"output_tokens_details":{"reasoning_tokens":54},"total_tokens":1303}},"output_index":0}

对话压缩

POST https://llmoxy.com/v1/responses/compact

请求字段是 model(必填)、input、instructions、previous_response_id。上面的 grok 实测没有调用这个路由。