go/resources/containers/index.md +0 −998 deleted
File Deleted View Diff
1# Containers
2
3## List containers
4
5`client.Containers.List(ctx, query) (*CursorPage[ContainerListResponse], error)`
6
7**get** `/containers`
8
9List Containers
10
11### Parameters
12
13- `query ContainerListParams`
14
15 - `After param.Field[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 param.Field[int64]`
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 - `Name param.Field[string]`
24
25 Filter results by container name.
26
27 - `Order param.Field[ContainerListParamsOrder]`
28
29 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
30
31 - `const ContainerListParamsOrderAsc ContainerListParamsOrder = "asc"`
32
33 - `const ContainerListParamsOrderDesc ContainerListParamsOrder = "desc"`
34
35### Returns
36
37- `type ContainerListResponse struct{…}`
38
39 - `ID string`
40
41 Unique identifier for the container.
42
43 - `CreatedAt int64`
44
45 Unix timestamp (in seconds) when the container was created.
46
47 - `Name string`
48
49 Name of the container.
50
51 - `Object string`
52
53 The type of this object.
54
55 - `Status string`
56
57 Status of the container (e.g., active, deleted).
58
59 - `ExpiresAfter ContainerListResponseExpiresAfter`
60
61 The container will expire after this time period.
62 The anchor is the reference point for the expiration.
63 The minutes is the number of minutes after the anchor before the container expires.
64
65 - `Anchor string`
66
67 The reference point for the expiration.
68
69 - `const ContainerListResponseExpiresAfterAnchorLastActiveAt ContainerListResponseExpiresAfterAnchor = "last_active_at"`
70
71 - `Minutes int64`
72
73 The number of minutes after the anchor before the container expires.
74
75 - `LastActiveAt int64`
76
77 Unix timestamp (in seconds) when the container was last active.
78
79 - `MemoryLimit ContainerListResponseMemoryLimit`
80
81 The memory limit configured for the container.
82
83 - `const ContainerListResponseMemoryLimit1g ContainerListResponseMemoryLimit = "1g"`
84
85 - `const ContainerListResponseMemoryLimit4g ContainerListResponseMemoryLimit = "4g"`
86
87 - `const ContainerListResponseMemoryLimit16g ContainerListResponseMemoryLimit = "16g"`
88
89 - `const ContainerListResponseMemoryLimit64g ContainerListResponseMemoryLimit = "64g"`
90
91 - `NetworkPolicy ContainerListResponseNetworkPolicy`
92
93 Network access policy for the container.
94
95 - `Type string`
96
97 The network policy mode.
98
99 - `const ContainerListResponseNetworkPolicyTypeAllowlist ContainerListResponseNetworkPolicyType = "allowlist"`
100
101 - `const ContainerListResponseNetworkPolicyTypeDisabled ContainerListResponseNetworkPolicyType = "disabled"`
102
103 - `AllowedDomains []string`
104
105 Allowed outbound domains when `type` is `allowlist`.
106
107### Example
108
109```go
110package main
111
112import (
113 "context"
114 "fmt"
115
116 "github.com/openai/openai-go"
117 "github.com/openai/openai-go/option"
118)
119
120func main() {
121 client := openai.NewClient(
122 option.WithAPIKey("My API Key"),
123 )
124 page, err := client.Containers.List(context.TODO(), openai.ContainerListParams{
125
126 })
127 if err != nil {
128 panic(err.Error())
129 }
130 fmt.Printf("%+v\n", page)
131}
132```
133
134#### Response
135
136```json
137{
138 "data": [
139 {
140 "id": "id",
141 "created_at": 0,
142 "name": "name",
143 "object": "object",
144 "status": "status",
145 "expires_after": {
146 "anchor": "last_active_at",
147 "minutes": 0
148 },
149 "last_active_at": 0,
150 "memory_limit": "1g",
151 "network_policy": {
152 "type": "allowlist",
153 "allowed_domains": [
154 "string"
155 ]
156 }
157 }
158 ],
159 "first_id": "first_id",
160 "has_more": true,
161 "last_id": "last_id",
162 "object": "list"
163}
164```
165
166## Create container
167
168`client.Containers.New(ctx, body) (*ContainerNewResponse, error)`
169
170**post** `/containers`
171
172Create Container
173
174### Parameters
175
176- `body ContainerNewParams`
177
178 - `Name param.Field[string]`
179
180 Name of the container to create.
181
182 - `ExpiresAfter param.Field[ContainerNewParamsExpiresAfter]`
183
184 Container expiration time in seconds relative to the 'anchor' time.
185
186 - `Anchor string`
187
188 Time anchor for the expiration time. Currently only 'last_active_at' is supported.
189
190 - `const ContainerNewParamsExpiresAfterAnchorLastActiveAt ContainerNewParamsExpiresAfterAnchor = "last_active_at"`
191
192 - `Minutes int64`
193
194 - `FileIDs param.Field[[]string]`
195
196 IDs of files to copy to the container.
197
198 - `MemoryLimit param.Field[ContainerNewParamsMemoryLimit]`
199
200 Optional memory limit for the container. Defaults to "1g".
201
202 - `const ContainerNewParamsMemoryLimit1g ContainerNewParamsMemoryLimit = "1g"`
203
204 - `const ContainerNewParamsMemoryLimit4g ContainerNewParamsMemoryLimit = "4g"`
205
206 - `const ContainerNewParamsMemoryLimit16g ContainerNewParamsMemoryLimit = "16g"`
207
208 - `const ContainerNewParamsMemoryLimit64g ContainerNewParamsMemoryLimit = "64g"`
209
210 - `NetworkPolicy param.Field[ContainerNewParamsNetworkPolicyUnion]`
211
212 Network access policy for the container.
213
214 - `type ContainerNetworkPolicyDisabled struct{…}`
215
216 - `Type Disabled`
217
218 Disable outbound network access. Always `disabled`.
219
220 - `const DisabledDisabled Disabled = "disabled"`
221
222 - `type ContainerNetworkPolicyAllowlist struct{…}`
223
224 - `AllowedDomains []string`
225
226 A list of allowed domains when type is `allowlist`.
227
228 - `Type Allowlist`
229
230 Allow outbound network access only to specified domains. Always `allowlist`.
231
232 - `const AllowlistAllowlist Allowlist = "allowlist"`
233
234 - `DomainSecrets []ContainerNetworkPolicyDomainSecret`
235
236 Optional domain-scoped secrets for allowlisted domains.
237
238 - `Domain string`
239
240 The domain associated with the secret.
241
242 - `Name string`
243
244 The name of the secret to inject for the domain.
245
246 - `Value string`
247
248 The secret value to inject for the domain.
249
250 - `Skills param.Field[[]ContainerNewParamsSkillUnion]`
251
252 An optional list of skills referenced by id or inline data.
253
254 - `type SkillReference struct{…}`
255
256 - `SkillID string`
257
258 The ID of the referenced skill.
259
260 - `Type SkillReference`
261
262 References a skill created with the /v1/skills endpoint.
263
264 - `const SkillReferenceSkillReference SkillReference = "skill_reference"`
265
266 - `Version string`
267
268 Optional skill version. Use a positive integer or 'latest'. Omit for default.
269
270 - `type InlineSkill struct{…}`
271
272 - `Description string`
273
274 The description of the skill.
275
276 - `Name string`
277
278 The name of the skill.
279
280 - `Source InlineSkillSource`
281
282 Inline skill payload
283
284 - `Data string`
285
286 Base64-encoded skill zip bundle.
287
288 - `MediaType ApplicationZip`
289
290 The media type of the inline skill payload. Must be `application/zip`.
291
292 - `const ApplicationZipApplicationZip ApplicationZip = "application/zip"`
293
294 - `Type Base64`
295
296 The type of the inline skill source. Must be `base64`.
297
298 - `const Base64Base64 Base64 = "base64"`
299
300 - `Type Inline`
301
302 Defines an inline skill for this request.
303
304 - `const InlineInline Inline = "inline"`
305
306### Returns
307
308- `type ContainerNewResponse struct{…}`
309
310 - `ID string`
311
312 Unique identifier for the container.
313
314 - `CreatedAt int64`
315
316 Unix timestamp (in seconds) when the container was created.
317
318 - `Name string`
319
320 Name of the container.
321
322 - `Object string`
323
324 The type of this object.
325
326 - `Status string`
327
328 Status of the container (e.g., active, deleted).
329
330 - `ExpiresAfter ContainerNewResponseExpiresAfter`
331
332 The container will expire after this time period.
333 The anchor is the reference point for the expiration.
334 The minutes is the number of minutes after the anchor before the container expires.
335
336 - `Anchor string`
337
338 The reference point for the expiration.
339
340 - `const ContainerNewResponseExpiresAfterAnchorLastActiveAt ContainerNewResponseExpiresAfterAnchor = "last_active_at"`
341
342 - `Minutes int64`
343
344 The number of minutes after the anchor before the container expires.
345
346 - `LastActiveAt int64`
347
348 Unix timestamp (in seconds) when the container was last active.
349
350 - `MemoryLimit ContainerNewResponseMemoryLimit`
351
352 The memory limit configured for the container.
353
354 - `const ContainerNewResponseMemoryLimit1g ContainerNewResponseMemoryLimit = "1g"`
355
356 - `const ContainerNewResponseMemoryLimit4g ContainerNewResponseMemoryLimit = "4g"`
357
358 - `const ContainerNewResponseMemoryLimit16g ContainerNewResponseMemoryLimit = "16g"`
359
360 - `const ContainerNewResponseMemoryLimit64g ContainerNewResponseMemoryLimit = "64g"`
361
362 - `NetworkPolicy ContainerNewResponseNetworkPolicy`
363
364 Network access policy for the container.
365
366 - `Type string`
367
368 The network policy mode.
369
370 - `const ContainerNewResponseNetworkPolicyTypeAllowlist ContainerNewResponseNetworkPolicyType = "allowlist"`
371
372 - `const ContainerNewResponseNetworkPolicyTypeDisabled ContainerNewResponseNetworkPolicyType = "disabled"`
373
374 - `AllowedDomains []string`
375
376 Allowed outbound domains when `type` is `allowlist`.
377
378### Example
379
380```go
381package main
382
383import (
384 "context"
385 "fmt"
386
387 "github.com/openai/openai-go"
388 "github.com/openai/openai-go/option"
389)
390
391func main() {
392 client := openai.NewClient(
393 option.WithAPIKey("My API Key"),
394 )
395 container, err := client.Containers.New(context.TODO(), openai.ContainerNewParams{
396 Name: "name",
397 })
398 if err != nil {
399 panic(err.Error())
400 }
401 fmt.Printf("%+v\n", container.ID)
402}
403```
404
405#### Response
406
407```json
408{
409 "id": "id",
410 "created_at": 0,
411 "name": "name",
412 "object": "object",
413 "status": "status",
414 "expires_after": {
415 "anchor": "last_active_at",
416 "minutes": 0
417 },
418 "last_active_at": 0,
419 "memory_limit": "1g",
420 "network_policy": {
421 "type": "allowlist",
422 "allowed_domains": [
423 "string"
424 ]
425 }
426}
427```
428
429## Retrieve container
430
431`client.Containers.Get(ctx, containerID) (*ContainerGetResponse, error)`
432
433**get** `/containers/{container_id}`
434
435Retrieve Container
436
437### Parameters
438
439- `containerID string`
440
441### Returns
442
443- `type ContainerGetResponse struct{…}`
444
445 - `ID string`
446
447 Unique identifier for the container.
448
449 - `CreatedAt int64`
450
451 Unix timestamp (in seconds) when the container was created.
452
453 - `Name string`
454
455 Name of the container.
456
457 - `Object string`
458
459 The type of this object.
460
461 - `Status string`
462
463 Status of the container (e.g., active, deleted).
464
465 - `ExpiresAfter ContainerGetResponseExpiresAfter`
466
467 The container will expire after this time period.
468 The anchor is the reference point for the expiration.
469 The minutes is the number of minutes after the anchor before the container expires.
470
471 - `Anchor string`
472
473 The reference point for the expiration.
474
475 - `const ContainerGetResponseExpiresAfterAnchorLastActiveAt ContainerGetResponseExpiresAfterAnchor = "last_active_at"`
476
477 - `Minutes int64`
478
479 The number of minutes after the anchor before the container expires.
480
481 - `LastActiveAt int64`
482
483 Unix timestamp (in seconds) when the container was last active.
484
485 - `MemoryLimit ContainerGetResponseMemoryLimit`
486
487 The memory limit configured for the container.
488
489 - `const ContainerGetResponseMemoryLimit1g ContainerGetResponseMemoryLimit = "1g"`
490
491 - `const ContainerGetResponseMemoryLimit4g ContainerGetResponseMemoryLimit = "4g"`
492
493 - `const ContainerGetResponseMemoryLimit16g ContainerGetResponseMemoryLimit = "16g"`
494
495 - `const ContainerGetResponseMemoryLimit64g ContainerGetResponseMemoryLimit = "64g"`
496
497 - `NetworkPolicy ContainerGetResponseNetworkPolicy`
498
499 Network access policy for the container.
500
501 - `Type string`
502
503 The network policy mode.
504
505 - `const ContainerGetResponseNetworkPolicyTypeAllowlist ContainerGetResponseNetworkPolicyType = "allowlist"`
506
507 - `const ContainerGetResponseNetworkPolicyTypeDisabled ContainerGetResponseNetworkPolicyType = "disabled"`
508
509 - `AllowedDomains []string`
510
511 Allowed outbound domains when `type` is `allowlist`.
512
513### Example
514
515```go
516package main
517
518import (
519 "context"
520 "fmt"
521
522 "github.com/openai/openai-go"
523 "github.com/openai/openai-go/option"
524)
525
526func main() {
527 client := openai.NewClient(
528 option.WithAPIKey("My API Key"),
529 )
530 container, err := client.Containers.Get(context.TODO(), "container_id")
531 if err != nil {
532 panic(err.Error())
533 }
534 fmt.Printf("%+v\n", container.ID)
535}
536```
537
538#### Response
539
540```json
541{
542 "id": "id",
543 "created_at": 0,
544 "name": "name",
545 "object": "object",
546 "status": "status",
547 "expires_after": {
548 "anchor": "last_active_at",
549 "minutes": 0
550 },
551 "last_active_at": 0,
552 "memory_limit": "1g",
553 "network_policy": {
554 "type": "allowlist",
555 "allowed_domains": [
556 "string"
557 ]
558 }
559}
560```
561
562## Delete a container
563
564`client.Containers.Delete(ctx, containerID) error`
565
566**delete** `/containers/{container_id}`
567
568Delete Container
569
570### Parameters
571
572- `containerID string`
573
574### Example
575
576```go
577package main
578
579import (
580 "context"
581
582 "github.com/openai/openai-go"
583 "github.com/openai/openai-go/option"
584)
585
586func main() {
587 client := openai.NewClient(
588 option.WithAPIKey("My API Key"),
589 )
590 err := client.Containers.Delete(context.TODO(), "container_id")
591 if err != nil {
592 panic(err.Error())
593 }
594}
595```
596
597# Files
598
599## List container files
600
601`client.Containers.Files.List(ctx, containerID, query) (*CursorPage[ContainerFileListResponse], error)`
602
603**get** `/containers/{container_id}/files`
604
605List Container files
606
607### Parameters
608
609- `containerID string`
610
611- `query ContainerFileListParams`
612
613 - `After param.Field[string]`
614
615 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.
616
617 - `Limit param.Field[int64]`
618
619 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
620
621 - `Order param.Field[ContainerFileListParamsOrder]`
622
623 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
624
625 - `const ContainerFileListParamsOrderAsc ContainerFileListParamsOrder = "asc"`
626
627 - `const ContainerFileListParamsOrderDesc ContainerFileListParamsOrder = "desc"`
628
629### Returns
630
631- `type ContainerFileListResponse struct{…}`
632
633 - `ID string`
634
635 Unique identifier for the file.
636
637 - `Bytes int64`
638
639 Size of the file in bytes.
640
641 - `ContainerID string`
642
643 The container this file belongs to.
644
645 - `CreatedAt int64`
646
647 Unix timestamp (in seconds) when the file was created.
648
649 - `Object ContainerFile`
650
651 The type of this object (`container.file`).
652
653 - `const ContainerFileContainerFile ContainerFile = "container.file"`
654
655 - `Path string`
656
657 Path of the file in the container.
658
659 - `Source string`
660
661 Source of the file (e.g., `user`, `assistant`).
662
663### Example
664
665```go
666package main
667
668import (
669 "context"
670 "fmt"
671
672 "github.com/openai/openai-go"
673 "github.com/openai/openai-go/option"
674)
675
676func main() {
677 client := openai.NewClient(
678 option.WithAPIKey("My API Key"),
679 )
680 page, err := client.Containers.Files.List(
681 context.TODO(),
682 "container_id",
683 openai.ContainerFileListParams{
684
685 },
686 )
687 if err != nil {
688 panic(err.Error())
689 }
690 fmt.Printf("%+v\n", page)
691}
692```
693
694#### Response
695
696```json
697{
698 "data": [
699 {
700 "id": "id",
701 "bytes": 0,
702 "container_id": "container_id",
703 "created_at": 0,
704 "object": "container.file",
705 "path": "path",
706 "source": "source"
707 }
708 ],
709 "first_id": "first_id",
710 "has_more": true,
711 "last_id": "last_id",
712 "object": "list"
713}
714```
715
716## Create container file
717
718`client.Containers.Files.New(ctx, containerID, body) (*ContainerFileNewResponse, error)`
719
720**post** `/containers/{container_id}/files`
721
722Create a Container File
723
724You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
725
726### Parameters
727
728- `containerID string`
729
730- `body ContainerFileNewParams`
731
732 - `File param.Field[Reader]`
733
734 The File object (not file name) to be uploaded.
735
736 - `FileID param.Field[string]`
737
738 Name of the file to create.
739
740### Returns
741
742- `type ContainerFileNewResponse struct{…}`
743
744 - `ID string`
745
746 Unique identifier for the file.
747
748 - `Bytes int64`
749
750 Size of the file in bytes.
751
752 - `ContainerID string`
753
754 The container this file belongs to.
755
756 - `CreatedAt int64`
757
758 Unix timestamp (in seconds) when the file was created.
759
760 - `Object ContainerFile`
761
762 The type of this object (`container.file`).
763
764 - `const ContainerFileContainerFile ContainerFile = "container.file"`
765
766 - `Path string`
767
768 Path of the file in the container.
769
770 - `Source string`
771
772 Source of the file (e.g., `user`, `assistant`).
773
774### Example
775
776```go
777package main
778
779import (
780 "context"
781 "fmt"
782
783 "github.com/openai/openai-go"
784 "github.com/openai/openai-go/option"
785)
786
787func main() {
788 client := openai.NewClient(
789 option.WithAPIKey("My API Key"),
790 )
791 file, err := client.Containers.Files.New(
792 context.TODO(),
793 "container_id",
794 openai.ContainerFileNewParams{
795
796 },
797 )
798 if err != nil {
799 panic(err.Error())
800 }
801 fmt.Printf("%+v\n", file.ID)
802}
803```
804
805#### Response
806
807```json
808{
809 "id": "id",
810 "bytes": 0,
811 "container_id": "container_id",
812 "created_at": 0,
813 "object": "container.file",
814 "path": "path",
815 "source": "source"
816}
817```
818
819## Retrieve container file
820
821`client.Containers.Files.Get(ctx, containerID, fileID) (*ContainerFileGetResponse, error)`
822
823**get** `/containers/{container_id}/files/{file_id}`
824
825Retrieve Container File
826
827### Parameters
828
829- `containerID string`
830
831- `fileID string`
832
833### Returns
834
835- `type ContainerFileGetResponse struct{…}`
836
837 - `ID string`
838
839 Unique identifier for the file.
840
841 - `Bytes int64`
842
843 Size of the file in bytes.
844
845 - `ContainerID string`
846
847 The container this file belongs to.
848
849 - `CreatedAt int64`
850
851 Unix timestamp (in seconds) when the file was created.
852
853 - `Object ContainerFile`
854
855 The type of this object (`container.file`).
856
857 - `const ContainerFileContainerFile ContainerFile = "container.file"`
858
859 - `Path string`
860
861 Path of the file in the container.
862
863 - `Source string`
864
865 Source of the file (e.g., `user`, `assistant`).
866
867### Example
868
869```go
870package main
871
872import (
873 "context"
874 "fmt"
875
876 "github.com/openai/openai-go"
877 "github.com/openai/openai-go/option"
878)
879
880func main() {
881 client := openai.NewClient(
882 option.WithAPIKey("My API Key"),
883 )
884 file, err := client.Containers.Files.Get(
885 context.TODO(),
886 "container_id",
887 "file_id",
888 )
889 if err != nil {
890 panic(err.Error())
891 }
892 fmt.Printf("%+v\n", file.ID)
893}
894```
895
896#### Response
897
898```json
899{
900 "id": "id",
901 "bytes": 0,
902 "container_id": "container_id",
903 "created_at": 0,
904 "object": "container.file",
905 "path": "path",
906 "source": "source"
907}
908```
909
910## Delete a container file
911
912`client.Containers.Files.Delete(ctx, containerID, fileID) error`
913
914**delete** `/containers/{container_id}/files/{file_id}`
915
916Delete Container File
917
918### Parameters
919
920- `containerID string`
921
922- `fileID string`
923
924### Example
925
926```go
927package main
928
929import (
930 "context"
931
932 "github.com/openai/openai-go"
933 "github.com/openai/openai-go/option"
934)
935
936func main() {
937 client := openai.NewClient(
938 option.WithAPIKey("My API Key"),
939 )
940 err := client.Containers.Files.Delete(
941 context.TODO(),
942 "container_id",
943 "file_id",
944 )
945 if err != nil {
946 panic(err.Error())
947 }
948}
949```
950
951# Content
952
953## Retrieve container file content
954
955`client.Containers.Files.Content.Get(ctx, containerID, fileID) (*Response, error)`
956
957**get** `/containers/{container_id}/files/{file_id}/content`
958
959Retrieve Container File Content
960
961### Parameters
962
963- `containerID string`
964
965- `fileID string`
966
967### Returns
968
969- `type ContainerFileContentGetResponse interface{…}`
970
971### Example
972
973```go
974package main
975
976import (
977 "context"
978 "fmt"
979
980 "github.com/openai/openai-go"
981 "github.com/openai/openai-go/option"
982)
983
984func main() {
985 client := openai.NewClient(
986 option.WithAPIKey("My API Key"),
987 )
988 content, err := client.Containers.Files.Content.Get(
989 context.TODO(),
990 "container_id",
991 "file_id",
992 )
993 if err != nil {
994 panic(err.Error())
995 }
996 fmt.Printf("%+v\n", content)
997}
998```