API 參考
建立響應 (OpenAI Responses API)
/v1/responsesResponses 文字與工具呼叫介面;可選欄位和工具型別取決於模型支援。stream=true 返回帶 type 的 SSE 事件;previous_response_id 不保證持久儲存或可恢復。
鑑權與許可權
使用當前 GloopAPI Key。模型、功能與許可權以當前 Key 的目錄及介面說明為準。
Authorization: Bearer $GLOOP_API_KEY鑑權方案: BearerAuth
請求
請求體 · application/json
- 型別
- object
- 必填欄位
modelinput
請求體必填
modelstring必填inputunion必填輸入內容,可以是字串或訊息陣列
oneOf 分支 1
型別: string
instructionsstring選填max_output_tokensinteger選填temperaturenumber選填取樣溫度 具體支援與限制取所選模型,不保證統一預設值。
top_pnumber選填核取樣引數 具體支援與限制取所選模型,不保證統一預設值。
streamboolean選填toolsarray選填tools 子欄位(1)
[]object選填
tool_choiceunion選填oneOf 分支 1
型別: string
oneOf 分支 2
型別: object
reasoningobject選填previous_response_idstring選填truncationstring選填- 列舉
["auto","disabled"]
parallel_tool_callsboolean選填是否允許並行工具呼叫,取決於所選模型。Chat 接受布林值,Responses 接受相容協議的 JSON 值。
storeboolean選填是否允許儲存請求與響應,取決於所選模型和服務支援範圍;不代表提供通用對話儲存介面。
prompt_cache_keystring選填提示快取關聯標識;模型相關,不保證命中或支援。Chat 接受字串,Responses 接受相容協議 JSON 值。
prompt_cache_retentionunknown選填提示快取保留控制 JSON 值;模型相關,平臺不賦予統一列舉、預設值或快取保留保證。
service_tierstring選填請求服務層級,可能影響費用;預設忽略,僅在支援此引數時生效。支援值取決於所選模型。
textobject選填文字輸出配置,例如 format 指定結構化輸出;具體支援與限制取決於所選模型。
context_managementunknown選填上下文管理配置;取決於所選模型,不代表自動摘要或持久記憶。
stream_optionsobject選填Responses 流引數;與 stream=true 配合,僅支援的欄位生效。
stream_options 子欄位(2)
include_usageboolean選填請求流式用量,是否返回取決於所選模型。
include_obfuscationboolean選填Responses 流混淆控制;預設忽略,僅在支援此引數時生效。
響應與錯誤
HTTP 200
成功建立響應
application/json
- 型別
- object
- 額外屬性
- false
idstring選填objectstring選填created_atinteger選填statusstring選填- 列舉
["completed","failed","in_progress","incomplete"]
modelstring選填outputarray選填usageobject選填usage 子欄位(5)
prompt_tokensinteger選填提示詞 Token 數
completion_tokensinteger選填補全 Token 數
total_tokensinteger選填總 Token 數
prompt_tokens_detailsobject選填prompt_tokens_details 子欄位(4)
cached_tokensinteger選填text_tokensinteger選填audio_tokensinteger選填image_tokensinteger選填
completion_tokens_detailsobject選填completion_tokens_details 子欄位(3)
text_tokensinteger選填audio_tokensinteger選填reasoning_tokensinteger選填
text/event-stream
- 型別
- string
- 說明
- SSE 事件流,協議事件/用量/結束符取當前介面,錯誤可能在流內。
{
"type": "string",
"description": "SSE 事件流,协议事件/用量/结束符取当前接口,错误可能在流内。"
}HTTP 401
Key 缺失、無效、過期或已撤銷。
application/json
- 型別
- object
- 必填欄位
error
errorobject必填error 子欄位(4)
codestring選填messagestring選填typestring選填request_idstring選填
HTTP 403
IP、賬戶、模型或工具許可權不足。
application/json
- 型別
- object
- 必填欄位
error
errorobject必填error 子欄位(4)
codestring選填messagestring選填typestring選填request_idstring選填
HTTP 429
請求/佇列限流。
application/json
- 型別
- object
- 必填欄位
error
errorobject必填error 子欄位(4)
codestring選填messagestring選填typestring選填request_idstring選填
HTTP 500
鑑權或資料儲存內部失敗。
application/json
- 型別
- object
- 必填欄位
error
errorobject必填error 子欄位(4)
codestring選填messagestring選填typestring選填request_idstring選填