Delete file
client.Files.Delete(ctx, fileID) (*FileDeleted, error)
delete /files/{file_id}
Delete a file and remove it from all vector stores.
Parameters
fileID string
Returns
-
type FileDeleted struct{…}-
ID string -
Deleted bool -
Object Fileconst FileFile File = "file"
-
Example
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
{
"id": "id",
"deleted": true,
"object": "file"
}