Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

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.

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)
}
Response example
{
  "object": "chat.completion.deleted",
  "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
  "deleted": true
}
Parameters
completionID string
Returns
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.

Returns Examples
Response example
{
  "object": "chat.completion.deleted",
  "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",
  "deleted": true
}