Skip to content

Delete chat completion

client.Chat.Completions.Delete(ctx, completionID) (*ChatCompletionDeleted, error)
DELETE/chat/completions/{completion_id}

Delete a stored chat completion. Only Chat Completions that have been created with the store parameter set to true can be deleted.

ParametersExpand Collapse
completionID string
ReturnsExpand Collapse
type ChatCompletionDeleted struct{…}
ID string

The ID of the chat completion that was deleted.

Deleted bool

Whether the chat completion was deleted.

Object ChatCompletionDeleted

The type of object being deleted.

Delete chat completion

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\n", chatCompletionDeleted.ID)
}
{
  "id": "id",
  "deleted": true,
  "object": "chat.completion.deleted"
}
Returns Examples
{
  "id": "id",
  "deleted": true,
  "object": "chat.completion.deleted"
}