Skip to content
Primary navigation

Modify message

Deprecated
Message beta().threads().messages().update(MessageUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/threads/{thread_id}/messages/{message_id}

Modifies a message.

ParametersExpand Collapse
MessageUpdateParams params
String threadId
Optional<String> messageId
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.

ReturnsExpand Collapse
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
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")
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
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")
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
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.

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.

Modify message

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.Message;
import com.openai.models.beta.threads.messages.MessageUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        MessageUpdateParams params = MessageUpdateParams.builder()
            .threadId("thread_id")
            .messageId("message_id")
            .build();
        Message message = client.beta().threads().messages().update(params);
    }
}
{
  "id": "msg_abc123",
  "object": "thread.message",
  "created_at": 1699017614,
  "assistant_id": null,
  "thread_id": "thread_abc123",
  "run_id": null,
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": {
        "value": "How does AI work? Explain it in simple terms.",
        "annotations": []
      }
    }
  ],
  "file_ids": [],
  "metadata": {
    "modified": "true",
    "user": "abc123"
  }
}
Returns Examples
{
  "id": "msg_abc123",
  "object": "thread.message",
  "created_at": 1699017614,
  "assistant_id": null,
  "thread_id": "thread_abc123",
  "run_id": null,
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": {
        "value": "How does AI work? Explain it in simple terms.",
        "annotations": []
      }
    }
  ],
  "file_ids": [],
  "metadata": {
    "modified": "true",
    "user": "abc123"
  }
}