python/resources/uploads/methods/complete/index.md +0 −180 deleted
File Deleted View Diff
1## Complete upload
2
3`uploads.complete(strupload_id, UploadCompleteParams**kwargs) -> Upload`
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- `upload_id: str`
19
20- `part_ids: Sequence[str]`
21
22 The ordered list of Part IDs.
23
24- `md5: Optional[str]`
25
26 The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect.
27
28### Returns
29
30- `class Upload: …`
31
32 The Upload object can accept byte chunks in the form of Parts.
33
34 - `id: str`
35
36 The Upload unique identifier, which can be referenced in API endpoints.
37
38 - `bytes: int`
39
40 The intended number of bytes to be uploaded.
41
42 - `created_at: int`
43
44 The Unix timestamp (in seconds) for when the Upload was created.
45
46 - `expires_at: int`
47
48 The Unix timestamp (in seconds) for when the Upload will expire.
49
50 - `filename: str`
51
52 The name of the file to be uploaded.
53
54 - `object: Literal["upload"]`
55
56 The object type, which is always "upload".
57
58 - `"upload"`
59
60 - `purpose: str`
61
62 The intended purpose of the file. [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose) for acceptable values.
63
64 - `status: Literal["pending", "completed", "cancelled", "expired"]`
65
66 The status of the Upload.
67
68 - `"pending"`
69
70 - `"completed"`
71
72 - `"cancelled"`
73
74 - `"expired"`
75
76 - `file: Optional[FileObject]`
77
78 The `File` object represents a document that has been uploaded to OpenAI.
79
80 - `id: str`
81
82 The file identifier, which can be referenced in the API endpoints.
83
84 - `bytes: int`
85
86 The size of the file, in bytes.
87
88 - `created_at: int`
89
90 The Unix timestamp (in seconds) for when the file was created.
91
92 - `filename: str`
93
94 The name of the file.
95
96 - `object: Literal["file"]`
97
98 The object type, which is always `file`.
99
100 - `"file"`
101
102 - `purpose: Literal["assistants", "assistants_output", "batch", 5 more]`
103
104 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
105
106 - `"assistants"`
107
108 - `"assistants_output"`
109
110 - `"batch"`
111
112 - `"batch_output"`
113
114 - `"fine-tune"`
115
116 - `"fine-tune-results"`
117
118 - `"vision"`
119
120 - `"user_data"`
121
122 - `status: Literal["uploaded", "processed", "error"]`
123
124 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
125
126 - `"uploaded"`
127
128 - `"processed"`
129
130 - `"error"`
131
132 - `expires_at: Optional[int]`
133
134 The Unix timestamp (in seconds) for when the file will expire.
135
136 - `status_details: Optional[str]`
137
138 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
139
140### Example
141
142```python
143import os
144from openai import OpenAI
145
146client = OpenAI(
147 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
148)
149upload = client.uploads.complete(
150 upload_id="upload_abc123",
151 part_ids=["string"],
152)
153print(upload.id)
154```
155
156#### Response
157
158```json
159{
160 "id": "id",
161 "bytes": 0,
162 "created_at": 0,
163 "expires_at": 0,
164 "filename": "filename",
165 "object": "upload",
166 "purpose": "purpose",
167 "status": "pending",
168 "file": {
169 "id": "id",
170 "bytes": 0,
171 "created_at": 0,
172 "filename": "filename",
173 "object": "file",
174 "purpose": "assistants",
175 "status": "uploaded",
176 "expires_at": 0,
177 "status_details": "status_details"
178 }
179}
180```