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.
路徑參數
completion_id
string
必要
The ID of the chat completion to delete.
回覆
The request has succeeded.
主體
Content-Type: application/json
object
enum
必要
The type of object being deleted.
chat.completion.deleted
id
string
必要
The ID of the chat completion that was deleted.
deleted
boolean
必要
Whether the chat completion was deleted.
Request
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)
回應
{
"object": "chat.completion.deleted",
"id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
"deleted": true
}