Skip to main content

Create Message

Create a message in a thread.

Path Parameters
thread_id Thread Id REQUIRED
Request Body REQUIRED
role Role8 REQUIRED

Possible values: [user]

The role of the entity that is creating the message. Currently only user is supported.

content Content REQUIRED

Possible values: 1 ≤ length ≤ 32768

The content of the message.

file_ids string[]

A list of File IDs that the message should use. There can be a maximum of 10 files attached to a message. Useful for tools like retrieval and code_interpreter that can access and use files.

metadata object

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 maxium of 512 characters long.

Responses
200

Successful Response

Schema OPTIONAL
_id Id OPTIONAL

MongoDB document ObjectID

id Id

The identifier, which can be referenced in API endpoints.

object Object25

Possible values: [thread.message]

The object type, which is always thread.message.

created_at Created At

The Unix timestamp (in seconds) for when the message was created.

thread_id Thread Id

The thread ID that this message belongs to.

role Role7

Possible values: [user, assistant, tool_call, tool_output]

The entity that produced the message. One of user or assistant.

content undefined[]

The content of the message in array of text and/or images.

assistant_id Assistant Id

If applicable, the ID of the assistant that authored this message.

run_id Run Id

If applicable, the ID of the run associated with the authoring of this message.

file_ids string[]

A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files. A maximum of 10 files can be attached to a message.

metadata object

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 maxium of 512 characters long.

422

Validation Error

Schema OPTIONAL
detail object[] OPTIONAL
loc undefined[]
msg Message
type Error Type