跳转到主要内容
OpenAI Responses

获取输入项列表

获取生成指定 Response 时所使用的输入项列表

GET
/api/v2/apps/protocols/compatible-mode/v1/responses/{response_id}/input_items
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

response = client.responses.input_items.list("resp_xxx")
print(response.data)
{
  "created_at": 1778674066000,
  "data": [
    {
      "content": [
        {
          "text": "你好",
          "type": "input_text"
        }
      ],
      "id": "msg_8dac4972-fdba-42b5-bed9-280441ced8ea",
      "role": "user",
      "status": "completed",
      "type": "message"
    }
  ],
  "first_id": "msg_8dac4972-fdba-42b5-bed9-280441ced8ea",
  "has_more": false,
  "id": "resp_4ca7fa5e-6ff5-9787-bc18-af6ca5eff36c",
  "last_id": "msg_8dac4972-fdba-42b5-bed9-280441ced8ea",
  "model": "qwen-plus"
}

鉴权

string
header
必填

千问云 API Key。详见获取 API Key

路径参数

string
必填

要查询输入项的 Response ID,格式为 resp_xxx。仅当原创建请求中 store=true 时,返回的 Response ID 才支持查询。

查询参数

string

以指定的 item ID(格式为 msg_xxx)作为起点,返回排在该 ID 之后的数据,顺序由 order 决定。item ID 来源:创建响应返回的 output[].id;或本接口返回的 data[].idfirst_idlast_id。常用于翻页:把上一次返回的 last_id 作为本次的 after 传入,即可继续获取后续数据。

integer
默认值20

返回的最大条数,取值范围 [1, 100],默认值为 20。

1 <= x <= 100
enum<string>
默认值"desc"

排序方式,支持 asc(升序)和 desc(降序),默认值为 desc

asc,desc

响应

200-application/json
object[]

输入项列表。每个元素是一个消息对象。多轮对话(使用 previous_response_id 串联)中,会按发生顺序包含历史用户消息与历史模型回复。

string

列表中第一个元素的 ID。

string

列表中最后一个元素的 ID。

boolean

是否还有未返回的数据。当为 true 时,把本次返回的 last_id 作为下一次请求的 after 参数,可继续获取后续数据。

string

对应的 Response ID。

string

生成该 Response 时使用的模型名称。

integer

Response 创建时间的 Unix 时间戳(毫秒)。注意:与创建响应/获取响应接口返回的 created_at(秒)单位不同。

string | null

多轮对话时返回,值为上一轮的 Response ID。