Skip to main content
OpenAI兼容-Responses

获取输入项列表

获取生成指定 Response 时所使用的输入项列表。在多轮对话(使用 previous_response_id 串联)中,会一并返回历史轮次的用户输入和模型回复。仅当原创建请求中 store=true 时,返回的 Response ID 才支持查询。

调用时请将{WorkspaceId}替换为真实的业务空间ID
  • 华北2(北京)
SDK 调用配置的base_urlhttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1HTTP 请求地址:GET https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/responses/{response_id}/input_items

路径参数

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

查询参数

afterstring(可选)以指定的 item ID(格式为 msg_xxx)作为起点,返回排在该 ID 之后的数据,顺序由 order 决定。item ID 来源创建响应返回的 output[].id;或本接口返回的 data[].idfirst_idlast_id。常用于翻页:把上一次返回的 last_id 作为本次的 after 传入,即可继续获取后续数据。limitinteger(可选)返回的最大条数,取值范围 [1, 100],默认值为 20。orderstring(可选)排序方式,支持 asc(升序)和 desc(降序),默认值为 desc
  • 默认查询
  • 按条件查询
Python
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)

返回结果

data array输入项列表。每个元素是一个消息对象,包含 idrolecontenttypestatus 字段。role 取值为 userassistantcontent 中元素的 type 取值为 input_text(用户输入)或 output_text(模型回复)。多轮对话(使用 previous_response_id 串联)中,会按发生顺序包含历史用户消息与历史模型回复。first_id string列表中第一个元素的 ID。last_id string列表中最后一个元素的 ID。has_more boolean是否还有未返回的数据。当为 true 时,把本次返回的 last_id 作为下一次请求的 after 参数,可继续获取后续数据。id string对应的 Response ID。model string生成该 Response 时使用的模型名称。created_at integerResponse 创建时间的 Unix 时间戳(毫秒)。注意:与"创建响应/检索响应"接口返回的 created_at(秒)单位不同。previous_response_id string多轮对话(使用 previous_response_id 串联)时返回,值为上一轮的 Response ID。
{
    "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": "qwen3.8-max"
}

错误响应

当指定的 Response ID 不存在时,返回以下错误:
{
    "request_id": "339b771548c7fbb15717316b49627681",
    "code": "InvalidParameter",
    "message": "Response with id 'resp_xxx' not found."
}