Skip to content

compatible Responses-List input items

Returns the input items used to generate the specified Response. For multi-turn conversations chained by previous_response_id, the returned list also includes user inputs and assistant replies from earlier turns. A Response ID can be queried only when the create request was sent with store=true.

China (Beijing)

SDK base_url: https://dashscope.aliyuncs.com/compatible-mode/v1

HTTP request URL: GET https://dashscope.aliyuncs.com/compatible-mode/v1/responses/{response_id}/input_items

## Path parameters

response_id *string* (Required) The Response ID to query input items for, in the format resp_xxx. A Response ID can be queried only when the create request was sent with store=true.

## Default request

## Python

python
import os
from openai import OpenAI

client = OpenAI(
 # If you have not configured the environment variable, replace the line below with your Model Studio API key: api_key="sk-xxx"
 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)

## Node.js

nodejs
import OpenAI from "openai";

const openai = new OpenAI({
 // If you have not configured the environment variable, replace the line below with your Model Studio API key: apiKey: "sk-xxx"
 apiKey: process.env.DASHSCOPE_API_KEY,
 baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});

async function main() {
 const response = await openai.responses.inputItems.list("resp_xxx");
 console.log(response.data);
}

main();

## curl

curl
curl https://dashscope.aliyuncs.com/compatible-mode/v1/responses/resp_xxx/input_items \\
 -H "Authorization: Bearer $DASHSCOPE_API_KEY"

## Filtered request

## Python

python
import os
from openai import OpenAI

client = OpenAI(
 # If you have not configured the environment variable, replace the line below with your Model Studio API key: api_key="sk-xxx"
 api_key=os.getenv("DASHSCOPE_API_KEY"),
 base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

response = client.responses.input_items.list(
 "resp_xxx",
 # after takes an item ID (msg_xxx): from output\[\].id of Create a response, or data\[\].id / first_id / last_id of this API.
 after="msg_xxx",
 limit=10,
 order="asc",
)
print(response.data)

## Node.js

nodejs
import OpenAI from "openai";

const openai = new OpenAI({
 // If you have not configured the environment variable, replace the line below with your Model Studio API key: apiKey: "sk-xxx"
 apiKey: process.env.DASHSCOPE_API_KEY,
 baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
});

async function main() {
 const response = await openai.responses.inputItems.list("resp_xxx", {
 // after takes an item ID (msg_xxx): from output\[\].id of Create a response, or data\[\].id / first_id / last_id of this API.
 after: "msg_xxx",
 limit: 10,
 order: "asc",
 });
 console.log(response.data);
}

main();

## curl

curl
curl "https://dashscope.aliyuncs.com/compatible-mode/v1/responses/resp_xxx/input_items?after=msg_xxx\&limit=10\&order=asc" \\
 -H "Authorization: Bearer $DASHSCOPE_API_KEY"

## Query parameters

after *string* (Optional) A cursor for pagination. Returns items that come after the specified item ID (in the format msg_xxx); the direction follows order. Sources of the item ID: output\[\].id from the Create a response API, or data\[\].id, first_id, or last_id from this API. To paginate, pass the last_id from the previous response as after in the next request.

limit *integer* (Optional) The maximum number of items to return. Value range: [1, 100]. Default: 20.

order *string* (Optional) Sort order. Supported values: asc (ascending) and desc (descending). Default: desc.

## Returns

json
{
 "created_at": 1778674066000,
 "data": \[
 {
 "content": \[
 {
 "text": "Hello",
 "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"
}

data *array* The list of input items. Each element is a message object with the fields id, role, content, type, and status. role is either user or assistant. The type of each element in content is either input_text (user input) or output_text (assistant reply). For multi-turn conversations chained by previous_response_id, the list contains user messages and assistant replies from previous turns in chronological order.

first_id *string* The ID of the first item in the list.

last_id *string* The ID of the last item in the list.

has_more *boolean* Whether more items are available. When true, pass the returned last_id as the after parameter in the next request to fetch more items.

id *string* The Response ID that these input items belong to.

model *string* The name of the model used to generate this Response.

created_at *integer* The Unix timestamp when the Response was created, in milliseconds. Note: this differs from the created_at field returned by the Create a response and Retrieve a response APIs, which is in seconds.

previous_response_id *string* Returned only for multi-turn conversations chained by previous_response_id. The value is the Response ID of the previous turn.

Error response

If the specified Response ID does not exist, the API returns the following error:

HELPCODEESCAPE-json
{
    "error": {
        "message": "Response with id 'resp_xxx' not found.",
        "type": "InvalidParameter"
    }
}

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.