根據 Response ID 擷取一個已完成的模型響應。
- 华北2(北京)
SDK 調用配置的
base_url:https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1HTTP 要求地址:GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/responses/{response_id}{WorkspaceId}替換為真實的業務空間ID。
路徑參數response_idstring(必選)要擷取的 Response ID,格式為 resp_xxx。可從建立響應介面的響應中擷取。僅當原建立請求中 store=true 時返回的 Response ID 可被檢索。 | Python |
返回結果返回與建立響應相同的 Response 對象。各欄位含義如下:idstring本次響應的唯一識別碼,格式為 resp_xxx。object string物件類型,固定為 response。status string響應狀態。枚舉值:completed(完成)、failed(失敗)、in_progress(產生中)、cancelled(已取消)、queued(排隊中)、incomplete(不完整)。created_at integer響應建立時的 Unix 時間戳記(秒)。completed_at integer響應產生完成時的 Unix 時間戳記(秒)。響應未完成時為 null。error object當模型產生響應失敗時返回的錯誤對象。成功時為 null。model string用於產生響應的模型 ID。output array模型產生的輸出項數組。數組中的元素類型和順序取決於模型的響應。
數組元素屬性 type string輸出項類型。枚舉值:
string輸出項的唯一識別碼。所有類型的輸出項都包含此欄位。role string訊息角色,固定為 assistant。僅當 type 為 message 時存在。status string輸出項狀態。可選值:completed(完成)、in_progress(產生中)。當 type 不為reasoning時存在。name string工具或函數名稱。當 type 為 function_call、web_search_image_call、image_search_call、mcp_call 時存在。對於 web_search_image_call 和 image_search_call,值分別固定為 "web_search_image" 和 "image_search"。對於 mcp_call,值為 MCP 服務中被調用的具體函數名(如 amap-maps-maps_geo)。arguments string工具調用的參數,JSON 字串格式。當 type 為 function_call、web_search_image_call、image_search_call、mcp_call 時存在。使用前需要通過 JSON.parse() 解析。不同工具類型的 arguments 內容:
string函數調用的唯一識別碼。僅當 type 為 function_call 時存在。在返回函數調用結果時,需要通過此 ID 關聯請求與響應。content array訊息內容數組。僅當 type 為 message 時存在。
數組元素屬性 type string內容類型,固定為 output_text。text string模型產生的常值內容。annotations array文本注釋數組。通常為空白數組。array推理摘要數組。僅當 type 為 reasoning 時存在。每個元素包含 type(值為 summary_text)和 text(摘要文本)欄位。action object搜尋動作資訊。僅當 type 為 web_search_call 時存在。
屬性 query string搜尋查詢關鍵詞。type string搜尋類型,固定為 search。sources array搜尋來源列表。每個元素包含 type和 url欄位。string模型產生並執行的代碼。僅當 type 為 code_interpreter_call 時存在。outputs array代碼執行輸出數組。僅當 type 為 code_interpreter_call 時存在。每個元素包含 type(值為 logs)和 logs(代碼執行日誌)欄位。container_id string代碼解譯器容器標識符。僅當 type 為 code_interpreter_call 時存在。用於關聯同一會話中的多次代碼執行。goal string抽取目標描述,說明需要從網頁中提取哪些資訊。僅當 type 為 web_extractor_call 時存在。output string工具調用的輸出結果,字串格式。
array被抽取的網頁 URL 列表。僅當 type 為 web_extractor_call 時存在。server_label stringMCP 服務標籤。僅當 type 為 mcp_call 時存在。標識本次調用所使用的 MCP 服務。queries array知識庫檢索使用的查詢列表。僅當 type 為 file_search_call 時存在。數組元素為字串,表示模型產生的搜尋查詢詞。results array知識庫檢索結果數組。僅當 type 為 file_search_call 時存在。
數組元素屬性 file_id string匹配文檔的檔案 ID。filename string匹配文檔的檔案名稱。score float匹配相關度評分,取值範圍 0-1,值越大表示相關度越高。text string匹配到的文檔內容片段。object本次請求的 Token 消耗資訊。
屬性 input_tokens integer輸入的 Token 數。output_tokens integer模型輸出的 Token 數。total_tokens integer消耗的總 Token 數,為 input_tokens 與 output_tokens 的總和。input_tokens_details object輸入 Token 的細粒度分類。
屬性 cached_tokens integer命中緩衝的 Token 數。object輸出 Token 的細粒度分類。
屬性 reasoning_tokens integer思考過程 Token 數。array計費明細數組。
屬性 input_tokens integer本計費類型的輸入 Token 數。output_tokens integer本計費類型的輸出 Token 數。total_tokens integer本計費類型的總 Token 數。x_billing_type string固定為response_api。prompt_tokens_details object啟用 Session 緩衝後返回。包含 cached_tokens(命中緩衝的 Token 數)欄位。object工具使用統計資訊。當使用內建工具時,包含各工具的調用次數。樣本:{"web_search": {"count": 1}}array回顯原建立響應請求中 tools 參數的完整內容。結構與請求體中的 tools 參數相同。無工具時為空白數組 []。tool_choice string回顯原建立響應請求中 tool_choice 參數的值。枚舉值:auto、none、required。parallel_tool_calls boolean回顯原建立響應請求中 parallel_tool_calls 參數的值,表示是否允許模型並行調用多個工具。temperature float回顯原建立響應請求中 temperature 參數的值。採樣溫度,控制模型產生文本的多樣性,取值範圍 [0, 2)。未設定時返回模型預設值。top_p float回顯原建立響應請求中 top_p 參數的值。核採樣的機率閾值,取值範圍 (0, 1.0]。未設定時返回模型預設值。frequency_penalty float回顯原建立響應請求中 frequency_penalty 參數的值。頻率懲罰係數,正值降低重複用詞的機率。presence_penalty float回顯原建立響應請求中 presence_penalty 參數的值。存在懲罰係數,正值增加產生新主題的機率。top_logprobs integer回顯原建立響應請求中 top_logprobs 參數的值。每個位置返回的最可能 Token 數量。未啟用時為 0。store boolean回顯原建立響應請求中 store 參數的值。true 表示該響應已儲存,可被 previous_response_id 引用;false 表示未儲存。service_tier string服務等級,固定為 default。background boolean是否為後台非同步執行的響應。當前百鍊僅支援同步調用,固定為 false。metadata object回顯原建立響應請求中 metadata 參數的內容。可用於附加自訂索引值對的對象,無設定時為空白對象 {}。 |