go/resources/uploads/methods/complete/index.md +0 −197 deleted
File Deleted View Diff
1## Complete upload
2
3`client.Uploads.Complete(ctx, uploadID, body) (*Upload, error)`
4
5**post** `/uploads/{upload_id}/complete`
6
7Completes the [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
8
9Within the returned Upload object, there is a nested [File](https://platform.openai.com/docs/api-reference/files/object) object that is ready to use in the rest of the platform.
10
11You can specify the order of the Parts by passing in an ordered list of the Part IDs.
12
13The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed.
14Returns the Upload object with status `completed`, including an additional `file` property containing the created usable File object.
15
16### Parameters
17
18- `uploadID string`
19
20- `body UploadCompleteParams`
21
22 - `PartIDs param.Field[[]string]`
23
24 The ordered list of Part IDs.
25
26 - `Md5 param.Field[string]`
27
28 The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.
29
30### Returns
31
32- `type Upload struct{…}`
33
34 The Upload object can accept byte chunks in the form of Parts.
35
36 - `ID string`
37
38 The Upload unique identifier, which can be referenced in API endpoints.
39
40 - `Bytes int64`
41
42 The intended number of bytes to be uploaded.
43
44 - `CreatedAt int64`
45
46 The Unix timestamp (in seconds) for when the Upload was created.
47
48 - `ExpiresAt int64`
49
50 The Unix timestamp (in seconds) for when the Upload will expire.
51
52 - `Filename string`
53
54 The name of the file to be uploaded.
55
56 - `Object Upload`
57
58 The object type, which is always "upload".
59
60 - `const UploadUpload Upload = "upload"`
61
62 - `Purpose string`
63
64 The intended purpose of the file. [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose) for acceptable values.
65
66 - `Status UploadStatus`
67
68 The status of the Upload.
69
70 - `const UploadStatusPending UploadStatus = "pending"`
71
72 - `const UploadStatusCompleted UploadStatus = "completed"`
73
74 - `const UploadStatusCancelled UploadStatus = "cancelled"`
75
76 - `const UploadStatusExpired UploadStatus = "expired"`
77
78 - `File FileObject`
79
80 The `File` object represents a document that has been uploaded to OpenAI.
81
82 - `ID string`
83
84 The file identifier, which can be referenced in the API endpoints.
85
86 - `Bytes int64`
87
88 The size of the file, in bytes.
89
90 - `CreatedAt int64`
91
92 The Unix timestamp (in seconds) for when the file was created.
93
94 - `Filename string`
95
96 The name of the file.
97
98 - `Object File`
99
100 The object type, which is always `file`.
101
102 - `const FileFile File = "file"`
103
104 - `Purpose FileObjectPurpose`
105
106 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
107
108 - `const FileObjectPurposeAssistants FileObjectPurpose = "assistants"`
109
110 - `const FileObjectPurposeAssistantsOutput FileObjectPurpose = "assistants_output"`
111
112 - `const FileObjectPurposeBatch FileObjectPurpose = "batch"`
113
114 - `const FileObjectPurposeBatchOutput FileObjectPurpose = "batch_output"`
115
116 - `const FileObjectPurposeFineTune FileObjectPurpose = "fine-tune"`
117
118 - `const FileObjectPurposeFineTuneResults FileObjectPurpose = "fine-tune-results"`
119
120 - `const FileObjectPurposeVision FileObjectPurpose = "vision"`
121
122 - `const FileObjectPurposeUserData FileObjectPurpose = "user_data"`
123
124 - `Status FileObjectStatus`
125
126 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
127
128 - `const FileObjectStatusUploaded FileObjectStatus = "uploaded"`
129
130 - `const FileObjectStatusProcessed FileObjectStatus = "processed"`
131
132 - `const FileObjectStatusError FileObjectStatus = "error"`
133
134 - `ExpiresAt int64`
135
136 The Unix timestamp (in seconds) for when the file will expire.
137
138 - `StatusDetails string`
139
140 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
141
142### Example
143
144```go
145package main
146
147import (
148 "context"
149 "fmt"
150
151 "github.com/openai/openai-go"
152 "github.com/openai/openai-go/option"
153)
154
155func main() {
156 client := openai.NewClient(
157 option.WithAPIKey("My API Key"),
158 )
159 upload, err := client.Uploads.Complete(
160 context.TODO(),
161 "upload_abc123",
162 openai.UploadCompleteParams{
163 PartIDs: []string{"string"},
164 },
165 )
166 if err != nil {
167 panic(err.Error())
168 }
169 fmt.Printf("%+v\n", upload.ID)
170}
171```
172
173#### Response
174
175```json
176{
177 "id": "id",
178 "bytes": 0,
179 "created_at": 0,
180 "expires_at": 0,
181 "filename": "filename",
182 "object": "upload",
183 "purpose": "purpose",
184 "status": "pending",
185 "file": {
186 "id": "id",
187 "bytes": 0,
188 "created_at": 0,
189 "filename": "filename",
190 "object": "file",
191 "purpose": "assistants",
192 "status": "uploaded",
193 "expires_at": 0,
194 "status_details": "status_details"
195 }
196}
197```