要查詢輸入項的 Response ID,格式為 resp_xxx。僅當原建立請求中 store=true 時,返回的 Response ID 才支援查詢。
查詢參數
afterstring(可選)
以指定的 item ID(格式為 msg_xxx)作為起點,返回排在該 ID 之後的資料,順序由 order 決定。item ID 來源:建立響應返回的 output[].id;或本介面返回的 data[].id、first_id、last_id。常用於翻頁:把上一次返回的 last_id 作為本次的 after 傳入,即可繼續擷取後續資料。
limitinteger(可選)
返回的最大條數,取值範圍 [1, 100],預設值為 20。
orderstring(可選)
排序方式,支援 asc(升序)和 desc(降序),預設值為 desc。
預設查詢
import os
from openai import OpenAI
client = OpenAI(
# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
response = client.responses.input_items.list("resp_xxx")
print(response.data)
import OpenAI from "openai";
const openai = new OpenAI({
// 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey: "sk-xxx"
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});
async function main() {
const response = await openai.responses.inputItems.list("resp_xxx");
console.log(response.data);
}
main();