Skip to main content
POST
The Assistants API is deprecated in favor of the Responses API.
Create a message in a thread.

Path Parameters

string
required
The ID of the thread to create a message for.

Request Body

string
required
The role of the entity that is creating the message. Allowed values:
  • user: Indicates the message is sent by an actual user
  • assistant: Indicates the message is generated by the assistant
string
required
The text contents of the message.
array
A list of files attached to the message, and the tools they should be added to.
object
Set of 16 key-value pairs that can be attached to an object.Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

Response

Returns a Message object.
string
The message identifier.
string
The object type, always thread.message.
integer
The Unix timestamp (in seconds) for when the message was created.
string
The thread ID that this message belongs to.
string
The entity that produced the message. One of user or assistant.
array
The content of the message in array of text and/or images.

List Messages

GET https://api.openai.com/v1/threads/{thread_id}/messages Returns a list of messages for a given thread.

Query Parameters

integer
default:"20"
A limit on the number of objects to be returned. Limit can range between 1 and 100.
string
default:"desc"
Sort order by the created_at timestamp. asc for ascending order and desc for descending order.
string
A cursor for use in pagination.
string
A cursor for use in pagination.
string
Filter messages by the run ID that generated them.