java/resources/containers/subresources/files/index.md +0 −373 deleted
File Deleted View Diff
1# Files
2
3## List container files
4
5`FileListPage containers().files().list(FileListParamsparams = FileListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`
6
7**get** `/containers/{container_id}/files`
8
9List Container files
10
11### Parameters
12
13- `FileListParams params`
14
15 - `Optional<String> containerId`
16
17 - `Optional<String> after`
18
19 A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
20
21 - `Optional<Long> limit`
22
23 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
24
25 - `Optional<Order> order`
26
27 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
28
29 - `ASC("asc")`
30
31 - `DESC("desc")`
32
33### Returns
34
35- `class FileListResponse:`
36
37 - `String id`
38
39 Unique identifier for the file.
40
41 - `long bytes`
42
43 Size of the file in bytes.
44
45 - `String containerId`
46
47 The container this file belongs to.
48
49 - `long createdAt`
50
51 Unix timestamp (in seconds) when the file was created.
52
53 - `JsonValue; object_ "container.file"constant`
54
55 The type of this object (`container.file`).
56
57 - `CONTAINER_FILE("container.file")`
58
59 - `String path`
60
61 Path of the file in the container.
62
63 - `String source`
64
65 Source of the file (e.g., `user`, `assistant`).
66
67### Example
68
69```java
70package com.openai.example;
71
72import com.openai.client.OpenAIClient;
73import com.openai.client.okhttp.OpenAIOkHttpClient;
74import com.openai.models.containers.files.FileListPage;
75import com.openai.models.containers.files.FileListParams;
76
77public final class Main {
78 private Main() {}
79
80 public static void main(String[] args) {
81 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
82
83 FileListPage page = client.containers().files().list("container_id");
84 }
85}
86```
87
88#### Response
89
90```json
91{
92 "data": [
93 {
94 "id": "id",
95 "bytes": 0,
96 "container_id": "container_id",
97 "created_at": 0,
98 "object": "container.file",
99 "path": "path",
100 "source": "source"
101 }
102 ],
103 "first_id": "first_id",
104 "has_more": true,
105 "last_id": "last_id",
106 "object": "list"
107}
108```
109
110## Create container file
111
112`FileCreateResponse containers().files().create(FileCreateParamsparams = FileCreateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`
113
114**post** `/containers/{container_id}/files`
115
116Create a Container File
117
118You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
119
120### Parameters
121
122- `FileCreateParams params`
123
124 - `Optional<String> containerId`
125
126 - `Optional<String> file`
127
128 The File object (not file name) to be uploaded.
129
130 - `Optional<String> fileId`
131
132 Name of the file to create.
133
134### Returns
135
136- `class FileCreateResponse:`
137
138 - `String id`
139
140 Unique identifier for the file.
141
142 - `long bytes`
143
144 Size of the file in bytes.
145
146 - `String containerId`
147
148 The container this file belongs to.
149
150 - `long createdAt`
151
152 Unix timestamp (in seconds) when the file was created.
153
154 - `JsonValue; object_ "container.file"constant`
155
156 The type of this object (`container.file`).
157
158 - `CONTAINER_FILE("container.file")`
159
160 - `String path`
161
162 Path of the file in the container.
163
164 - `String source`
165
166 Source of the file (e.g., `user`, `assistant`).
167
168### Example
169
170```java
171package com.openai.example;
172
173import com.openai.client.OpenAIClient;
174import com.openai.client.okhttp.OpenAIOkHttpClient;
175import com.openai.models.containers.files.FileCreateParams;
176import com.openai.models.containers.files.FileCreateResponse;
177
178public final class Main {
179 private Main() {}
180
181 public static void main(String[] args) {
182 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
183
184 FileCreateResponse file = client.containers().files().create("container_id");
185 }
186}
187```
188
189#### Response
190
191```json
192{
193 "id": "id",
194 "bytes": 0,
195 "container_id": "container_id",
196 "created_at": 0,
197 "object": "container.file",
198 "path": "path",
199 "source": "source"
200}
201```
202
203## Retrieve container file
204
205`FileRetrieveResponse containers().files().retrieve(FileRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
206
207**get** `/containers/{container_id}/files/{file_id}`
208
209Retrieve Container File
210
211### Parameters
212
213- `FileRetrieveParams params`
214
215 - `String containerId`
216
217 - `Optional<String> fileId`
218
219### Returns
220
221- `class FileRetrieveResponse:`
222
223 - `String id`
224
225 Unique identifier for the file.
226
227 - `long bytes`
228
229 Size of the file in bytes.
230
231 - `String containerId`
232
233 The container this file belongs to.
234
235 - `long createdAt`
236
237 Unix timestamp (in seconds) when the file was created.
238
239 - `JsonValue; object_ "container.file"constant`
240
241 The type of this object (`container.file`).
242
243 - `CONTAINER_FILE("container.file")`
244
245 - `String path`
246
247 Path of the file in the container.
248
249 - `String source`
250
251 Source of the file (e.g., `user`, `assistant`).
252
253### Example
254
255```java
256package com.openai.example;
257
258import com.openai.client.OpenAIClient;
259import com.openai.client.okhttp.OpenAIOkHttpClient;
260import com.openai.models.containers.files.FileRetrieveParams;
261import com.openai.models.containers.files.FileRetrieveResponse;
262
263public final class Main {
264 private Main() {}
265
266 public static void main(String[] args) {
267 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
268
269 FileRetrieveParams params = FileRetrieveParams.builder()
270 .containerId("container_id")
271 .fileId("file_id")
272 .build();
273 FileRetrieveResponse file = client.containers().files().retrieve(params);
274 }
275}
276```
277
278#### Response
279
280```json
281{
282 "id": "id",
283 "bytes": 0,
284 "container_id": "container_id",
285 "created_at": 0,
286 "object": "container.file",
287 "path": "path",
288 "source": "source"
289}
290```
291
292## Delete a container file
293
294`containers().files().delete(FileDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
295
296**delete** `/containers/{container_id}/files/{file_id}`
297
298Delete Container File
299
300### Parameters
301
302- `FileDeleteParams params`
303
304 - `String containerId`
305
306 - `Optional<String> fileId`
307
308### Example
309
310```java
311package com.openai.example;
312
313import com.openai.client.OpenAIClient;
314import com.openai.client.okhttp.OpenAIOkHttpClient;
315import com.openai.models.containers.files.FileDeleteParams;
316
317public final class Main {
318 private Main() {}
319
320 public static void main(String[] args) {
321 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
322
323 FileDeleteParams params = FileDeleteParams.builder()
324 .containerId("container_id")
325 .fileId("file_id")
326 .build();
327 client.containers().files().delete(params);
328 }
329}
330```
331
332# Content
333
334## Retrieve container file content
335
336`HttpResponse containers().files().content().retrieve(ContentRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
337
338**get** `/containers/{container_id}/files/{file_id}/content`
339
340Retrieve Container File Content
341
342### Parameters
343
344- `ContentRetrieveParams params`
345
346 - `String containerId`
347
348 - `Optional<String> fileId`
349
350### Example
351
352```java
353package com.openai.example;
354
355import com.openai.client.OpenAIClient;
356import com.openai.client.okhttp.OpenAIOkHttpClient;
357import com.openai.core.http.HttpResponse;
358import com.openai.models.containers.files.content.ContentRetrieveParams;
359
360public final class Main {
361 private Main() {}
362
363 public static void main(String[] args) {
364 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
365
366 ContentRetrieveParams params = ContentRetrieveParams.builder()
367 .containerId("container_id")
368 .fileId("file_id")
369 .build();
370 HttpResponse content = client.containers().files().content().retrieve(params);
371 }
372}
373```