Přeskočit na hlavní obsah

Tento prohlížeč se už nepodporuje.

Upgradujte na Microsoft Edge, abyste mohli využívat nejnovější funkce, aktualizace zabezpečení a technickou podporu.

Stáhnout Microsoft Edge Další informace o Internet Exploreru a Microsoft Edgi
microsoft-foundry.rest.security.o-auth2-auth

Threads, Assistants

Delete a message

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

Deletes a message by its identifier.

Parametry cesty

thread_id string vyžadováno

The ID of the thread to which this message belongs.

message_id string vyžadováno

The ID of the message to delete.

Odpovědi

The request has succeeded.

Text

Content-Type: application/json
id string vyžadováno
deleted boolean vyžadováno
object enum vyžadováno
thread.message.deleted

Client error

Text

Content-Type: application/json
error OpenAI.Error vyžadováno
code string | null vyžadováno
message string vyžadováno
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Některá z následujících možností:
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 vyžadováno

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Text

Content-Type: application/json
error OpenAI.Error vyžadováno
code string | null vyžadováno
message string vyžadováno
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Některá z následujících možností:
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 vyžadováno

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Žádost

curl -X DELETE 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"
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_deleted = client.beta.threads.messages.delete(
    message_id="message_id",
    thread_id="thread_id",
)
print(message_deleted.id)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const deletedMessage = await openai.beta.threads.messages.delete(
    "msg_abc123",
    { thread_id: "thread_abc123" }
  );

  console.log(deletedMessage);
}
import OpenAI from 'openai';

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

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

console.log(messageDeleted.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"),
    )
    messageDeleted, err := client.Beta.Threads.Messages.Delete(
        context.TODO(),
        "thread_id",
        "message_id",
    )
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", messageDeleted.ID)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.messages.MessageDeleteParams;
import com.openai.models.beta.threads.messages.MessageDeleted;

public final class Main {
    private Main() {}

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

        MessageDeleteParams params = MessageDeleteParams.builder()
            .threadId("thread_id")
            .messageId("message_id")
            .build();
        MessageDeleted messageDeleted = client.beta().threads().messages().delete(params);
    }
}
require "openai"

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

message_deleted = openai.beta.threads.messages.delete("message_id", thread_id: "thread_id")

puts(message_deleted)

Response

{
  "id": "msg_abc123",
  "object": "thread.message.deleted",
  "deleted": true
}
cs-cz
Vaše volby ochrany osobních údajů
  • Právní omezení AI
  • Předchozí verze
  • Blog
  • Přispět
  • Ochrana osobních údajů
  • Ochrana osobních zdravotních údajů spotřebitelů
  • Podmínky použití
  • Ochranné známky
  • © Microsoft 2026