go/resources/files/methods/retrieve/index.md +0 −118 deleted
File Deleted View Diff
1## Retrieve file
2
3`client.Files.Get(ctx, fileID) (*FileObject, error)`
4
5**get** `/files/{file_id}`
6
7Returns information about a specific file.
8
9### Parameters
10
11- `fileID string`
12
13### Returns
14
15- `type FileObject struct{…}`
16
17 The `File` object represents a document that has been uploaded to OpenAI.
18
19 - `ID string`
20
21 The file identifier, which can be referenced in the API endpoints.
22
23 - `Bytes int64`
24
25 The size of the file, in bytes.
26
27 - `CreatedAt int64`
28
29 The Unix timestamp (in seconds) for when the file was created.
30
31 - `Filename string`
32
33 The name of the file.
34
35 - `Object File`
36
37 The object type, which is always `file`.
38
39 - `const FileFile File = "file"`
40
41 - `Purpose FileObjectPurpose`
42
43 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
44
45 - `const FileObjectPurposeAssistants FileObjectPurpose = "assistants"`
46
47 - `const FileObjectPurposeAssistantsOutput FileObjectPurpose = "assistants_output"`
48
49 - `const FileObjectPurposeBatch FileObjectPurpose = "batch"`
50
51 - `const FileObjectPurposeBatchOutput FileObjectPurpose = "batch_output"`
52
53 - `const FileObjectPurposeFineTune FileObjectPurpose = "fine-tune"`
54
55 - `const FileObjectPurposeFineTuneResults FileObjectPurpose = "fine-tune-results"`
56
57 - `const FileObjectPurposeVision FileObjectPurpose = "vision"`
58
59 - `const FileObjectPurposeUserData FileObjectPurpose = "user_data"`
60
61 - `Status FileObjectStatus`
62
63 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
64
65 - `const FileObjectStatusUploaded FileObjectStatus = "uploaded"`
66
67 - `const FileObjectStatusProcessed FileObjectStatus = "processed"`
68
69 - `const FileObjectStatusError FileObjectStatus = "error"`
70
71 - `ExpiresAt int64`
72
73 The Unix timestamp (in seconds) for when the file will expire.
74
75 - `StatusDetails string`
76
77 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
78
79### Example
80
81```go
82package main
83
84import (
85 "context"
86 "fmt"
87
88 "github.com/openai/openai-go"
89 "github.com/openai/openai-go/option"
90)
91
92func main() {
93 client := openai.NewClient(
94 option.WithAPIKey("My API Key"),
95 )
96 fileObject, err := client.Files.Get(context.TODO(), "file_id")
97 if err != nil {
98 panic(err.Error())
99 }
100 fmt.Printf("%+v\n", fileObject.ID)
101}
102```
103
104#### Response
105
106```json
107{
108 "id": "id",
109 "bytes": 0,
110 "created_at": 0,
111 "filename": "filename",
112 "object": "file",
113 "purpose": "assistants",
114 "status": "uploaded",
115 "expires_at": 0,
116 "status_details": "status_details"
117}
118```