ruby/resources/containers/index.md +0 −1171 deleted
File Deleted View Diff
1# Containers
2
3## List containers
4
5`containers.list(**kwargs) -> CursorPage<ContainerListResponse>`
6
7**get** `/containers`
8
9List Containers
10
11### Parameters
12
13- `after: String`
14
15 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.
16
17- `limit: Integer`
18
19 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
20
21- `name: String`
22
23 Filter results by container name.
24
25- `order: :asc | :desc`
26
27 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
28
29 - `:asc`
30
31 - `:desc`
32
33### Returns
34
35- `class ContainerListResponse`
36
37 - `id: String`
38
39 Unique identifier for the container.
40
41 - `created_at: Integer`
42
43 Unix timestamp (in seconds) when the container was created.
44
45 - `name: String`
46
47 Name of the container.
48
49 - `object: String`
50
51 The type of this object.
52
53 - `status: String`
54
55 Status of the container (e.g., active, deleted).
56
57 - `expires_after: ExpiresAfter{ anchor, minutes}`
58
59 The container will expire after this time period.
60 The anchor is the reference point for the expiration.
61 The minutes is the number of minutes after the anchor before the container expires.
62
63 - `anchor: :last_active_at`
64
65 The reference point for the expiration.
66
67 - `:last_active_at`
68
69 - `minutes: Integer`
70
71 The number of minutes after the anchor before the container expires.
72
73 - `last_active_at: Integer`
74
75 Unix timestamp (in seconds) when the container was last active.
76
77 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
78
79 The memory limit configured for the container.
80
81 - `:"1g"`
82
83 - `:"4g"`
84
85 - `:"16g"`
86
87 - `:"64g"`
88
89 - `network_policy: NetworkPolicy{ type, allowed_domains}`
90
91 Network access policy for the container.
92
93 - `type: :allowlist | :disabled`
94
95 The network policy mode.
96
97 - `:allowlist`
98
99 - `:disabled`
100
101 - `allowed_domains: Array[String]`
102
103 Allowed outbound domains when `type` is `allowlist`.
104
105### Example
106
107```ruby
108require "openai"
109
110openai = OpenAI::Client.new(api_key: "My API Key")
111
112page = openai.containers.list
113
114puts(page)
115```
116
117#### Response
118
119```json
120{
121 "data": [
122 {
123 "id": "id",
124 "created_at": 0,
125 "name": "name",
126 "object": "object",
127 "status": "status",
128 "expires_after": {
129 "anchor": "last_active_at",
130 "minutes": 0
131 },
132 "last_active_at": 0,
133 "memory_limit": "1g",
134 "network_policy": {
135 "type": "allowlist",
136 "allowed_domains": [
137 "string"
138 ]
139 }
140 }
141 ],
142 "first_id": "first_id",
143 "has_more": true,
144 "last_id": "last_id",
145 "object": "list"
146}
147```
148
149## Create container
150
151`containers.create(**kwargs) -> ContainerCreateResponse`
152
153**post** `/containers`
154
155Create Container
156
157### Parameters
158
159- `name: String`
160
161 Name of the container to create.
162
163- `expires_after: ExpiresAfter{ anchor, minutes}`
164
165 Container expiration time in seconds relative to the 'anchor' time.
166
167 - `anchor: :last_active_at`
168
169 Time anchor for the expiration time. Currently only 'last_active_at' is supported.
170
171 - `:last_active_at`
172
173 - `minutes: Integer`
174
175- `file_ids: Array[String]`
176
177 IDs of files to copy to the container.
178
179- `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
180
181 Optional memory limit for the container. Defaults to "1g".
182
183 - `:"1g"`
184
185 - `:"4g"`
186
187 - `:"16g"`
188
189 - `:"64g"`
190
191- `network_policy: ContainerNetworkPolicyDisabled | ContainerNetworkPolicyAllowlist`
192
193 Network access policy for the container.
194
195 - `class ContainerNetworkPolicyDisabled`
196
197 - `type: :disabled`
198
199 Disable outbound network access. Always `disabled`.
200
201 - `:disabled`
202
203 - `class ContainerNetworkPolicyAllowlist`
204
205 - `allowed_domains: Array[String]`
206
207 A list of allowed domains when type is `allowlist`.
208
209 - `type: :allowlist`
210
211 Allow outbound network access only to specified domains. Always `allowlist`.
212
213 - `:allowlist`
214
215 - `domain_secrets: Array[ContainerNetworkPolicyDomainSecret]`
216
217 Optional domain-scoped secrets for allowlisted domains.
218
219 - `domain: String`
220
221 The domain associated with the secret.
222
223 - `name: String`
224
225 The name of the secret to inject for the domain.
226
227 - `value: String`
228
229 The secret value to inject for the domain.
230
231- `skills: Array[SkillReference | InlineSkill]`
232
233 An optional list of skills referenced by id or inline data.
234
235 - `class SkillReference`
236
237 - `skill_id: String`
238
239 The ID of the referenced skill.
240
241 - `type: :skill_reference`
242
243 References a skill created with the /v1/skills endpoint.
244
245 - `:skill_reference`
246
247 - `version: String`
248
249 Optional skill version. Use a positive integer or 'latest'. Omit for default.
250
251 - `class InlineSkill`
252
253 - `description: String`
254
255 The description of the skill.
256
257 - `name: String`
258
259 The name of the skill.
260
261 - `source: InlineSkillSource`
262
263 Inline skill payload
264
265 - `data: String`
266
267 Base64-encoded skill zip bundle.
268
269 - `media_type: :"application/zip"`
270
271 The media type of the inline skill payload. Must be `application/zip`.
272
273 - `:"application/zip"`
274
275 - `type: :base64`
276
277 The type of the inline skill source. Must be `base64`.
278
279 - `:base64`
280
281 - `type: :inline`
282
283 Defines an inline skill for this request.
284
285 - `:inline`
286
287### Returns
288
289- `class ContainerCreateResponse`
290
291 - `id: String`
292
293 Unique identifier for the container.
294
295 - `created_at: Integer`
296
297 Unix timestamp (in seconds) when the container was created.
298
299 - `name: String`
300
301 Name of the container.
302
303 - `object: String`
304
305 The type of this object.
306
307 - `status: String`
308
309 Status of the container (e.g., active, deleted).
310
311 - `expires_after: ExpiresAfter{ anchor, minutes}`
312
313 The container will expire after this time period.
314 The anchor is the reference point for the expiration.
315 The minutes is the number of minutes after the anchor before the container expires.
316
317 - `anchor: :last_active_at`
318
319 The reference point for the expiration.
320
321 - `:last_active_at`
322
323 - `minutes: Integer`
324
325 The number of minutes after the anchor before the container expires.
326
327 - `last_active_at: Integer`
328
329 Unix timestamp (in seconds) when the container was last active.
330
331 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
332
333 The memory limit configured for the container.
334
335 - `:"1g"`
336
337 - `:"4g"`
338
339 - `:"16g"`
340
341 - `:"64g"`
342
343 - `network_policy: NetworkPolicy{ type, allowed_domains}`
344
345 Network access policy for the container.
346
347 - `type: :allowlist | :disabled`
348
349 The network policy mode.
350
351 - `:allowlist`
352
353 - `:disabled`
354
355 - `allowed_domains: Array[String]`
356
357 Allowed outbound domains when `type` is `allowlist`.
358
359### Example
360
361```ruby
362require "openai"
363
364openai = OpenAI::Client.new(api_key: "My API Key")
365
366container = openai.containers.create(name: "name")
367
368puts(container)
369```
370
371#### Response
372
373```json
374{
375 "id": "id",
376 "created_at": 0,
377 "name": "name",
378 "object": "object",
379 "status": "status",
380 "expires_after": {
381 "anchor": "last_active_at",
382 "minutes": 0
383 },
384 "last_active_at": 0,
385 "memory_limit": "1g",
386 "network_policy": {
387 "type": "allowlist",
388 "allowed_domains": [
389 "string"
390 ]
391 }
392}
393```
394
395## Retrieve container
396
397`containers.retrieve(container_id) -> ContainerRetrieveResponse`
398
399**get** `/containers/{container_id}`
400
401Retrieve Container
402
403### Parameters
404
405- `container_id: String`
406
407### Returns
408
409- `class ContainerRetrieveResponse`
410
411 - `id: String`
412
413 Unique identifier for the container.
414
415 - `created_at: Integer`
416
417 Unix timestamp (in seconds) when the container was created.
418
419 - `name: String`
420
421 Name of the container.
422
423 - `object: String`
424
425 The type of this object.
426
427 - `status: String`
428
429 Status of the container (e.g., active, deleted).
430
431 - `expires_after: ExpiresAfter{ anchor, minutes}`
432
433 The container will expire after this time period.
434 The anchor is the reference point for the expiration.
435 The minutes is the number of minutes after the anchor before the container expires.
436
437 - `anchor: :last_active_at`
438
439 The reference point for the expiration.
440
441 - `:last_active_at`
442
443 - `minutes: Integer`
444
445 The number of minutes after the anchor before the container expires.
446
447 - `last_active_at: Integer`
448
449 Unix timestamp (in seconds) when the container was last active.
450
451 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
452
453 The memory limit configured for the container.
454
455 - `:"1g"`
456
457 - `:"4g"`
458
459 - `:"16g"`
460
461 - `:"64g"`
462
463 - `network_policy: NetworkPolicy{ type, allowed_domains}`
464
465 Network access policy for the container.
466
467 - `type: :allowlist | :disabled`
468
469 The network policy mode.
470
471 - `:allowlist`
472
473 - `:disabled`
474
475 - `allowed_domains: Array[String]`
476
477 Allowed outbound domains when `type` is `allowlist`.
478
479### Example
480
481```ruby
482require "openai"
483
484openai = OpenAI::Client.new(api_key: "My API Key")
485
486container = openai.containers.retrieve("container_id")
487
488puts(container)
489```
490
491#### Response
492
493```json
494{
495 "id": "id",
496 "created_at": 0,
497 "name": "name",
498 "object": "object",
499 "status": "status",
500 "expires_after": {
501 "anchor": "last_active_at",
502 "minutes": 0
503 },
504 "last_active_at": 0,
505 "memory_limit": "1g",
506 "network_policy": {
507 "type": "allowlist",
508 "allowed_domains": [
509 "string"
510 ]
511 }
512}
513```
514
515## Delete a container
516
517`containers.delete(container_id) -> void`
518
519**delete** `/containers/{container_id}`
520
521Delete Container
522
523### Parameters
524
525- `container_id: String`
526
527### Example
528
529```ruby
530require "openai"
531
532openai = OpenAI::Client.new(api_key: "My API Key")
533
534result = openai.containers.delete("container_id")
535
536puts(result)
537```
538
539## Domain Types
540
541### Container List Response
542
543- `class ContainerListResponse`
544
545 - `id: String`
546
547 Unique identifier for the container.
548
549 - `created_at: Integer`
550
551 Unix timestamp (in seconds) when the container was created.
552
553 - `name: String`
554
555 Name of the container.
556
557 - `object: String`
558
559 The type of this object.
560
561 - `status: String`
562
563 Status of the container (e.g., active, deleted).
564
565 - `expires_after: ExpiresAfter{ anchor, minutes}`
566
567 The container will expire after this time period.
568 The anchor is the reference point for the expiration.
569 The minutes is the number of minutes after the anchor before the container expires.
570
571 - `anchor: :last_active_at`
572
573 The reference point for the expiration.
574
575 - `:last_active_at`
576
577 - `minutes: Integer`
578
579 The number of minutes after the anchor before the container expires.
580
581 - `last_active_at: Integer`
582
583 Unix timestamp (in seconds) when the container was last active.
584
585 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
586
587 The memory limit configured for the container.
588
589 - `:"1g"`
590
591 - `:"4g"`
592
593 - `:"16g"`
594
595 - `:"64g"`
596
597 - `network_policy: NetworkPolicy{ type, allowed_domains}`
598
599 Network access policy for the container.
600
601 - `type: :allowlist | :disabled`
602
603 The network policy mode.
604
605 - `:allowlist`
606
607 - `:disabled`
608
609 - `allowed_domains: Array[String]`
610
611 Allowed outbound domains when `type` is `allowlist`.
612
613### Container Create Response
614
615- `class ContainerCreateResponse`
616
617 - `id: String`
618
619 Unique identifier for the container.
620
621 - `created_at: Integer`
622
623 Unix timestamp (in seconds) when the container was created.
624
625 - `name: String`
626
627 Name of the container.
628
629 - `object: String`
630
631 The type of this object.
632
633 - `status: String`
634
635 Status of the container (e.g., active, deleted).
636
637 - `expires_after: ExpiresAfter{ anchor, minutes}`
638
639 The container will expire after this time period.
640 The anchor is the reference point for the expiration.
641 The minutes is the number of minutes after the anchor before the container expires.
642
643 - `anchor: :last_active_at`
644
645 The reference point for the expiration.
646
647 - `:last_active_at`
648
649 - `minutes: Integer`
650
651 The number of minutes after the anchor before the container expires.
652
653 - `last_active_at: Integer`
654
655 Unix timestamp (in seconds) when the container was last active.
656
657 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
658
659 The memory limit configured for the container.
660
661 - `:"1g"`
662
663 - `:"4g"`
664
665 - `:"16g"`
666
667 - `:"64g"`
668
669 - `network_policy: NetworkPolicy{ type, allowed_domains}`
670
671 Network access policy for the container.
672
673 - `type: :allowlist | :disabled`
674
675 The network policy mode.
676
677 - `:allowlist`
678
679 - `:disabled`
680
681 - `allowed_domains: Array[String]`
682
683 Allowed outbound domains when `type` is `allowlist`.
684
685### Container Retrieve Response
686
687- `class ContainerRetrieveResponse`
688
689 - `id: String`
690
691 Unique identifier for the container.
692
693 - `created_at: Integer`
694
695 Unix timestamp (in seconds) when the container was created.
696
697 - `name: String`
698
699 Name of the container.
700
701 - `object: String`
702
703 The type of this object.
704
705 - `status: String`
706
707 Status of the container (e.g., active, deleted).
708
709 - `expires_after: ExpiresAfter{ anchor, minutes}`
710
711 The container will expire after this time period.
712 The anchor is the reference point for the expiration.
713 The minutes is the number of minutes after the anchor before the container expires.
714
715 - `anchor: :last_active_at`
716
717 The reference point for the expiration.
718
719 - `:last_active_at`
720
721 - `minutes: Integer`
722
723 The number of minutes after the anchor before the container expires.
724
725 - `last_active_at: Integer`
726
727 Unix timestamp (in seconds) when the container was last active.
728
729 - `memory_limit: :"1g" | :"4g" | :"16g" | :"64g"`
730
731 The memory limit configured for the container.
732
733 - `:"1g"`
734
735 - `:"4g"`
736
737 - `:"16g"`
738
739 - `:"64g"`
740
741 - `network_policy: NetworkPolicy{ type, allowed_domains}`
742
743 Network access policy for the container.
744
745 - `type: :allowlist | :disabled`
746
747 The network policy mode.
748
749 - `:allowlist`
750
751 - `:disabled`
752
753 - `allowed_domains: Array[String]`
754
755 Allowed outbound domains when `type` is `allowlist`.
756
757# Files
758
759## List container files
760
761`containers.files.list(container_id, **kwargs) -> CursorPage<FileListResponse>`
762
763**get** `/containers/{container_id}/files`
764
765List Container files
766
767### Parameters
768
769- `container_id: String`
770
771- `after: String`
772
773 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.
774
775- `limit: Integer`
776
777 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
778
779- `order: :asc | :desc`
780
781 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
782
783 - `:asc`
784
785 - `:desc`
786
787### Returns
788
789- `class FileListResponse`
790
791 - `id: String`
792
793 Unique identifier for the file.
794
795 - `bytes: Integer`
796
797 Size of the file in bytes.
798
799 - `container_id: String`
800
801 The container this file belongs to.
802
803 - `created_at: Integer`
804
805 Unix timestamp (in seconds) when the file was created.
806
807 - `object: :"container.file"`
808
809 The type of this object (`container.file`).
810
811 - `:"container.file"`
812
813 - `path: String`
814
815 Path of the file in the container.
816
817 - `source: String`
818
819 Source of the file (e.g., `user`, `assistant`).
820
821### Example
822
823```ruby
824require "openai"
825
826openai = OpenAI::Client.new(api_key: "My API Key")
827
828page = openai.containers.files.list("container_id")
829
830puts(page)
831```
832
833#### Response
834
835```json
836{
837 "data": [
838 {
839 "id": "id",
840 "bytes": 0,
841 "container_id": "container_id",
842 "created_at": 0,
843 "object": "container.file",
844 "path": "path",
845 "source": "source"
846 }
847 ],
848 "first_id": "first_id",
849 "has_more": true,
850 "last_id": "last_id",
851 "object": "list"
852}
853```
854
855## Create container file
856
857`containers.files.create(container_id, **kwargs) -> FileCreateResponse`
858
859**post** `/containers/{container_id}/files`
860
861Create a Container File
862
863You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.
864
865### Parameters
866
867- `container_id: String`
868
869- `file: String`
870
871 The File object (not file name) to be uploaded.
872
873- `file_id: String`
874
875 Name of the file to create.
876
877### Returns
878
879- `class FileCreateResponse`
880
881 - `id: String`
882
883 Unique identifier for the file.
884
885 - `bytes: Integer`
886
887 Size of the file in bytes.
888
889 - `container_id: String`
890
891 The container this file belongs to.
892
893 - `created_at: Integer`
894
895 Unix timestamp (in seconds) when the file was created.
896
897 - `object: :"container.file"`
898
899 The type of this object (`container.file`).
900
901 - `:"container.file"`
902
903 - `path: String`
904
905 Path of the file in the container.
906
907 - `source: String`
908
909 Source of the file (e.g., `user`, `assistant`).
910
911### Example
912
913```ruby
914require "openai"
915
916openai = OpenAI::Client.new(api_key: "My API Key")
917
918file = openai.containers.files.create("container_id")
919
920puts(file)
921```
922
923#### Response
924
925```json
926{
927 "id": "id",
928 "bytes": 0,
929 "container_id": "container_id",
930 "created_at": 0,
931 "object": "container.file",
932 "path": "path",
933 "source": "source"
934}
935```
936
937## Retrieve container file
938
939`containers.files.retrieve(file_id, **kwargs) -> FileRetrieveResponse`
940
941**get** `/containers/{container_id}/files/{file_id}`
942
943Retrieve Container File
944
945### Parameters
946
947- `container_id: String`
948
949- `file_id: String`
950
951### Returns
952
953- `class FileRetrieveResponse`
954
955 - `id: String`
956
957 Unique identifier for the file.
958
959 - `bytes: Integer`
960
961 Size of the file in bytes.
962
963 - `container_id: String`
964
965 The container this file belongs to.
966
967 - `created_at: Integer`
968
969 Unix timestamp (in seconds) when the file was created.
970
971 - `object: :"container.file"`
972
973 The type of this object (`container.file`).
974
975 - `:"container.file"`
976
977 - `path: String`
978
979 Path of the file in the container.
980
981 - `source: String`
982
983 Source of the file (e.g., `user`, `assistant`).
984
985### Example
986
987```ruby
988require "openai"
989
990openai = OpenAI::Client.new(api_key: "My API Key")
991
992file = openai.containers.files.retrieve("file_id", container_id: "container_id")
993
994puts(file)
995```
996
997#### Response
998
999```json
1000{
1001 "id": "id",
1002 "bytes": 0,
1003 "container_id": "container_id",
1004 "created_at": 0,
1005 "object": "container.file",
1006 "path": "path",
1007 "source": "source"
1008}
1009```
1010
1011## Delete a container file
1012
1013`containers.files.delete(file_id, **kwargs) -> void`
1014
1015**delete** `/containers/{container_id}/files/{file_id}`
1016
1017Delete Container File
1018
1019### Parameters
1020
1021- `container_id: String`
1022
1023- `file_id: String`
1024
1025### Example
1026
1027```ruby
1028require "openai"
1029
1030openai = OpenAI::Client.new(api_key: "My API Key")
1031
1032result = openai.containers.files.delete("file_id", container_id: "container_id")
1033
1034puts(result)
1035```
1036
1037## Domain Types
1038
1039### File List Response
1040
1041- `class FileListResponse`
1042
1043 - `id: String`
1044
1045 Unique identifier for the file.
1046
1047 - `bytes: Integer`
1048
1049 Size of the file in bytes.
1050
1051 - `container_id: String`
1052
1053 The container this file belongs to.
1054
1055 - `created_at: Integer`
1056
1057 Unix timestamp (in seconds) when the file was created.
1058
1059 - `object: :"container.file"`
1060
1061 The type of this object (`container.file`).
1062
1063 - `:"container.file"`
1064
1065 - `path: String`
1066
1067 Path of the file in the container.
1068
1069 - `source: String`
1070
1071 Source of the file (e.g., `user`, `assistant`).
1072
1073### File Create Response
1074
1075- `class FileCreateResponse`
1076
1077 - `id: String`
1078
1079 Unique identifier for the file.
1080
1081 - `bytes: Integer`
1082
1083 Size of the file in bytes.
1084
1085 - `container_id: String`
1086
1087 The container this file belongs to.
1088
1089 - `created_at: Integer`
1090
1091 Unix timestamp (in seconds) when the file was created.
1092
1093 - `object: :"container.file"`
1094
1095 The type of this object (`container.file`).
1096
1097 - `:"container.file"`
1098
1099 - `path: String`
1100
1101 Path of the file in the container.
1102
1103 - `source: String`
1104
1105 Source of the file (e.g., `user`, `assistant`).
1106
1107### File Retrieve Response
1108
1109- `class FileRetrieveResponse`
1110
1111 - `id: String`
1112
1113 Unique identifier for the file.
1114
1115 - `bytes: Integer`
1116
1117 Size of the file in bytes.
1118
1119 - `container_id: String`
1120
1121 The container this file belongs to.
1122
1123 - `created_at: Integer`
1124
1125 Unix timestamp (in seconds) when the file was created.
1126
1127 - `object: :"container.file"`
1128
1129 The type of this object (`container.file`).
1130
1131 - `:"container.file"`
1132
1133 - `path: String`
1134
1135 Path of the file in the container.
1136
1137 - `source: String`
1138
1139 Source of the file (e.g., `user`, `assistant`).
1140
1141# Content
1142
1143## Retrieve container file content
1144
1145`containers.files.content.retrieve(file_id, **kwargs) -> StringIO`
1146
1147**get** `/containers/{container_id}/files/{file_id}/content`
1148
1149Retrieve Container File Content
1150
1151### Parameters
1152
1153- `container_id: String`
1154
1155- `file_id: String`
1156
1157### Returns
1158
1159- `StringIO`
1160
1161### Example
1162
1163```ruby
1164require "openai"
1165
1166openai = OpenAI::Client.new(api_key: "My API Key")
1167
1168content = openai.containers.files.content.retrieve("file_id", container_id: "container_id")
1169
1170puts(content)
1171```