Skip to content

Delete file

client.Files.Delete(ctx, fileID) (*FileDeleted, error)
DELETE/files/{file_id}

Delete a file and remove it from all vector stores.

ParametersExpand Collapse
fileID string
ReturnsExpand Collapse
type FileDeleted struct{…}
ID string
Deleted bool
Object File

Delete file

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"),
  )
  fileDeleted, err := client.Files.Delete(context.TODO(), "file_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fileDeleted.ID)
}
{
  "id": "id",
  "deleted": true,
  "object": "file"
}
Returns Examples
{
  "id": "id",
  "deleted": true,
  "object": "file"
}