Pular para o conteúdo principal

Não há mais suporte para esse navegador.

Atualize o Microsoft Edge para aproveitar os recursos, o suporte técnico e as atualizações de segurança mais recentes.

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

Threads, Assistants

Delete a thread

DELETE /openai/v1/threads/{thread_id}

Deletes a thread by its identifier.

Parâmetros de caminho

thread_id string exigido

The ID of the thread to delete.

Respostas

The request has succeeded.

Corpo

Content-Type: application/json
id string exigido
deleted boolean exigido
object enum exigido
thread.deleted

Client error

Corpo

Content-Type: application/json
error OpenAI.Error exigido
code string | null exigido
message string exigido
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 exigido

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Corpo

Content-Type: application/json
error OpenAI.Error exigido
code string | null exigido
message string exigido
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 exigido

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Solicitar

curl https://api.openai.com/v1/threads/thread_abc123 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Beta: assistants=v2" \
  -X DELETE
import os
from openai import OpenAI

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

const openai = new OpenAI();

async function main() {
  const response = await openai.beta.threads.delete("thread_abc123");

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

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

const threadDeleted = await client.beta.threads.delete('thread_id');

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

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.beta.threads.ThreadDeleteParams;
import com.openai.models.beta.threads.ThreadDeleted;

public final class Main {
    private Main() {}

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

        ThreadDeleted threadDeleted = client.beta().threads().delete("thread_id");
    }
}
require "openai"

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

thread_deleted = openai.beta.threads.delete("thread_id")

puts(thread_deleted)

Resposta

{
  "id": "thread_abc123",
  "object": "thread.deleted",
  "deleted": true
}
pt-br
Suas escolhas de privacidade
  • Aviso de isenção de responsabilidade sobre a IA
  • Versões anteriores
  • Blog
  • Contribuir
  • Privacidade
  • Privacidade da Integridade do Consumidor
  • Termos de Uso
  • Marcas Comerciais
  • © Microsoft 2026