Skip to content
Primary navigation

Messages

List messages
Deprecated
MessageListPage beta().threads().messages().list(MessageListParamsparams = MessageListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())
GET/threads/{thread_id}/messages
Create message
Deprecated
Message beta().threads().messages().create(MessageCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/threads/{thread_id}/messages
Modify message
Deprecated
Message beta().threads().messages().update(MessageUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/threads/{thread_id}/messages/{message_id}
Retrieve message
Deprecated
Message beta().threads().messages().retrieve(MessageRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
GET/threads/{thread_id}/messages/{message_id}
Delete message
Deprecated
MessageDeleted beta().threads().messages().delete(MessageDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
DELETE/threads/{thread_id}/messages/{message_id}
ModelsExpand Collapse
class Annotation: A class that can be one of several variants.union

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.

class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

class AnnotationDelta: A class that can be one of several variants.union

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.

class FileCitationDeltaAnnotation:

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.

long index

The index of the annotation in the text content part.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

Optional<Long> endIndex
minimum0
Optional<FileCitation> fileCitation
Optional<String> fileId

The ID of the specific File the citation is from.

Optional<String> quote

The specific quote in the file.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class FilePathDeltaAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long index

The index of the annotation in the text content part.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

Optional<Long> endIndex
minimum0
Optional<FilePath> filePath
Optional<String> fileId

The ID of the file that was generated.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FileCitationDeltaAnnotation:

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.

long index

The index of the annotation in the text content part.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

Optional<Long> endIndex
minimum0
Optional<FileCitation> fileCitation
Optional<String> fileId

The ID of the specific File the citation is from.

Optional<String> quote

The specific quote in the file.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class FilePathAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

class FilePathDeltaAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long index

The index of the annotation in the text content part.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

Optional<Long> endIndex
minimum0
Optional<FilePath> filePath
Optional<String> fileId

The ID of the file that was generated.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class ImageFile:
String fileId

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.

Optional<Detail> detail

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.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageFileDelta:
Optional<Detail> detail

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.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
Optional<String> fileId

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.

class ImageFileDeltaBlock:

References an image File in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_file"constant"image_file"constant

Always image_file.

Optional<ImageFileDelta> imageFile
class ImageUrl:
String url

The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

formaturi
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high. Default value is auto

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class ImageUrlDelta:
Optional<Detail> detail

Specifies the detail level of the image. low uses fewer tokens, you can opt in to high resolution using high.

Accepts one of the following:
AUTO("auto")
LOW("low")
HIGH("high")
Optional<String> url

The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

class ImageUrlDeltaBlock:

References an image URL in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_url"constant"image_url"constant

Always image_url.

Optional<ImageUrlDelta> imageUrl
class Message:

Represents a message within a thread.

String id

The identifier, which can be referenced in API endpoints.

Optional<String> assistantId

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

Optional<List<Attachment>> attachments

A list of files attached to the message, and the tools they were added to.

Optional<String> fileId

The ID of the file to attach to the message.

Optional<List<Tool>> tools

The tools to add this file to.

Accepts one of the following:
class CodeInterpreterTool:
JsonValue; type "code_interpreter"constant"code_interpreter"constant

The type of tool being defined: code_interpreter

JsonValue;
JsonValue; type "file_search"constant"file_search"constant

The type of tool being defined: file_search

Optional<Long> completedAt

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

List<MessageContent> content

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

Accepts one of the following:
class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

long createdAt

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

Optional<Long> incompleteAt

The Unix timestamp (in seconds) for when the message was marked as incomplete.

Optional<IncompleteDetails> incompleteDetails

On an incomplete message, details about why the message is incomplete.

Reason reason

The reason the message is incomplete.

Accepts one of the following:
CONTENT_FILTER("content_filter")
MAX_TOKENS("max_tokens")
RUN_CANCELLED("run_cancelled")
RUN_EXPIRED("run_expired")
RUN_FAILED("run_failed")
Optional<Metadata> metadata

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, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

JsonValue; object_ "thread.message"constant"thread.message"constant

The object type, which is always thread.message.

Role role

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

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
Optional<String> runId

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.

Status status

The status of the message, which can be either in_progress, incomplete, or completed.

Accepts one of the following:
IN_PROGRESS("in_progress")
INCOMPLETE("incomplete")
COMPLETED("completed")
String threadId

The thread ID that this message belongs to.

class MessageContent: A class that can be one of several variants.union

References an image File in the content of a message.

class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlock:

The text content that is part of a message.

Text text
JsonValue; type "text"constant"text"constant

Always text.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

class MessageContentDelta: A class that can be one of several variants.union

References an image File in the content of a message.

class ImageFileDeltaBlock:

References an image File in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_file"constant"image_file"constant

Always image_file.

Optional<ImageFileDelta> imageFile
class TextDeltaBlock:

The text content that is part of a message.

long index

The index of the content part in the message.

JsonValue; type "text"constant"text"constant

Always text.

Optional<TextDelta> text
class RefusalDeltaBlock:

The refusal content that is part of a message.

long index

The index of the refusal part in the message.

JsonValue; type "refusal"constant"refusal"constant

Always refusal.

Optional<String> refusal
class ImageUrlDeltaBlock:

References an image URL in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_url"constant"image_url"constant

Always image_url.

Optional<ImageUrlDelta> imageUrl
class MessageContentPartParam: A class that can be one of several variants.union

References an image File in the content of a message.

class ImageFileContentBlock:

References an image File in the content of a message.

ImageFile imageFile
JsonValue; type "image_file"constant"image_file"constant

Always image_file.

class ImageUrlContentBlock:

References an image URL in the content of a message.

ImageUrl imageUrl
JsonValue; type "image_url"constant"image_url"constant

The type of the content part.

class TextContentBlockParam:

The text content that is part of a message.

String text

Text content to be sent to the model

JsonValue; type "text"constant"text"constant

Always text.

class MessageDeleted:
String id
boolean deleted
JsonValue; object_ "thread.message.deleted"constant"thread.message.deleted"constant
class MessageDelta:

The delta containing the fields that have changed on the Message.

Optional<List<MessageContentDelta>> content

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

Accepts one of the following:
class ImageFileDeltaBlock:

References an image File in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_file"constant"image_file"constant

Always image_file.

Optional<ImageFileDelta> imageFile
class TextDeltaBlock:

The text content that is part of a message.

long index

The index of the content part in the message.

JsonValue; type "text"constant"text"constant

Always text.

Optional<TextDelta> text
class RefusalDeltaBlock:

The refusal content that is part of a message.

long index

The index of the refusal part in the message.

JsonValue; type "refusal"constant"refusal"constant

Always refusal.

Optional<String> refusal
class ImageUrlDeltaBlock:

References an image URL in the content of a message.

long index

The index of the content part in the message.

JsonValue; type "image_url"constant"image_url"constant

Always image_url.

Optional<ImageUrlDelta> imageUrl
Optional<Role> role

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

Accepts one of the following:
USER("user")
ASSISTANT("assistant")
class MessageDeltaEvent:

Represents a message delta i.e. any changed fields on a message during streaming.

String id

The identifier of the message, which can be referenced in API endpoints.

The delta containing the fields that have changed on the Message.

JsonValue; object_ "thread.message.delta"constant"thread.message.delta"constant

The object type, which is always thread.message.delta.

class RefusalContentBlock:

The refusal content generated by the assistant.

String refusal
JsonValue; type "refusal"constant"refusal"constant

Always refusal.

class RefusalDeltaBlock:

The refusal content that is part of a message.

long index

The index of the refusal part in the message.

JsonValue; type "refusal"constant"refusal"constant

Always refusal.

Optional<String> refusal
class Text:
List<Annotation> annotations
Accepts one of the following:
class FileCitationAnnotation:

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.

long endIndex
minimum0
FileCitation fileCitation
String fileId

The ID of the specific File the citation is from.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

class FilePathAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long endIndex
minimum0
FilePath filePath
String fileId

The ID of the file that was generated.

long startIndex
minimum0
String text

The text in the message content that needs to be replaced.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

String value

The data that makes up the text.

class TextContentBlock:

The text content that is part of a message.

Text text
JsonValue; type "text"constant"text"constant

Always text.

class TextContentBlockParam:

The text content that is part of a message.

String text

Text content to be sent to the model

JsonValue; type "text"constant"text"constant

Always text.

class TextDelta:
Optional<List<AnnotationDelta>> annotations
Accepts one of the following:
class FileCitationDeltaAnnotation:

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.

long index

The index of the annotation in the text content part.

JsonValue; type "file_citation"constant"file_citation"constant

Always file_citation.

Optional<Long> endIndex
minimum0
Optional<FileCitation> fileCitation
Optional<String> fileId

The ID of the specific File the citation is from.

Optional<String> quote

The specific quote in the file.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

class FilePathDeltaAnnotation:

A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file.

long index

The index of the annotation in the text content part.

JsonValue; type "file_path"constant"file_path"constant

Always file_path.

Optional<Long> endIndex
minimum0
Optional<FilePath> filePath
Optional<String> fileId

The ID of the file that was generated.

Optional<Long> startIndex
minimum0
Optional<String> text

The text in the message content that needs to be replaced.

Optional<String> value

The data that makes up the text.

class TextDeltaBlock:

The text content that is part of a message.

long index

The index of the content part in the message.

JsonValue; type "text"constant"text"constant

Always text.

Optional<TextDelta> text