Search + K

Command Palette

Search for a command to run...

Sign In

Returns a list of messages for a given thread.

GET /threads/{thread_id}/messages
Copy endpoint
https://api.openai.com/v1

Parameters

path Path Parameters

Name Type
thread_id required

The ID of the thread the messages belong to.

string

query Query Parameters

Name Type
limit

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

number
order

Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

"asc" | "desc"
after

A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

string
before

A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

string
run_id

Filter messages by the run ID that generated them.

string

Responses

200 application/json

OK

interface ListMessagesResponse {
object: string;
data: MessageObject

Represents a message within a thread.

interface MessageObject {
id: string;
object: "thread.message";
created_at: number;
thread_id: string;
status: "in_progress" | "incomplete" | "completed";
incomplete_details: { reason: "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed"; } | null;
completed_at: number | null;
incomplete_at: number | null;
role: "user" | "assistant";
content: (MessageContentImageFileObject | MessageContentImageUrlObject | MessageContentTextObject | MessageContentRefusalObject)[];
assistant_id: string | null;
run_id: string | null;
attachments: { file_id?: string;tools?: (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; }[] | null;
metadata: Metadata;
}
[]
;
first_id: string;
last_id: string;
has_more: boolean;
}