Implementation:Openai Openai node Responses InputItems
| Knowledge Sources | |
|---|---|
| Domains | SDK, Responses |
| Last Updated | 2026-02-15 12:00 GMT |
Overview
The InputItems class provides a paginated listing endpoint that returns the input items used to generate a specific response.
Description
The InputItems class extends APIResource and exposes a single list method that retrieves all input items associated with a given response ID. Input items represent the messages, files, images, or other content that was provided as input when the response was created. This is useful for auditing, debugging, or replaying the inputs that produced a particular response.
The method returns a PagePromise wrapping a CursorPage of ResponseItem objects (imported from the parent responses module), enabling automatic cursor-based pagination. The query parameters support include for requesting additional fields in the response, order for sorting direction ('asc' or 'desc', defaulting to 'desc'), and standard cursor pagination fields (after, limit).
The module also exports a ResponseItemList interface that describes the raw list envelope with data, first_id, last_id, has_more, and object fields, though the SDK typically handles this structure internally through its pagination layer.
Usage
Use this resource when you need to inspect which input items were used to generate a particular response, such as for debugging response behavior, building conversation replay UIs, or auditing model inputs.
Code Reference
Source Location
- Repository: openai-node
- File: src/resources/responses/input-items.ts
Signature
export class InputItems extends APIResource {
list(
responseID: string,
query?: InputItemListParams | null | undefined,
options?: RequestOptions,
): PagePromise<ResponseItemsPage, ResponseItem>;
}
export interface ResponseItemList {
data: Array<ResponseItem>;
first_id: string;
has_more: boolean;
last_id: string;
object: 'list';
}
export interface InputItemListParams extends CursorPageParams {
include?: Array<ResponseIncludable>;
order?: 'asc' | 'desc';
}
Import
import OpenAI from 'openai';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| responseID | string |
Yes | The identifier of the response whose input items to list. |
| query.after | string |
No | Cursor for pagination; return results after this item ID. |
| query.limit | number |
No | Maximum number of items to return per page. |
| query.include | Array<ResponseIncludable> |
No | Additional fields to include in each response item. |
| query.order | 'desc' | No | Sort order; defaults to 'desc'.
|
| options | RequestOptions |
No | Additional request configuration. |
Outputs
| Name | Type | Description |
|---|---|---|
| data | Array<ResponseItem> |
The list of input items used to generate the response. |
| first_id | string |
ID of the first item in the current page. |
| last_id | string |
ID of the last item in the current page. |
| has_more | boolean |
Whether additional pages are available. |
| object | 'list' |
Object type discriminator. |
Usage Examples
import OpenAI from 'openai';
const client = new OpenAI();
// Automatically fetches more pages as needed.
for await (const item of client.responses.inputItems.list('response_abc123')) {
console.log(item.type, item.id);
}
// List with ordering and pagination limit
for await (const item of client.responses.inputItems.list('response_abc123', {
order: 'asc',
limit: 10,
})) {
console.log(item);
}