Saltar para o conteúdo principal

Este browser já não é suportado.

Atualize para o Microsoft Edge para tirar partido das mais recentes funcionalidades, atualizações de segurança e de suporte técnico.

Transferir Microsoft Edge Mais informações sobre o Internet Explorer e o Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Threads, Assistants

Update a message

POST /openai/v1/threads/{thread_id}/messages/{message_id}

Updates a message with the supplied changes.

Parâmetros de caminho

thread_id string obrigatório

The ID of the thread to which this message belongs.

message_id string obrigatório

The ID of the message to modify.

Corpo do Pedido

The request body.

Content-Type: application/json
metadata OpenAI.Metadata | null

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.

[key: string] string

Respostas

The request has succeeded.

Corpo

Content-Type: application/json
id string obrigatório

The identifier, which can be referenced in API endpoints.

object enum obrigatório

The object type, which is always thread.message.

thread.message
created_at integer obrigatório

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

thread_id string obrigatório

The thread ID that this message belongs to.

status enum obrigatório

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

in_progressincompletecompleted
incomplete_details OpenAI.MessageObjectIncompleteDetails | null obrigatório
reason enum obrigatório
content_filtermax_tokensrun_cancelledrun_expiredrun_failed
completed_at integer | null obrigatório
incomplete_at integer | null obrigatório
role enum obrigatório

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

userassistant
content OpenAI.MessageObjectContent[] obrigatório

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

assistant_id string | null obrigatório
run_id string | null obrigatório
attachments OpenAI.MessageObjectAttachments[] | null obrigatório
metadata OpenAI.Metadata | null obrigatório

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.

[key: string] string

Client error

Corpo

Content-Type: application/json
error OpenAI.Error obrigatório
code string | null obrigatório
message string obrigatório
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Qualquer uma das seguintes opções:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string obrigatório

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Corpo

Content-Type: application/json
error OpenAI.Error obrigatório
code string | null obrigatório
message string obrigatório
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Qualquer uma das seguintes opções:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string obrigatório

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Pedir

curl https://api.openai.com/v1/threads/thread_abc123/messages/msg_abc123 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Beta: assistants=v2" \
  -d '{
      "metadata": {
        "modified": "true",
        "user": "abc123"
      }
    }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
message = client.beta.threads.messages.update(
    message_id="message_id",
    thread_id="thread_id",
)
print(message.id)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const message = await openai.beta.threads.messages.update(
    "thread_abc123",
    "msg_abc123",
    {
      metadata: {
        modified: "true",
        user: "abc123",
      },
    }
  }'
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const message = await client.beta.threads.messages.update('message_id', { thread_id: 'thread_id' });

console.log(message.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    message, err := client.Beta.Threads.Messages.Update(
        context.TODO(),
        "thread_id",
        "message_id",
        openai.BetaThreadMessageUpdateParams{},
    )
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", message.ID)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

message = openai.beta.threads.messages.update("message_id", thread_id: "thread_id")

puts(message)

Response

{
  "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"
  }
}
pt-pt
Suas opções de privacidade
  • Exclusão de responsabilidade de IA
  • Versões anteriores
  • Blogue
  • Contribuir
  • Privacidade
  • Privacidade da Saúde do Consumidor
  • Termos de Utilização
  • Marcas Comerciais
  • © Microsoft 2026