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