Returns a list of messages for a given thread.
GET /threads/{thread_id}/messages
Authorizations
Parameters
Path Parameters
The ID of the thread the messages belong to.
Query Parameters
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
Sort order by the created_at
timestamp of the objects. asc
for ascending order and desc
for descending order.
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.
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, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
Filter messages by the run ID that generated them.
Responses
200
OK
object
Represents a message within a thread.
object
The identifier, which can be referenced in API endpoints.
The object type, which is always thread.message
.
The Unix timestamp (in seconds) for when the message was created.
The thread ID that this message belongs to.
The status of the message, which can be either in_progress
, incomplete
, or completed
.
On an incomplete message, details about why the message is incomplete.
object
The reason the message is incomplete.
The Unix timestamp (in seconds) for when the message was completed.
The Unix timestamp (in seconds) for when the message was marked as incomplete.
The entity that produced the message. One of user
or assistant
.
The content of the message in array of text and/or images.
References an image File in the content of a message.
object
Always image_file
.
object
The File ID of the image in the message content. Set purpose="vision"
when uploading the File if you need to later display the file content.
Specifies the detail level of the image if specified by the user. low
uses fewer tokens, you can opt in to high resolution using high
.
References an image URL in the content of a message.
object
The type of the content part.
object
The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.
Specifies the detail level of the image. low
uses fewer tokens, you can opt in to high resolution using high
. Default value is auto
The text content that is part of a message.
object
Always text
.
object
The data that makes up the text.
A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the “file_search” tool to search files.
object
Always file_citation
.
The text in the message content that needs to be replaced.
object
The ID of the specific File the citation is from.
A URL for the file that’s generated when the assistant used the code_interpreter
tool to generate a file.
object
Always file_path
.
The text in the message content that needs to be replaced.
object
The ID of the file that was generated.
The refusal content generated by the assistant.
object
Always refusal
.
If applicable, the ID of the assistant that authored this message.
The ID of the run associated with the creation of this message. Value is null
when messages are created manually using the create message or create thread endpoints.
A list of files attached to the message, and the tools they were added to.
object
The ID of the file to attach to the message.
The tools to add this file to.
object
The type of tool being defined: code_interpreter
object
The type of tool being defined: file_search
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long.