ruby/resources/containers/subresources/files/index.md +0 −415 deleted
File Deleted View Diff
1# Files
2
3## List container files
4
5`containers.files.list(container_id, **kwargs) -> CursorPage<FileListResponse>`
6
7**get** `/containers/{container_id}/files`
8
9List Container files
10
11### Parameters
12
13- `container_id: String`
14
15- `after: String`
16
17 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.
18
19- `limit: Integer`
20
21 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
22
23- `order: :asc | :desc`
24
25 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
26
27 - `:asc`
28
29 - `:desc`
30
31### Returns
32
33- `class FileListResponse`
34
35 - `id: String`
36
37 Unique identifier for the file.
38
39 - `bytes: Integer`
40
41 Size of the file in bytes.
42
43 - `container_id: String`
44
45 The container this file belongs to.
46
47 - `created_at: Integer`
48
49 Unix timestamp (in seconds) when the file was created.
50
51 - `object: :"container.file"`
52
53 The type of this object (`container.file`).
54
55 - `:"container.file"`
56
57 - `path: String`
58
59 Path of the file in the container.
60
61 - `source: String`
62
63 Source of the file (e.g., `user`, `assistant`).
64
65### Example
66
67```ruby
68require "openai"
69
70openai = OpenAI::Client.new(api_key: "My API Key")
71
72page = openai.containers.files.list("container_id")
73
74puts(page)
75```
76
77#### Response
78
79```json
80{
81 "data": [
82 {
83 "id": "id",
84 "bytes": 0,
85 "container_id": "container_id",
86 "created_at": 0,
87 "object": "container.file",
88 "path": "path",
89 "source": "source"
90 }
91 ],
92 "first_id": "first_id",
93 "has_more": true,
94 "last_id": "last_id",
95 "object": "list"
96}
97```
98
99## Create container file
100
101`containers.files.create(container_id, **kwargs) -> FileCreateResponse`
102
103**post** `/containers/{container_id}/files`
104
105Create a Container File
106
107You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
108
109### Parameters
110
111- `container_id: String`
112
113- `file: String`
114
115 The File object (not file name) to be uploaded.
116
117- `file_id: String`
118
119 Name of the file to create.
120
121### Returns
122
123- `class FileCreateResponse`
124
125 - `id: String`
126
127 Unique identifier for the file.
128
129 - `bytes: Integer`
130
131 Size of the file in bytes.
132
133 - `container_id: String`
134
135 The container this file belongs to.
136
137 - `created_at: Integer`
138
139 Unix timestamp (in seconds) when the file was created.
140
141 - `object: :"container.file"`
142
143 The type of this object (`container.file`).
144
145 - `:"container.file"`
146
147 - `path: String`
148
149 Path of the file in the container.
150
151 - `source: String`
152
153 Source of the file (e.g., `user`, `assistant`).
154
155### Example
156
157```ruby
158require "openai"
159
160openai = OpenAI::Client.new(api_key: "My API Key")
161
162file = openai.containers.files.create("container_id")
163
164puts(file)
165```
166
167#### Response
168
169```json
170{
171 "id": "id",
172 "bytes": 0,
173 "container_id": "container_id",
174 "created_at": 0,
175 "object": "container.file",
176 "path": "path",
177 "source": "source"
178}
179```
180
181## Retrieve container file
182
183`containers.files.retrieve(file_id, **kwargs) -> FileRetrieveResponse`
184
185**get** `/containers/{container_id}/files/{file_id}`
186
187Retrieve Container File
188
189### Parameters
190
191- `container_id: String`
192
193- `file_id: String`
194
195### Returns
196
197- `class FileRetrieveResponse`
198
199 - `id: String`
200
201 Unique identifier for the file.
202
203 - `bytes: Integer`
204
205 Size of the file in bytes.
206
207 - `container_id: String`
208
209 The container this file belongs to.
210
211 - `created_at: Integer`
212
213 Unix timestamp (in seconds) when the file was created.
214
215 - `object: :"container.file"`
216
217 The type of this object (`container.file`).
218
219 - `:"container.file"`
220
221 - `path: String`
222
223 Path of the file in the container.
224
225 - `source: String`
226
227 Source of the file (e.g., `user`, `assistant`).
228
229### Example
230
231```ruby
232require "openai"
233
234openai = OpenAI::Client.new(api_key: "My API Key")
235
236file = openai.containers.files.retrieve("file_id", container_id: "container_id")
237
238puts(file)
239```
240
241#### Response
242
243```json
244{
245 "id": "id",
246 "bytes": 0,
247 "container_id": "container_id",
248 "created_at": 0,
249 "object": "container.file",
250 "path": "path",
251 "source": "source"
252}
253```
254
255## Delete a container file
256
257`containers.files.delete(file_id, **kwargs) -> void`
258
259**delete** `/containers/{container_id}/files/{file_id}`
260
261Delete Container File
262
263### Parameters
264
265- `container_id: String`
266
267- `file_id: String`
268
269### Example
270
271```ruby
272require "openai"
273
274openai = OpenAI::Client.new(api_key: "My API Key")
275
276result = openai.containers.files.delete("file_id", container_id: "container_id")
277
278puts(result)
279```
280
281## Domain Types
282
283### File List Response
284
285- `class FileListResponse`
286
287 - `id: String`
288
289 Unique identifier for the file.
290
291 - `bytes: Integer`
292
293 Size of the file in bytes.
294
295 - `container_id: String`
296
297 The container this file belongs to.
298
299 - `created_at: Integer`
300
301 Unix timestamp (in seconds) when the file was created.
302
303 - `object: :"container.file"`
304
305 The type of this object (`container.file`).
306
307 - `:"container.file"`
308
309 - `path: String`
310
311 Path of the file in the container.
312
313 - `source: String`
314
315 Source of the file (e.g., `user`, `assistant`).
316
317### File Create Response
318
319- `class FileCreateResponse`
320
321 - `id: String`
322
323 Unique identifier for the file.
324
325 - `bytes: Integer`
326
327 Size of the file in bytes.
328
329 - `container_id: String`
330
331 The container this file belongs to.
332
333 - `created_at: Integer`
334
335 Unix timestamp (in seconds) when the file was created.
336
337 - `object: :"container.file"`
338
339 The type of this object (`container.file`).
340
341 - `:"container.file"`
342
343 - `path: String`
344
345 Path of the file in the container.
346
347 - `source: String`
348
349 Source of the file (e.g., `user`, `assistant`).
350
351### File Retrieve Response
352
353- `class FileRetrieveResponse`
354
355 - `id: String`
356
357 Unique identifier for the file.
358
359 - `bytes: Integer`
360
361 Size of the file in bytes.
362
363 - `container_id: String`
364
365 The container this file belongs to.
366
367 - `created_at: Integer`
368
369 Unix timestamp (in seconds) when the file was created.
370
371 - `object: :"container.file"`
372
373 The type of this object (`container.file`).
374
375 - `:"container.file"`
376
377 - `path: String`
378
379 Path of the file in the container.
380
381 - `source: String`
382
383 Source of the file (e.g., `user`, `assistant`).
384
385# Content
386
387## Retrieve container file content
388
389`containers.files.content.retrieve(file_id, **kwargs) -> StringIO`
390
391**get** `/containers/{container_id}/files/{file_id}/content`
392
393Retrieve Container File Content
394
395### Parameters
396
397- `container_id: String`
398
399- `file_id: String`
400
401### Returns
402
403- `StringIO`
404
405### Example
406
407```ruby
408require "openai"
409
410openai = OpenAI::Client.new(api_key: "My API Key")
411
412content = openai.containers.files.content.retrieve("file_id", container_id: "container_id")
413
414puts(content)
415```