go/resources/files/methods/delete/index.md +0 −58 deleted
File Deleted View Diff
1## Delete file
2
3`client.Files.Delete(ctx, fileID) (*FileDeleted, error)`
4
5**delete** `/files/{file_id}`
6
7Delete a file and remove it from all vector stores.
8
9### Parameters
10
11- `fileID string`
12
13### Returns
14
15- `type FileDeleted struct{…}`
16
17 - `ID string`
18
19 - `Deleted bool`
20
21 - `Object File`
22
23 - `const FileFile File = "file"`
24
25### Example
26
27```go
28package main
29
30import (
31 "context"
32 "fmt"
33
34 "github.com/openai/openai-go"
35 "github.com/openai/openai-go/option"
36)
37
38func main() {
39 client := openai.NewClient(
40 option.WithAPIKey("My API Key"),
41 )
42 fileDeleted, err := client.Files.Delete(context.TODO(), "file_id")
43 if err != nil {
44 panic(err.Error())
45 }
46 fmt.Printf("%+v\n", fileDeleted.ID)
47}
48```
49
50#### Response
51
52```json
53{
54 "id": "id",
55 "deleted": true,
56 "object": "file"
57}
58```