microsoft-foundry.rest.security.o-auth2-auth
Chat
Delete a chat completion
DELETE
/openai/v1/chat/completions/{completion_id}
Deletes a chat completion by its identifier.
Pfadparameter
completion_id
string
Erforderlich
The ID of the chat completion to delete.
Antworten
The request has succeeded.
Text
Content-Type: application/json
object
enum
Erforderlich
The type of object being deleted.
chat.completion.deleted
id
string
Erforderlich
The ID of the chat completion that was deleted.
deleted
boolean
Erforderlich
Whether the chat completion was deleted.
Anfordern
curl -X DELETE https://api.openai.com/v1/chat/completions/chat_abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json"
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
chat_completion_deleted = client.chat.completions.delete(
"completion_id",
)
print(chat_completion_deleted.id)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});
const chatCompletionDeleted = await client.chat.completions.delete('completion_id');
console.log(chatCompletionDeleted.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"),
)
chatCompletionDeleted, err := client.Chat.Completions.Delete(context.TODO(), "completion_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v
", chatCompletionDeleted.ID)
}
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletionDeleteParams;
import com.openai.models.chat.completions.ChatCompletionDeleted;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ChatCompletionDeleted chatCompletionDeleted = client.chat().completions().delete("completion_id");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
chat_completion_deleted = openai.chat.completions.delete("completion_id")
puts(chat_completion_deleted)
Antwort
{
"object": "chat.completion.deleted",
"id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
"deleted": true
}