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 file

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

Delete a file and remove it from all vector stores.

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)
}
Response example
{
  "id": "file-abc123",
  "object": "file",
  "deleted": true
}
Parameters
fileID string
Returns
type FileDeleted struct{…}
ID string
Deleted bool
Object File
Returns Examples
Response example
{
  "id": "file-abc123",
  "object": "file",
  "deleted": true
}