python/resources/vector_stores/index.md +0 −3367 deleted
File Deleted View Diff
1# Vector Stores
2
3## List vector stores
4
5`vector_stores.list(VectorStoreListParams**kwargs) -> SyncCursorPage[VectorStore]`
6
7**get** `/vector_stores`
8
9Returns a list of vector stores.
10
11### Parameters
12
13- `after: Optional[str]`
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- `before: Optional[str]`
18
19 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
20
21- `limit: Optional[int]`
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: Optional[Literal["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 VectorStore: …`
36
37 A vector store is a collection of processed files can be used by the `file_search` tool.
38
39 - `id: str`
40
41 The identifier, which can be referenced in API endpoints.
42
43 - `created_at: int`
44
45 The Unix timestamp (in seconds) for when the vector store was created.
46
47 - `file_counts: FileCounts`
48
49 - `cancelled: int`
50
51 The number of files that were cancelled.
52
53 - `completed: int`
54
55 The number of files that have been successfully processed.
56
57 - `failed: int`
58
59 The number of files that have failed to process.
60
61 - `in_progress: int`
62
63 The number of files that are currently being processed.
64
65 - `total: int`
66
67 The total number of files.
68
69 - `last_active_at: Optional[int]`
70
71 The Unix timestamp (in seconds) for when the vector store was last active.
72
73 - `metadata: Optional[Metadata]`
74
75 Set of 16 key-value pairs that can be attached to an object. This can be
76 useful for storing additional information about the object in a structured
77 format, and querying for objects via API or the dashboard.
78
79 Keys are strings with a maximum length of 64 characters. Values are strings
80 with a maximum length of 512 characters.
81
82 - `name: str`
83
84 The name of the vector store.
85
86 - `object: Literal["vector_store"]`
87
88 The object type, which is always `vector_store`.
89
90 - `"vector_store"`
91
92 - `status: Literal["expired", "in_progress", "completed"]`
93
94 The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
95
96 - `"expired"`
97
98 - `"in_progress"`
99
100 - `"completed"`
101
102 - `usage_bytes: int`
103
104 The total number of bytes used by the files in the vector store.
105
106 - `expires_after: Optional[ExpiresAfter]`
107
108 The expiration policy for a vector store.
109
110 - `anchor: Literal["last_active_at"]`
111
112 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
113
114 - `"last_active_at"`
115
116 - `days: int`
117
118 The number of days after the anchor time that the vector store will expire.
119
120 - `expires_at: Optional[int]`
121
122 The Unix timestamp (in seconds) for when the vector store will expire.
123
124### Example
125
126```python
127import os
128from openai import OpenAI
129
130client = OpenAI(
131 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
132)
133page = client.vector_stores.list()
134page = page.data[0]
135print(page.id)
136```
137
138#### Response
139
140```json
141{
142 "data": [
143 {
144 "id": "id",
145 "created_at": 0,
146 "file_counts": {
147 "cancelled": 0,
148 "completed": 0,
149 "failed": 0,
150 "in_progress": 0,
151 "total": 0
152 },
153 "last_active_at": 0,
154 "metadata": {
155 "foo": "string"
156 },
157 "name": "name",
158 "object": "vector_store",
159 "status": "expired",
160 "usage_bytes": 0,
161 "expires_after": {
162 "anchor": "last_active_at",
163 "days": 1
164 },
165 "expires_at": 0
166 }
167 ],
168 "first_id": "vs_abc123",
169 "has_more": false,
170 "last_id": "vs_abc456",
171 "object": "list"
172}
173```
174
175### Example
176
177```python
178from openai import OpenAI
179client = OpenAI()
180
181vector_stores = client.vector_stores.list()
182print(vector_stores)
183```
184
185#### Response
186
187```json
188{
189 "object": "list",
190 "data": [
191 {
192 "id": "vs_abc123",
193 "object": "vector_store",
194 "created_at": 1699061776,
195 "name": "Support FAQ",
196 "description": "Contains commonly asked questions and answers, organized by topic.",
197 "bytes": 139920,
198 "file_counts": {
199 "in_progress": 0,
200 "completed": 3,
201 "failed": 0,
202 "cancelled": 0,
203 "total": 3
204 }
205 },
206 {
207 "id": "vs_abc456",
208 "object": "vector_store",
209 "created_at": 1699061776,
210 "name": "Support FAQ v2",
211 "description": null,
212 "bytes": 139920,
213 "file_counts": {
214 "in_progress": 0,
215 "completed": 3,
216 "failed": 0,
217 "cancelled": 0,
218 "total": 3
219 }
220 }
221 ],
222 "first_id": "vs_abc123",
223 "last_id": "vs_abc456",
224 "has_more": false
225}
226```
227
228## Create vector store
229
230`vector_stores.create(VectorStoreCreateParams**kwargs) -> VectorStore`
231
232**post** `/vector_stores`
233
234Create a vector store.
235
236### Parameters
237
238- `chunking_strategy: Optional[FileChunkingStrategyParam]`
239
240 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
241
242 - `class AutoFileChunkingStrategyParam: …`
243
244 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
245
246 - `type: Literal["auto"]`
247
248 Always `auto`.
249
250 - `"auto"`
251
252 - `class StaticFileChunkingStrategyObjectParam: …`
253
254 Customize your own chunking strategy by setting chunk size and chunk overlap.
255
256 - `static: StaticFileChunkingStrategy`
257
258 - `chunk_overlap_tokens: int`
259
260 The number of tokens that overlap between chunks. The default value is `400`.
261
262 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
263
264 - `max_chunk_size_tokens: int`
265
266 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
267
268 - `type: Literal["static"]`
269
270 Always `static`.
271
272 - `"static"`
273
274- `description: Optional[str]`
275
276 A description for the vector store. Can be used to describe the vector store's purpose.
277
278- `expires_after: Optional[ExpiresAfter]`
279
280 The expiration policy for a vector store.
281
282 - `anchor: Literal["last_active_at"]`
283
284 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
285
286 - `"last_active_at"`
287
288 - `days: int`
289
290 The number of days after the anchor time that the vector store will expire.
291
292- `file_ids: Optional[Sequence[str]]`
293
294 A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files.
295
296- `metadata: Optional[Metadata]`
297
298 Set of 16 key-value pairs that can be attached to an object. This can be
299 useful for storing additional information about the object in a structured
300 format, and querying for objects via API or the dashboard.
301
302 Keys are strings with a maximum length of 64 characters. Values are strings
303 with a maximum length of 512 characters.
304
305- `name: Optional[str]`
306
307 The name of the vector store.
308
309### Returns
310
311- `class VectorStore: …`
312
313 A vector store is a collection of processed files can be used by the `file_search` tool.
314
315 - `id: str`
316
317 The identifier, which can be referenced in API endpoints.
318
319 - `created_at: int`
320
321 The Unix timestamp (in seconds) for when the vector store was created.
322
323 - `file_counts: FileCounts`
324
325 - `cancelled: int`
326
327 The number of files that were cancelled.
328
329 - `completed: int`
330
331 The number of files that have been successfully processed.
332
333 - `failed: int`
334
335 The number of files that have failed to process.
336
337 - `in_progress: int`
338
339 The number of files that are currently being processed.
340
341 - `total: int`
342
343 The total number of files.
344
345 - `last_active_at: Optional[int]`
346
347 The Unix timestamp (in seconds) for when the vector store was last active.
348
349 - `metadata: Optional[Metadata]`
350
351 Set of 16 key-value pairs that can be attached to an object. This can be
352 useful for storing additional information about the object in a structured
353 format, and querying for objects via API or the dashboard.
354
355 Keys are strings with a maximum length of 64 characters. Values are strings
356 with a maximum length of 512 characters.
357
358 - `name: str`
359
360 The name of the vector store.
361
362 - `object: Literal["vector_store"]`
363
364 The object type, which is always `vector_store`.
365
366 - `"vector_store"`
367
368 - `status: Literal["expired", "in_progress", "completed"]`
369
370 The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
371
372 - `"expired"`
373
374 - `"in_progress"`
375
376 - `"completed"`
377
378 - `usage_bytes: int`
379
380 The total number of bytes used by the files in the vector store.
381
382 - `expires_after: Optional[ExpiresAfter]`
383
384 The expiration policy for a vector store.
385
386 - `anchor: Literal["last_active_at"]`
387
388 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
389
390 - `"last_active_at"`
391
392 - `days: int`
393
394 The number of days after the anchor time that the vector store will expire.
395
396 - `expires_at: Optional[int]`
397
398 The Unix timestamp (in seconds) for when the vector store will expire.
399
400### Example
401
402```python
403import os
404from openai import OpenAI
405
406client = OpenAI(
407 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
408)
409vector_store = client.vector_stores.create()
410print(vector_store.id)
411```
412
413#### Response
414
415```json
416{
417 "id": "id",
418 "created_at": 0,
419 "file_counts": {
420 "cancelled": 0,
421 "completed": 0,
422 "failed": 0,
423 "in_progress": 0,
424 "total": 0
425 },
426 "last_active_at": 0,
427 "metadata": {
428 "foo": "string"
429 },
430 "name": "name",
431 "object": "vector_store",
432 "status": "expired",
433 "usage_bytes": 0,
434 "expires_after": {
435 "anchor": "last_active_at",
436 "days": 1
437 },
438 "expires_at": 0
439}
440```
441
442### Example
443
444```python
445from openai import OpenAI
446client = OpenAI()
447
448vector_store = client.vector_stores.create(
449 name="Support FAQ"
450)
451print(vector_store)
452```
453
454#### Response
455
456```json
457{
458 "id": "vs_abc123",
459 "object": "vector_store",
460 "created_at": 1699061776,
461 "name": "Support FAQ",
462 "description": "Contains commonly asked questions and answers, organized by topic.",
463 "bytes": 139920,
464 "file_counts": {
465 "in_progress": 0,
466 "completed": 3,
467 "failed": 0,
468 "cancelled": 0,
469 "total": 3
470 }
471}
472```
473
474## Retrieve vector store
475
476`vector_stores.retrieve(strvector_store_id) -> VectorStore`
477
478**get** `/vector_stores/{vector_store_id}`
479
480Retrieves a vector store.
481
482### Parameters
483
484- `vector_store_id: str`
485
486### Returns
487
488- `class VectorStore: …`
489
490 A vector store is a collection of processed files can be used by the `file_search` tool.
491
492 - `id: str`
493
494 The identifier, which can be referenced in API endpoints.
495
496 - `created_at: int`
497
498 The Unix timestamp (in seconds) for when the vector store was created.
499
500 - `file_counts: FileCounts`
501
502 - `cancelled: int`
503
504 The number of files that were cancelled.
505
506 - `completed: int`
507
508 The number of files that have been successfully processed.
509
510 - `failed: int`
511
512 The number of files that have failed to process.
513
514 - `in_progress: int`
515
516 The number of files that are currently being processed.
517
518 - `total: int`
519
520 The total number of files.
521
522 - `last_active_at: Optional[int]`
523
524 The Unix timestamp (in seconds) for when the vector store was last active.
525
526 - `metadata: Optional[Metadata]`
527
528 Set of 16 key-value pairs that can be attached to an object. This can be
529 useful for storing additional information about the object in a structured
530 format, and querying for objects via API or the dashboard.
531
532 Keys are strings with a maximum length of 64 characters. Values are strings
533 with a maximum length of 512 characters.
534
535 - `name: str`
536
537 The name of the vector store.
538
539 - `object: Literal["vector_store"]`
540
541 The object type, which is always `vector_store`.
542
543 - `"vector_store"`
544
545 - `status: Literal["expired", "in_progress", "completed"]`
546
547 The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
548
549 - `"expired"`
550
551 - `"in_progress"`
552
553 - `"completed"`
554
555 - `usage_bytes: int`
556
557 The total number of bytes used by the files in the vector store.
558
559 - `expires_after: Optional[ExpiresAfter]`
560
561 The expiration policy for a vector store.
562
563 - `anchor: Literal["last_active_at"]`
564
565 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
566
567 - `"last_active_at"`
568
569 - `days: int`
570
571 The number of days after the anchor time that the vector store will expire.
572
573 - `expires_at: Optional[int]`
574
575 The Unix timestamp (in seconds) for when the vector store will expire.
576
577### Example
578
579```python
580import os
581from openai import OpenAI
582
583client = OpenAI(
584 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
585)
586vector_store = client.vector_stores.retrieve(
587 "vector_store_id",
588)
589print(vector_store.id)
590```
591
592#### Response
593
594```json
595{
596 "id": "id",
597 "created_at": 0,
598 "file_counts": {
599 "cancelled": 0,
600 "completed": 0,
601 "failed": 0,
602 "in_progress": 0,
603 "total": 0
604 },
605 "last_active_at": 0,
606 "metadata": {
607 "foo": "string"
608 },
609 "name": "name",
610 "object": "vector_store",
611 "status": "expired",
612 "usage_bytes": 0,
613 "expires_after": {
614 "anchor": "last_active_at",
615 "days": 1
616 },
617 "expires_at": 0
618}
619```
620
621### Example
622
623```python
624from openai import OpenAI
625client = OpenAI()
626
627vector_store = client.vector_stores.retrieve(
628 vector_store_id="vs_abc123"
629)
630print(vector_store)
631```
632
633#### Response
634
635```json
636{
637 "id": "vs_abc123",
638 "object": "vector_store",
639 "created_at": 1699061776
640}
641```
642
643## Modify vector store
644
645`vector_stores.update(strvector_store_id, VectorStoreUpdateParams**kwargs) -> VectorStore`
646
647**post** `/vector_stores/{vector_store_id}`
648
649Modifies a vector store.
650
651### Parameters
652
653- `vector_store_id: str`
654
655- `expires_after: Optional[ExpiresAfter]`
656
657 The expiration policy for a vector store.
658
659 - `anchor: Literal["last_active_at"]`
660
661 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
662
663 - `"last_active_at"`
664
665 - `days: int`
666
667 The number of days after the anchor time that the vector store will expire.
668
669- `metadata: Optional[Metadata]`
670
671 Set of 16 key-value pairs that can be attached to an object. This can be
672 useful for storing additional information about the object in a structured
673 format, and querying for objects via API or the dashboard.
674
675 Keys are strings with a maximum length of 64 characters. Values are strings
676 with a maximum length of 512 characters.
677
678- `name: Optional[str]`
679
680 The name of the vector store.
681
682### Returns
683
684- `class VectorStore: …`
685
686 A vector store is a collection of processed files can be used by the `file_search` tool.
687
688 - `id: str`
689
690 The identifier, which can be referenced in API endpoints.
691
692 - `created_at: int`
693
694 The Unix timestamp (in seconds) for when the vector store was created.
695
696 - `file_counts: FileCounts`
697
698 - `cancelled: int`
699
700 The number of files that were cancelled.
701
702 - `completed: int`
703
704 The number of files that have been successfully processed.
705
706 - `failed: int`
707
708 The number of files that have failed to process.
709
710 - `in_progress: int`
711
712 The number of files that are currently being processed.
713
714 - `total: int`
715
716 The total number of files.
717
718 - `last_active_at: Optional[int]`
719
720 The Unix timestamp (in seconds) for when the vector store was last active.
721
722 - `metadata: Optional[Metadata]`
723
724 Set of 16 key-value pairs that can be attached to an object. This can be
725 useful for storing additional information about the object in a structured
726 format, and querying for objects via API or the dashboard.
727
728 Keys are strings with a maximum length of 64 characters. Values are strings
729 with a maximum length of 512 characters.
730
731 - `name: str`
732
733 The name of the vector store.
734
735 - `object: Literal["vector_store"]`
736
737 The object type, which is always `vector_store`.
738
739 - `"vector_store"`
740
741 - `status: Literal["expired", "in_progress", "completed"]`
742
743 The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
744
745 - `"expired"`
746
747 - `"in_progress"`
748
749 - `"completed"`
750
751 - `usage_bytes: int`
752
753 The total number of bytes used by the files in the vector store.
754
755 - `expires_after: Optional[ExpiresAfter]`
756
757 The expiration policy for a vector store.
758
759 - `anchor: Literal["last_active_at"]`
760
761 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
762
763 - `"last_active_at"`
764
765 - `days: int`
766
767 The number of days after the anchor time that the vector store will expire.
768
769 - `expires_at: Optional[int]`
770
771 The Unix timestamp (in seconds) for when the vector store will expire.
772
773### Example
774
775```python
776import os
777from openai import OpenAI
778
779client = OpenAI(
780 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
781)
782vector_store = client.vector_stores.update(
783 vector_store_id="vector_store_id",
784)
785print(vector_store.id)
786```
787
788#### Response
789
790```json
791{
792 "id": "id",
793 "created_at": 0,
794 "file_counts": {
795 "cancelled": 0,
796 "completed": 0,
797 "failed": 0,
798 "in_progress": 0,
799 "total": 0
800 },
801 "last_active_at": 0,
802 "metadata": {
803 "foo": "string"
804 },
805 "name": "name",
806 "object": "vector_store",
807 "status": "expired",
808 "usage_bytes": 0,
809 "expires_after": {
810 "anchor": "last_active_at",
811 "days": 1
812 },
813 "expires_at": 0
814}
815```
816
817### Example
818
819```python
820from openai import OpenAI
821client = OpenAI()
822
823vector_store = client.vector_stores.update(
824 vector_store_id="vs_abc123",
825 name="Support FAQ"
826)
827print(vector_store)
828```
829
830#### Response
831
832```json
833{
834 "id": "vs_abc123",
835 "object": "vector_store",
836 "created_at": 1699061776,
837 "name": "Support FAQ",
838 "description": "Contains commonly asked questions and answers, organized by topic.",
839 "bytes": 139920,
840 "file_counts": {
841 "in_progress": 0,
842 "completed": 3,
843 "failed": 0,
844 "cancelled": 0,
845 "total": 3
846 }
847}
848```
849
850## Delete vector store
851
852`vector_stores.delete(strvector_store_id) -> VectorStoreDeleted`
853
854**delete** `/vector_stores/{vector_store_id}`
855
856Delete a vector store.
857
858### Parameters
859
860- `vector_store_id: str`
861
862### Returns
863
864- `class VectorStoreDeleted: …`
865
866 - `id: str`
867
868 - `deleted: bool`
869
870 - `object: Literal["vector_store.deleted"]`
871
872 - `"vector_store.deleted"`
873
874### Example
875
876```python
877import os
878from openai import OpenAI
879
880client = OpenAI(
881 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
882)
883vector_store_deleted = client.vector_stores.delete(
884 "vector_store_id",
885)
886print(vector_store_deleted.id)
887```
888
889#### Response
890
891```json
892{
893 "id": "id",
894 "deleted": true,
895 "object": "vector_store.deleted"
896}
897```
898
899### Example
900
901```python
902from openai import OpenAI
903client = OpenAI()
904
905deleted_vector_store = client.vector_stores.delete(
906 vector_store_id="vs_abc123"
907)
908print(deleted_vector_store)
909```
910
911#### Response
912
913```json
914{
915 id: "vs_abc123",
916 object: "vector_store.deleted",
917 deleted: true
918}
919```
920
921## Search vector store
922
923`vector_stores.search(strvector_store_id, VectorStoreSearchParams**kwargs) -> SyncPage[VectorStoreSearchResponse]`
924
925**post** `/vector_stores/{vector_store_id}/search`
926
927Search a vector store for relevant chunks based on a query and file attributes filter.
928
929### Parameters
930
931- `vector_store_id: str`
932
933- `query: Union[str, Sequence[str]]`
934
935 A query string for a search
936
937 - `str`
938
939 - `Sequence[str]`
940
941- `filters: Optional[Filters]`
942
943 A filter to apply based on file attributes.
944
945 - `class ComparisonFilter: …`
946
947 A filter used to compare a specified attribute key to a given value using a defined comparison operation.
948
949 - `key: str`
950
951 The key to compare against the value.
952
953 - `type: Literal["eq", "ne", "gt", 5 more]`
954
955 Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.
956
957 - `eq`: equals
958 - `ne`: not equal
959 - `gt`: greater than
960 - `gte`: greater than or equal
961 - `lt`: less than
962 - `lte`: less than or equal
963 - `in`: in
964 - `nin`: not in
965
966 - `"eq"`
967
968 - `"ne"`
969
970 - `"gt"`
971
972 - `"gte"`
973
974 - `"lt"`
975
976 - `"lte"`
977
978 - `"in"`
979
980 - `"nin"`
981
982 - `value: Union[str, float, bool, List[Union[str, float]]]`
983
984 The value to compare against the attribute key; supports string, number, or boolean types.
985
986 - `str`
987
988 - `float`
989
990 - `bool`
991
992 - `List[Union[str, float]]`
993
994 - `str`
995
996 - `float`
997
998 - `class CompoundFilter: …`
999
1000 Combine multiple filters using `and` or `or`.
1001
1002 - `filters: List[Filter]`
1003
1004 Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`.
1005
1006 - `class ComparisonFilter: …`
1007
1008 A filter used to compare a specified attribute key to a given value using a defined comparison operation.
1009
1010 - `object`
1011
1012 - `type: Literal["and", "or"]`
1013
1014 Type of operation: `and` or `or`.
1015
1016 - `"and"`
1017
1018 - `"or"`
1019
1020- `max_num_results: Optional[int]`
1021
1022 The maximum number of results to return. This number should be between 1 and 50 inclusive.
1023
1024- `ranking_options: Optional[RankingOptions]`
1025
1026 Ranking options for search.
1027
1028 - `ranker: Optional[Literal["none", "auto", "default-2024-11-15"]]`
1029
1030 Enable re-ranking; set to `none` to disable, which can help reduce latency.
1031
1032 - `"none"`
1033
1034 - `"auto"`
1035
1036 - `"default-2024-11-15"`
1037
1038 - `score_threshold: Optional[float]`
1039
1040- `rewrite_query: Optional[bool]`
1041
1042 Whether to rewrite the natural language query for vector search.
1043
1044### Returns
1045
1046- `class VectorStoreSearchResponse: …`
1047
1048 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1049
1050 Set of 16 key-value pairs that can be attached to an object. This can be
1051 useful for storing additional information about the object in a structured
1052 format, and querying for objects via API or the dashboard. Keys are strings
1053 with a maximum length of 64 characters. Values are strings with a maximum
1054 length of 512 characters, booleans, or numbers.
1055
1056 - `str`
1057
1058 - `float`
1059
1060 - `bool`
1061
1062 - `content: List[Content]`
1063
1064 Content chunks from the file.
1065
1066 - `text: str`
1067
1068 The text content returned from search.
1069
1070 - `type: Literal["text"]`
1071
1072 The type of content.
1073
1074 - `"text"`
1075
1076 - `file_id: str`
1077
1078 The ID of the vector store file.
1079
1080 - `filename: str`
1081
1082 The name of the vector store file.
1083
1084 - `score: float`
1085
1086 The similarity score for the result.
1087
1088### Example
1089
1090```python
1091import os
1092from openai import OpenAI
1093
1094client = OpenAI(
1095 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
1096)
1097page = client.vector_stores.search(
1098 vector_store_id="vs_abc123",
1099 query="string",
1100)
1101page = page.data[0]
1102print(page.file_id)
1103```
1104
1105#### Response
1106
1107```json
1108{
1109 "data": [
1110 {
1111 "attributes": {
1112 "foo": "string"
1113 },
1114 "content": [
1115 {
1116 "text": "text",
1117 "type": "text"
1118 }
1119 ],
1120 "file_id": "file_id",
1121 "filename": "filename",
1122 "score": 0
1123 }
1124 ],
1125 "has_more": true,
1126 "next_page": "next_page",
1127 "object": "vector_store.search_results.page",
1128 "search_query": [
1129 "string"
1130 ]
1131}
1132```
1133
1134## Domain Types
1135
1136### Auto File Chunking Strategy Param
1137
1138- `class AutoFileChunkingStrategyParam: …`
1139
1140 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
1141
1142 - `type: Literal["auto"]`
1143
1144 Always `auto`.
1145
1146 - `"auto"`
1147
1148### File Chunking Strategy
1149
1150- `FileChunkingStrategy`
1151
1152 The strategy used to chunk the file.
1153
1154 - `class StaticFileChunkingStrategyObject: …`
1155
1156 - `static: StaticFileChunkingStrategy`
1157
1158 - `chunk_overlap_tokens: int`
1159
1160 The number of tokens that overlap between chunks. The default value is `400`.
1161
1162 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1163
1164 - `max_chunk_size_tokens: int`
1165
1166 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1167
1168 - `type: Literal["static"]`
1169
1170 Always `static`.
1171
1172 - `"static"`
1173
1174 - `class OtherFileChunkingStrategyObject: …`
1175
1176 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
1177
1178 - `type: Literal["other"]`
1179
1180 Always `other`.
1181
1182 - `"other"`
1183
1184### File Chunking Strategy Param
1185
1186- `FileChunkingStrategyParam`
1187
1188 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
1189
1190 - `class AutoFileChunkingStrategyParam: …`
1191
1192 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
1193
1194 - `type: Literal["auto"]`
1195
1196 Always `auto`.
1197
1198 - `"auto"`
1199
1200 - `class StaticFileChunkingStrategyObjectParam: …`
1201
1202 Customize your own chunking strategy by setting chunk size and chunk overlap.
1203
1204 - `static: StaticFileChunkingStrategy`
1205
1206 - `chunk_overlap_tokens: int`
1207
1208 The number of tokens that overlap between chunks. The default value is `400`.
1209
1210 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1211
1212 - `max_chunk_size_tokens: int`
1213
1214 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1215
1216 - `type: Literal["static"]`
1217
1218 Always `static`.
1219
1220 - `"static"`
1221
1222### Other File Chunking Strategy Object
1223
1224- `class OtherFileChunkingStrategyObject: …`
1225
1226 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
1227
1228 - `type: Literal["other"]`
1229
1230 Always `other`.
1231
1232 - `"other"`
1233
1234### Static File Chunking Strategy
1235
1236- `class StaticFileChunkingStrategy: …`
1237
1238 - `chunk_overlap_tokens: int`
1239
1240 The number of tokens that overlap between chunks. The default value is `400`.
1241
1242 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1243
1244 - `max_chunk_size_tokens: int`
1245
1246 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1247
1248### Static File Chunking Strategy Object
1249
1250- `class StaticFileChunkingStrategyObject: …`
1251
1252 - `static: StaticFileChunkingStrategy`
1253
1254 - `chunk_overlap_tokens: int`
1255
1256 The number of tokens that overlap between chunks. The default value is `400`.
1257
1258 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1259
1260 - `max_chunk_size_tokens: int`
1261
1262 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1263
1264 - `type: Literal["static"]`
1265
1266 Always `static`.
1267
1268 - `"static"`
1269
1270### Static File Chunking Strategy Object Param
1271
1272- `class StaticFileChunkingStrategyObjectParam: …`
1273
1274 Customize your own chunking strategy by setting chunk size and chunk overlap.
1275
1276 - `static: StaticFileChunkingStrategy`
1277
1278 - `chunk_overlap_tokens: int`
1279
1280 The number of tokens that overlap between chunks. The default value is `400`.
1281
1282 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1283
1284 - `max_chunk_size_tokens: int`
1285
1286 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1287
1288 - `type: Literal["static"]`
1289
1290 Always `static`.
1291
1292 - `"static"`
1293
1294### Vector Store
1295
1296- `class VectorStore: …`
1297
1298 A vector store is a collection of processed files can be used by the `file_search` tool.
1299
1300 - `id: str`
1301
1302 The identifier, which can be referenced in API endpoints.
1303
1304 - `created_at: int`
1305
1306 The Unix timestamp (in seconds) for when the vector store was created.
1307
1308 - `file_counts: FileCounts`
1309
1310 - `cancelled: int`
1311
1312 The number of files that were cancelled.
1313
1314 - `completed: int`
1315
1316 The number of files that have been successfully processed.
1317
1318 - `failed: int`
1319
1320 The number of files that have failed to process.
1321
1322 - `in_progress: int`
1323
1324 The number of files that are currently being processed.
1325
1326 - `total: int`
1327
1328 The total number of files.
1329
1330 - `last_active_at: Optional[int]`
1331
1332 The Unix timestamp (in seconds) for when the vector store was last active.
1333
1334 - `metadata: Optional[Metadata]`
1335
1336 Set of 16 key-value pairs that can be attached to an object. This can be
1337 useful for storing additional information about the object in a structured
1338 format, and querying for objects via API or the dashboard.
1339
1340 Keys are strings with a maximum length of 64 characters. Values are strings
1341 with a maximum length of 512 characters.
1342
1343 - `name: str`
1344
1345 The name of the vector store.
1346
1347 - `object: Literal["vector_store"]`
1348
1349 The object type, which is always `vector_store`.
1350
1351 - `"vector_store"`
1352
1353 - `status: Literal["expired", "in_progress", "completed"]`
1354
1355 The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use.
1356
1357 - `"expired"`
1358
1359 - `"in_progress"`
1360
1361 - `"completed"`
1362
1363 - `usage_bytes: int`
1364
1365 The total number of bytes used by the files in the vector store.
1366
1367 - `expires_after: Optional[ExpiresAfter]`
1368
1369 The expiration policy for a vector store.
1370
1371 - `anchor: Literal["last_active_at"]`
1372
1373 Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`.
1374
1375 - `"last_active_at"`
1376
1377 - `days: int`
1378
1379 The number of days after the anchor time that the vector store will expire.
1380
1381 - `expires_at: Optional[int]`
1382
1383 The Unix timestamp (in seconds) for when the vector store will expire.
1384
1385### Vector Store Deleted
1386
1387- `class VectorStoreDeleted: …`
1388
1389 - `id: str`
1390
1391 - `deleted: bool`
1392
1393 - `object: Literal["vector_store.deleted"]`
1394
1395 - `"vector_store.deleted"`
1396
1397### Vector Store Search Response
1398
1399- `class VectorStoreSearchResponse: …`
1400
1401 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1402
1403 Set of 16 key-value pairs that can be attached to an object. This can be
1404 useful for storing additional information about the object in a structured
1405 format, and querying for objects via API or the dashboard. Keys are strings
1406 with a maximum length of 64 characters. Values are strings with a maximum
1407 length of 512 characters, booleans, or numbers.
1408
1409 - `str`
1410
1411 - `float`
1412
1413 - `bool`
1414
1415 - `content: List[Content]`
1416
1417 Content chunks from the file.
1418
1419 - `text: str`
1420
1421 The text content returned from search.
1422
1423 - `type: Literal["text"]`
1424
1425 The type of content.
1426
1427 - `"text"`
1428
1429 - `file_id: str`
1430
1431 The ID of the vector store file.
1432
1433 - `filename: str`
1434
1435 The name of the vector store file.
1436
1437 - `score: float`
1438
1439 The similarity score for the result.
1440
1441# Files
1442
1443## List vector store files
1444
1445`vector_stores.files.list(strvector_store_id, FileListParams**kwargs) -> SyncCursorPage[VectorStoreFile]`
1446
1447**get** `/vector_stores/{vector_store_id}/files`
1448
1449Returns a list of vector store files.
1450
1451### Parameters
1452
1453- `vector_store_id: str`
1454
1455- `after: Optional[str]`
1456
1457 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.
1458
1459- `before: Optional[str]`
1460
1461 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
1462
1463- `filter: Optional[Literal["in_progress", "completed", "failed", "cancelled"]]`
1464
1465 Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
1466
1467 - `"in_progress"`
1468
1469 - `"completed"`
1470
1471 - `"failed"`
1472
1473 - `"cancelled"`
1474
1475- `limit: Optional[int]`
1476
1477 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
1478
1479- `order: Optional[Literal["asc", "desc"]]`
1480
1481 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
1482
1483 - `"asc"`
1484
1485 - `"desc"`
1486
1487### Returns
1488
1489- `class VectorStoreFile: …`
1490
1491 A list of files attached to a vector store.
1492
1493 - `id: str`
1494
1495 The identifier, which can be referenced in API endpoints.
1496
1497 - `created_at: int`
1498
1499 The Unix timestamp (in seconds) for when the vector store file was created.
1500
1501 - `last_error: Optional[LastError]`
1502
1503 The last error associated with this vector store file. Will be `null` if there are no errors.
1504
1505 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
1506
1507 One of `server_error`, `unsupported_file`, or `invalid_file`.
1508
1509 - `"server_error"`
1510
1511 - `"unsupported_file"`
1512
1513 - `"invalid_file"`
1514
1515 - `message: str`
1516
1517 A human-readable description of the error.
1518
1519 - `object: Literal["vector_store.file"]`
1520
1521 The object type, which is always `vector_store.file`.
1522
1523 - `"vector_store.file"`
1524
1525 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
1526
1527 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
1528
1529 - `"in_progress"`
1530
1531 - `"completed"`
1532
1533 - `"cancelled"`
1534
1535 - `"failed"`
1536
1537 - `usage_bytes: int`
1538
1539 The total vector store usage in bytes. Note that this may be different from the original file size.
1540
1541 - `vector_store_id: str`
1542
1543 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
1544
1545 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1546
1547 Set of 16 key-value pairs that can be attached to an object. This can be
1548 useful for storing additional information about the object in a structured
1549 format, and querying for objects via API or the dashboard. Keys are strings
1550 with a maximum length of 64 characters. Values are strings with a maximum
1551 length of 512 characters, booleans, or numbers.
1552
1553 - `str`
1554
1555 - `float`
1556
1557 - `bool`
1558
1559 - `chunking_strategy: Optional[FileChunkingStrategy]`
1560
1561 The strategy used to chunk the file.
1562
1563 - `class StaticFileChunkingStrategyObject: …`
1564
1565 - `static: StaticFileChunkingStrategy`
1566
1567 - `chunk_overlap_tokens: int`
1568
1569 The number of tokens that overlap between chunks. The default value is `400`.
1570
1571 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1572
1573 - `max_chunk_size_tokens: int`
1574
1575 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1576
1577 - `type: Literal["static"]`
1578
1579 Always `static`.
1580
1581 - `"static"`
1582
1583 - `class OtherFileChunkingStrategyObject: …`
1584
1585 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
1586
1587 - `type: Literal["other"]`
1588
1589 Always `other`.
1590
1591 - `"other"`
1592
1593### Example
1594
1595```python
1596import os
1597from openai import OpenAI
1598
1599client = OpenAI(
1600 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
1601)
1602page = client.vector_stores.files.list(
1603 vector_store_id="vector_store_id",
1604)
1605page = page.data[0]
1606print(page.id)
1607```
1608
1609#### Response
1610
1611```json
1612{
1613 "data": [
1614 {
1615 "id": "id",
1616 "created_at": 0,
1617 "last_error": {
1618 "code": "server_error",
1619 "message": "message"
1620 },
1621 "object": "vector_store.file",
1622 "status": "in_progress",
1623 "usage_bytes": 0,
1624 "vector_store_id": "vector_store_id",
1625 "attributes": {
1626 "foo": "string"
1627 },
1628 "chunking_strategy": {
1629 "static": {
1630 "chunk_overlap_tokens": 0,
1631 "max_chunk_size_tokens": 100
1632 },
1633 "type": "static"
1634 }
1635 }
1636 ],
1637 "first_id": "file-abc123",
1638 "has_more": false,
1639 "last_id": "file-abc456",
1640 "object": "list"
1641}
1642```
1643
1644### Example
1645
1646```python
1647from openai import OpenAI
1648client = OpenAI()
1649
1650vector_store_files = client.vector_stores.files.list(
1651 vector_store_id="vs_abc123"
1652)
1653print(vector_store_files)
1654```
1655
1656#### Response
1657
1658```json
1659{
1660 "object": "list",
1661 "data": [
1662 {
1663 "id": "file-abc123",
1664 "object": "vector_store.file",
1665 "created_at": 1699061776,
1666 "vector_store_id": "vs_abc123"
1667 },
1668 {
1669 "id": "file-abc456",
1670 "object": "vector_store.file",
1671 "created_at": 1699061776,
1672 "vector_store_id": "vs_abc123"
1673 }
1674 ],
1675 "first_id": "file-abc123",
1676 "last_id": "file-abc456",
1677 "has_more": false
1678}
1679```
1680
1681## Create vector store file
1682
1683`vector_stores.files.create(strvector_store_id, FileCreateParams**kwargs) -> VectorStoreFile`
1684
1685**post** `/vector_stores/{vector_store_id}/files`
1686
1687Create a vector store file by attaching a [File](https://platform.openai.com/docs/api-reference/files) to a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
1688
1689### Parameters
1690
1691- `vector_store_id: str`
1692
1693- `file_id: str`
1694
1695 A [File](https://platform.openai.com/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. For multi-file ingestion, we recommend [`file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch) to minimize per-vector-store write requests.
1696
1697- `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1698
1699 Set of 16 key-value pairs that can be attached to an object. This can be
1700 useful for storing additional information about the object in a structured
1701 format, and querying for objects via API or the dashboard. Keys are strings
1702 with a maximum length of 64 characters. Values are strings with a maximum
1703 length of 512 characters, booleans, or numbers.
1704
1705 - `str`
1706
1707 - `float`
1708
1709 - `bool`
1710
1711- `chunking_strategy: Optional[FileChunkingStrategyParam]`
1712
1713 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
1714
1715 - `class AutoFileChunkingStrategyParam: …`
1716
1717 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
1718
1719 - `type: Literal["auto"]`
1720
1721 Always `auto`.
1722
1723 - `"auto"`
1724
1725 - `class StaticFileChunkingStrategyObjectParam: …`
1726
1727 Customize your own chunking strategy by setting chunk size and chunk overlap.
1728
1729 - `static: StaticFileChunkingStrategy`
1730
1731 - `chunk_overlap_tokens: int`
1732
1733 The number of tokens that overlap between chunks. The default value is `400`.
1734
1735 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1736
1737 - `max_chunk_size_tokens: int`
1738
1739 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1740
1741 - `type: Literal["static"]`
1742
1743 Always `static`.
1744
1745 - `"static"`
1746
1747### Returns
1748
1749- `class VectorStoreFile: …`
1750
1751 A list of files attached to a vector store.
1752
1753 - `id: str`
1754
1755 The identifier, which can be referenced in API endpoints.
1756
1757 - `created_at: int`
1758
1759 The Unix timestamp (in seconds) for when the vector store file was created.
1760
1761 - `last_error: Optional[LastError]`
1762
1763 The last error associated with this vector store file. Will be `null` if there are no errors.
1764
1765 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
1766
1767 One of `server_error`, `unsupported_file`, or `invalid_file`.
1768
1769 - `"server_error"`
1770
1771 - `"unsupported_file"`
1772
1773 - `"invalid_file"`
1774
1775 - `message: str`
1776
1777 A human-readable description of the error.
1778
1779 - `object: Literal["vector_store.file"]`
1780
1781 The object type, which is always `vector_store.file`.
1782
1783 - `"vector_store.file"`
1784
1785 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
1786
1787 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
1788
1789 - `"in_progress"`
1790
1791 - `"completed"`
1792
1793 - `"cancelled"`
1794
1795 - `"failed"`
1796
1797 - `usage_bytes: int`
1798
1799 The total vector store usage in bytes. Note that this may be different from the original file size.
1800
1801 - `vector_store_id: str`
1802
1803 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
1804
1805 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1806
1807 Set of 16 key-value pairs that can be attached to an object. This can be
1808 useful for storing additional information about the object in a structured
1809 format, and querying for objects via API or the dashboard. Keys are strings
1810 with a maximum length of 64 characters. Values are strings with a maximum
1811 length of 512 characters, booleans, or numbers.
1812
1813 - `str`
1814
1815 - `float`
1816
1817 - `bool`
1818
1819 - `chunking_strategy: Optional[FileChunkingStrategy]`
1820
1821 The strategy used to chunk the file.
1822
1823 - `class StaticFileChunkingStrategyObject: …`
1824
1825 - `static: StaticFileChunkingStrategy`
1826
1827 - `chunk_overlap_tokens: int`
1828
1829 The number of tokens that overlap between chunks. The default value is `400`.
1830
1831 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
1832
1833 - `max_chunk_size_tokens: int`
1834
1835 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
1836
1837 - `type: Literal["static"]`
1838
1839 Always `static`.
1840
1841 - `"static"`
1842
1843 - `class OtherFileChunkingStrategyObject: …`
1844
1845 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
1846
1847 - `type: Literal["other"]`
1848
1849 Always `other`.
1850
1851 - `"other"`
1852
1853### Example
1854
1855```python
1856import os
1857from openai import OpenAI
1858
1859client = OpenAI(
1860 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
1861)
1862vector_store_file = client.vector_stores.files.create(
1863 vector_store_id="vs_abc123",
1864 file_id="file_id",
1865)
1866print(vector_store_file.id)
1867```
1868
1869#### Response
1870
1871```json
1872{
1873 "id": "id",
1874 "created_at": 0,
1875 "last_error": {
1876 "code": "server_error",
1877 "message": "message"
1878 },
1879 "object": "vector_store.file",
1880 "status": "in_progress",
1881 "usage_bytes": 0,
1882 "vector_store_id": "vector_store_id",
1883 "attributes": {
1884 "foo": "string"
1885 },
1886 "chunking_strategy": {
1887 "static": {
1888 "chunk_overlap_tokens": 0,
1889 "max_chunk_size_tokens": 100
1890 },
1891 "type": "static"
1892 }
1893}
1894```
1895
1896### Example
1897
1898```python
1899from openai import OpenAI
1900client = OpenAI()
1901
1902vector_store_file = client.vector_stores.files.create(
1903 vector_store_id="vs_abc123",
1904 file_id="file-abc123"
1905)
1906print(vector_store_file)
1907```
1908
1909#### Response
1910
1911```json
1912{
1913 "id": "file-abc123",
1914 "object": "vector_store.file",
1915 "created_at": 1699061776,
1916 "usage_bytes": 1234,
1917 "vector_store_id": "vs_abcd",
1918 "status": "completed",
1919 "last_error": null
1920}
1921```
1922
1923## Update vector store file attributes
1924
1925`vector_stores.files.update(strfile_id, FileUpdateParams**kwargs) -> VectorStoreFile`
1926
1927**post** `/vector_stores/{vector_store_id}/files/{file_id}`
1928
1929Update attributes on a vector store file.
1930
1931### Parameters
1932
1933- `vector_store_id: str`
1934
1935- `file_id: str`
1936
1937- `attributes: Optional[Dict[str, Union[str, float, bool]]]`
1938
1939 Set of 16 key-value pairs that can be attached to an object. This can be
1940 useful for storing additional information about the object in a structured
1941 format, and querying for objects via API or the dashboard. Keys are strings
1942 with a maximum length of 64 characters. Values are strings with a maximum
1943 length of 512 characters, booleans, or numbers.
1944
1945 - `str`
1946
1947 - `float`
1948
1949 - `bool`
1950
1951### Returns
1952
1953- `class VectorStoreFile: …`
1954
1955 A list of files attached to a vector store.
1956
1957 - `id: str`
1958
1959 The identifier, which can be referenced in API endpoints.
1960
1961 - `created_at: int`
1962
1963 The Unix timestamp (in seconds) for when the vector store file was created.
1964
1965 - `last_error: Optional[LastError]`
1966
1967 The last error associated with this vector store file. Will be `null` if there are no errors.
1968
1969 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
1970
1971 One of `server_error`, `unsupported_file`, or `invalid_file`.
1972
1973 - `"server_error"`
1974
1975 - `"unsupported_file"`
1976
1977 - `"invalid_file"`
1978
1979 - `message: str`
1980
1981 A human-readable description of the error.
1982
1983 - `object: Literal["vector_store.file"]`
1984
1985 The object type, which is always `vector_store.file`.
1986
1987 - `"vector_store.file"`
1988
1989 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
1990
1991 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
1992
1993 - `"in_progress"`
1994
1995 - `"completed"`
1996
1997 - `"cancelled"`
1998
1999 - `"failed"`
2000
2001 - `usage_bytes: int`
2002
2003 The total vector store usage in bytes. Note that this may be different from the original file size.
2004
2005 - `vector_store_id: str`
2006
2007 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2008
2009 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
2010
2011 Set of 16 key-value pairs that can be attached to an object. This can be
2012 useful for storing additional information about the object in a structured
2013 format, and querying for objects via API or the dashboard. Keys are strings
2014 with a maximum length of 64 characters. Values are strings with a maximum
2015 length of 512 characters, booleans, or numbers.
2016
2017 - `str`
2018
2019 - `float`
2020
2021 - `bool`
2022
2023 - `chunking_strategy: Optional[FileChunkingStrategy]`
2024
2025 The strategy used to chunk the file.
2026
2027 - `class StaticFileChunkingStrategyObject: …`
2028
2029 - `static: StaticFileChunkingStrategy`
2030
2031 - `chunk_overlap_tokens: int`
2032
2033 The number of tokens that overlap between chunks. The default value is `400`.
2034
2035 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2036
2037 - `max_chunk_size_tokens: int`
2038
2039 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
2040
2041 - `type: Literal["static"]`
2042
2043 Always `static`.
2044
2045 - `"static"`
2046
2047 - `class OtherFileChunkingStrategyObject: …`
2048
2049 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
2050
2051 - `type: Literal["other"]`
2052
2053 Always `other`.
2054
2055 - `"other"`
2056
2057### Example
2058
2059```python
2060import os
2061from openai import OpenAI
2062
2063client = OpenAI(
2064 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2065)
2066vector_store_file = client.vector_stores.files.update(
2067 file_id="file-abc123",
2068 vector_store_id="vs_abc123",
2069 attributes={
2070 "foo": "string"
2071 },
2072)
2073print(vector_store_file.id)
2074```
2075
2076#### Response
2077
2078```json
2079{
2080 "id": "id",
2081 "created_at": 0,
2082 "last_error": {
2083 "code": "server_error",
2084 "message": "message"
2085 },
2086 "object": "vector_store.file",
2087 "status": "in_progress",
2088 "usage_bytes": 0,
2089 "vector_store_id": "vector_store_id",
2090 "attributes": {
2091 "foo": "string"
2092 },
2093 "chunking_strategy": {
2094 "static": {
2095 "chunk_overlap_tokens": 0,
2096 "max_chunk_size_tokens": 100
2097 },
2098 "type": "static"
2099 }
2100}
2101```
2102
2103## Retrieve vector store file
2104
2105`vector_stores.files.retrieve(strfile_id, FileRetrieveParams**kwargs) -> VectorStoreFile`
2106
2107**get** `/vector_stores/{vector_store_id}/files/{file_id}`
2108
2109Retrieves a vector store file.
2110
2111### Parameters
2112
2113- `vector_store_id: str`
2114
2115- `file_id: str`
2116
2117### Returns
2118
2119- `class VectorStoreFile: …`
2120
2121 A list of files attached to a vector store.
2122
2123 - `id: str`
2124
2125 The identifier, which can be referenced in API endpoints.
2126
2127 - `created_at: int`
2128
2129 The Unix timestamp (in seconds) for when the vector store file was created.
2130
2131 - `last_error: Optional[LastError]`
2132
2133 The last error associated with this vector store file. Will be `null` if there are no errors.
2134
2135 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
2136
2137 One of `server_error`, `unsupported_file`, or `invalid_file`.
2138
2139 - `"server_error"`
2140
2141 - `"unsupported_file"`
2142
2143 - `"invalid_file"`
2144
2145 - `message: str`
2146
2147 A human-readable description of the error.
2148
2149 - `object: Literal["vector_store.file"]`
2150
2151 The object type, which is always `vector_store.file`.
2152
2153 - `"vector_store.file"`
2154
2155 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
2156
2157 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
2158
2159 - `"in_progress"`
2160
2161 - `"completed"`
2162
2163 - `"cancelled"`
2164
2165 - `"failed"`
2166
2167 - `usage_bytes: int`
2168
2169 The total vector store usage in bytes. Note that this may be different from the original file size.
2170
2171 - `vector_store_id: str`
2172
2173 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2174
2175 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
2176
2177 Set of 16 key-value pairs that can be attached to an object. This can be
2178 useful for storing additional information about the object in a structured
2179 format, and querying for objects via API or the dashboard. Keys are strings
2180 with a maximum length of 64 characters. Values are strings with a maximum
2181 length of 512 characters, booleans, or numbers.
2182
2183 - `str`
2184
2185 - `float`
2186
2187 - `bool`
2188
2189 - `chunking_strategy: Optional[FileChunkingStrategy]`
2190
2191 The strategy used to chunk the file.
2192
2193 - `class StaticFileChunkingStrategyObject: …`
2194
2195 - `static: StaticFileChunkingStrategy`
2196
2197 - `chunk_overlap_tokens: int`
2198
2199 The number of tokens that overlap between chunks. The default value is `400`.
2200
2201 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2202
2203 - `max_chunk_size_tokens: int`
2204
2205 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
2206
2207 - `type: Literal["static"]`
2208
2209 Always `static`.
2210
2211 - `"static"`
2212
2213 - `class OtherFileChunkingStrategyObject: …`
2214
2215 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
2216
2217 - `type: Literal["other"]`
2218
2219 Always `other`.
2220
2221 - `"other"`
2222
2223### Example
2224
2225```python
2226import os
2227from openai import OpenAI
2228
2229client = OpenAI(
2230 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2231)
2232vector_store_file = client.vector_stores.files.retrieve(
2233 file_id="file-abc123",
2234 vector_store_id="vs_abc123",
2235)
2236print(vector_store_file.id)
2237```
2238
2239#### Response
2240
2241```json
2242{
2243 "id": "id",
2244 "created_at": 0,
2245 "last_error": {
2246 "code": "server_error",
2247 "message": "message"
2248 },
2249 "object": "vector_store.file",
2250 "status": "in_progress",
2251 "usage_bytes": 0,
2252 "vector_store_id": "vector_store_id",
2253 "attributes": {
2254 "foo": "string"
2255 },
2256 "chunking_strategy": {
2257 "static": {
2258 "chunk_overlap_tokens": 0,
2259 "max_chunk_size_tokens": 100
2260 },
2261 "type": "static"
2262 }
2263}
2264```
2265
2266### Example
2267
2268```python
2269from openai import OpenAI
2270client = OpenAI()
2271
2272vector_store_file = client.vector_stores.files.retrieve(
2273 vector_store_id="vs_abc123",
2274 file_id="file-abc123"
2275)
2276print(vector_store_file)
2277```
2278
2279#### Response
2280
2281```json
2282{
2283 "id": "file-abc123",
2284 "object": "vector_store.file",
2285 "created_at": 1699061776,
2286 "vector_store_id": "vs_abcd",
2287 "status": "completed",
2288 "last_error": null
2289}
2290```
2291
2292## Delete vector store file
2293
2294`vector_stores.files.delete(strfile_id, FileDeleteParams**kwargs) -> VectorStoreFileDeleted`
2295
2296**delete** `/vector_stores/{vector_store_id}/files/{file_id}`
2297
2298Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](https://platform.openai.com/docs/api-reference/files/delete) endpoint.
2299
2300### Parameters
2301
2302- `vector_store_id: str`
2303
2304- `file_id: str`
2305
2306### Returns
2307
2308- `class VectorStoreFileDeleted: …`
2309
2310 - `id: str`
2311
2312 - `deleted: bool`
2313
2314 - `object: Literal["vector_store.file.deleted"]`
2315
2316 - `"vector_store.file.deleted"`
2317
2318### Example
2319
2320```python
2321import os
2322from openai import OpenAI
2323
2324client = OpenAI(
2325 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2326)
2327vector_store_file_deleted = client.vector_stores.files.delete(
2328 file_id="file_id",
2329 vector_store_id="vector_store_id",
2330)
2331print(vector_store_file_deleted.id)
2332```
2333
2334#### Response
2335
2336```json
2337{
2338 "id": "id",
2339 "deleted": true,
2340 "object": "vector_store.file.deleted"
2341}
2342```
2343
2344### Example
2345
2346```python
2347from openai import OpenAI
2348client = OpenAI()
2349
2350deleted_vector_store_file = client.vector_stores.files.delete(
2351 vector_store_id="vs_abc123",
2352 file_id="file-abc123"
2353)
2354print(deleted_vector_store_file)
2355```
2356
2357#### Response
2358
2359```json
2360{
2361 id: "file-abc123",
2362 object: "vector_store.file.deleted",
2363 deleted: true
2364}
2365```
2366
2367## Retrieve vector store file content
2368
2369`vector_stores.files.content(strfile_id, FileContentParams**kwargs) -> SyncPage[FileContentResponse]`
2370
2371**get** `/vector_stores/{vector_store_id}/files/{file_id}/content`
2372
2373Retrieve the parsed contents of a vector store file.
2374
2375### Parameters
2376
2377- `vector_store_id: str`
2378
2379- `file_id: str`
2380
2381### Returns
2382
2383- `class FileContentResponse: …`
2384
2385 - `text: Optional[str]`
2386
2387 The text content
2388
2389 - `type: Optional[str]`
2390
2391 The content type (currently only `"text"`)
2392
2393### Example
2394
2395```python
2396import os
2397from openai import OpenAI
2398
2399client = OpenAI(
2400 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2401)
2402page = client.vector_stores.files.content(
2403 file_id="file-abc123",
2404 vector_store_id="vs_abc123",
2405)
2406page = page.data[0]
2407print(page.text)
2408```
2409
2410#### Response
2411
2412```json
2413{
2414 "data": [
2415 {
2416 "text": "text",
2417 "type": "type"
2418 }
2419 ],
2420 "has_more": true,
2421 "next_page": "next_page",
2422 "object": "vector_store.file_content.page"
2423}
2424```
2425
2426## Domain Types
2427
2428### Vector Store File
2429
2430- `class VectorStoreFile: …`
2431
2432 A list of files attached to a vector store.
2433
2434 - `id: str`
2435
2436 The identifier, which can be referenced in API endpoints.
2437
2438 - `created_at: int`
2439
2440 The Unix timestamp (in seconds) for when the vector store file was created.
2441
2442 - `last_error: Optional[LastError]`
2443
2444 The last error associated with this vector store file. Will be `null` if there are no errors.
2445
2446 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
2447
2448 One of `server_error`, `unsupported_file`, or `invalid_file`.
2449
2450 - `"server_error"`
2451
2452 - `"unsupported_file"`
2453
2454 - `"invalid_file"`
2455
2456 - `message: str`
2457
2458 A human-readable description of the error.
2459
2460 - `object: Literal["vector_store.file"]`
2461
2462 The object type, which is always `vector_store.file`.
2463
2464 - `"vector_store.file"`
2465
2466 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
2467
2468 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
2469
2470 - `"in_progress"`
2471
2472 - `"completed"`
2473
2474 - `"cancelled"`
2475
2476 - `"failed"`
2477
2478 - `usage_bytes: int`
2479
2480 The total vector store usage in bytes. Note that this may be different from the original file size.
2481
2482 - `vector_store_id: str`
2483
2484 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2485
2486 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
2487
2488 Set of 16 key-value pairs that can be attached to an object. This can be
2489 useful for storing additional information about the object in a structured
2490 format, and querying for objects via API or the dashboard. Keys are strings
2491 with a maximum length of 64 characters. Values are strings with a maximum
2492 length of 512 characters, booleans, or numbers.
2493
2494 - `str`
2495
2496 - `float`
2497
2498 - `bool`
2499
2500 - `chunking_strategy: Optional[FileChunkingStrategy]`
2501
2502 The strategy used to chunk the file.
2503
2504 - `class StaticFileChunkingStrategyObject: …`
2505
2506 - `static: StaticFileChunkingStrategy`
2507
2508 - `chunk_overlap_tokens: int`
2509
2510 The number of tokens that overlap between chunks. The default value is `400`.
2511
2512 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2513
2514 - `max_chunk_size_tokens: int`
2515
2516 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
2517
2518 - `type: Literal["static"]`
2519
2520 Always `static`.
2521
2522 - `"static"`
2523
2524 - `class OtherFileChunkingStrategyObject: …`
2525
2526 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
2527
2528 - `type: Literal["other"]`
2529
2530 Always `other`.
2531
2532 - `"other"`
2533
2534### Vector Store File Deleted
2535
2536- `class VectorStoreFileDeleted: …`
2537
2538 - `id: str`
2539
2540 - `deleted: bool`
2541
2542 - `object: Literal["vector_store.file.deleted"]`
2543
2544 - `"vector_store.file.deleted"`
2545
2546### File Content Response
2547
2548- `class FileContentResponse: …`
2549
2550 - `text: Optional[str]`
2551
2552 The text content
2553
2554 - `type: Optional[str]`
2555
2556 The content type (currently only `"text"`)
2557
2558# File Batches
2559
2560## Create vector store file batch
2561
2562`vector_stores.file_batches.create(strvector_store_id, FileBatchCreateParams**kwargs) -> VectorStoreFileBatch`
2563
2564**post** `/vector_stores/{vector_store_id}/file_batches`
2565
2566Create a vector store file batch.
2567
2568### Parameters
2569
2570- `vector_store_id: str`
2571
2572- `attributes: Optional[Dict[str, Union[str, float, bool]]]`
2573
2574 Set of 16 key-value pairs that can be attached to an object. This can be
2575 useful for storing additional information about the object in a structured
2576 format, and querying for objects via API or the dashboard. Keys are strings
2577 with a maximum length of 64 characters. Values are strings with a maximum
2578 length of 512 characters, booleans, or numbers.
2579
2580 - `str`
2581
2582 - `float`
2583
2584 - `bool`
2585
2586- `chunking_strategy: Optional[FileChunkingStrategyParam]`
2587
2588 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
2589
2590 - `class AutoFileChunkingStrategyParam: …`
2591
2592 The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
2593
2594 - `type: Literal["auto"]`
2595
2596 Always `auto`.
2597
2598 - `"auto"`
2599
2600 - `class StaticFileChunkingStrategyObjectParam: …`
2601
2602 Customize your own chunking strategy by setting chunk size and chunk overlap.
2603
2604 - `static: StaticFileChunkingStrategy`
2605
2606 - `chunk_overlap_tokens: int`
2607
2608 The number of tokens that overlap between chunks. The default value is `400`.
2609
2610 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2611
2612 - `max_chunk_size_tokens: int`
2613
2614 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
2615
2616 - `type: Literal["static"]`
2617
2618 Always `static`.
2619
2620 - `"static"`
2621
2622- `file_ids: Optional[Sequence[str]]`
2623
2624 A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. If `attributes` or `chunking_strategy` are provided, they will be applied to all files in the batch. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `files`.
2625
2626- `files: Optional[Iterable[File]]`
2627
2628 A list of objects that each include a `file_id` plus optional `attributes` or `chunking_strategy`. Use this when you need to override metadata for specific files. The global `attributes` or `chunking_strategy` will be ignored and must be specified for each file. The maximum batch size is 2000 files. This endpoint is recommended for multi-file ingestion and helps reduce per-vector-store write request pressure. Mutually exclusive with `file_ids`.
2629
2630 - `file_id: str`
2631
2632 A [File](https://platform.openai.com/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. For multi-file ingestion, we recommend [`file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch) to minimize per-vector-store write requests.
2633
2634 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
2635
2636 Set of 16 key-value pairs that can be attached to an object. This can be
2637 useful for storing additional information about the object in a structured
2638 format, and querying for objects via API or the dashboard. Keys are strings
2639 with a maximum length of 64 characters. Values are strings with a maximum
2640 length of 512 characters, booleans, or numbers.
2641
2642 - `str`
2643
2644 - `float`
2645
2646 - `bool`
2647
2648 - `chunking_strategy: Optional[FileChunkingStrategyParam]`
2649
2650 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty.
2651
2652### Returns
2653
2654- `class VectorStoreFileBatch: …`
2655
2656 A batch of files attached to a vector store.
2657
2658 - `id: str`
2659
2660 The identifier, which can be referenced in API endpoints.
2661
2662 - `created_at: int`
2663
2664 The Unix timestamp (in seconds) for when the vector store files batch was created.
2665
2666 - `file_counts: FileCounts`
2667
2668 - `cancelled: int`
2669
2670 The number of files that where cancelled.
2671
2672 - `completed: int`
2673
2674 The number of files that have been processed.
2675
2676 - `failed: int`
2677
2678 The number of files that have failed to process.
2679
2680 - `in_progress: int`
2681
2682 The number of files that are currently being processed.
2683
2684 - `total: int`
2685
2686 The total number of files.
2687
2688 - `object: Literal["vector_store.files_batch"]`
2689
2690 The object type, which is always `vector_store.file_batch`.
2691
2692 - `"vector_store.files_batch"`
2693
2694 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
2695
2696 The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
2697
2698 - `"in_progress"`
2699
2700 - `"completed"`
2701
2702 - `"cancelled"`
2703
2704 - `"failed"`
2705
2706 - `vector_store_id: str`
2707
2708 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2709
2710### Example
2711
2712```python
2713import os
2714from openai import OpenAI
2715
2716client = OpenAI(
2717 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2718)
2719vector_store_file_batch = client.vector_stores.file_batches.create(
2720 vector_store_id="vs_abc123",
2721)
2722print(vector_store_file_batch.id)
2723```
2724
2725#### Response
2726
2727```json
2728{
2729 "id": "id",
2730 "created_at": 0,
2731 "file_counts": {
2732 "cancelled": 0,
2733 "completed": 0,
2734 "failed": 0,
2735 "in_progress": 0,
2736 "total": 0
2737 },
2738 "object": "vector_store.files_batch",
2739 "status": "in_progress",
2740 "vector_store_id": "vector_store_id"
2741}
2742```
2743
2744### Example
2745
2746```python
2747from openai import OpenAI
2748client = OpenAI()
2749
2750vector_store_file_batch = client.vector_stores.file_batches.create(
2751 vector_store_id="vs_abc123",
2752 files=[
2753 {
2754 "file_id": "file-abc123",
2755 "attributes": {"category": "finance"},
2756 },
2757 {
2758 "file_id": "file-abc456",
2759 "chunking_strategy": {
2760 "type": "static",
2761 "max_chunk_size_tokens": 1200,
2762 "chunk_overlap_tokens": 200,
2763 },
2764 },
2765 ],
2766)
2767print(vector_store_file_batch)
2768```
2769
2770#### Response
2771
2772```json
2773{
2774 "id": "vsfb_abc123",
2775 "object": "vector_store.file_batch",
2776 "created_at": 1699061776,
2777 "vector_store_id": "vs_abc123",
2778 "status": "in_progress",
2779 "file_counts": {
2780 "in_progress": 1,
2781 "completed": 1,
2782 "failed": 0,
2783 "cancelled": 0,
2784 "total": 0,
2785 }
2786}
2787```
2788
2789## Retrieve vector store file batch
2790
2791`vector_stores.file_batches.retrieve(strbatch_id, FileBatchRetrieveParams**kwargs) -> VectorStoreFileBatch`
2792
2793**get** `/vector_stores/{vector_store_id}/file_batches/{batch_id}`
2794
2795Retrieves a vector store file batch.
2796
2797### Parameters
2798
2799- `vector_store_id: str`
2800
2801- `batch_id: str`
2802
2803### Returns
2804
2805- `class VectorStoreFileBatch: …`
2806
2807 A batch of files attached to a vector store.
2808
2809 - `id: str`
2810
2811 The identifier, which can be referenced in API endpoints.
2812
2813 - `created_at: int`
2814
2815 The Unix timestamp (in seconds) for when the vector store files batch was created.
2816
2817 - `file_counts: FileCounts`
2818
2819 - `cancelled: int`
2820
2821 The number of files that where cancelled.
2822
2823 - `completed: int`
2824
2825 The number of files that have been processed.
2826
2827 - `failed: int`
2828
2829 The number of files that have failed to process.
2830
2831 - `in_progress: int`
2832
2833 The number of files that are currently being processed.
2834
2835 - `total: int`
2836
2837 The total number of files.
2838
2839 - `object: Literal["vector_store.files_batch"]`
2840
2841 The object type, which is always `vector_store.file_batch`.
2842
2843 - `"vector_store.files_batch"`
2844
2845 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
2846
2847 The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
2848
2849 - `"in_progress"`
2850
2851 - `"completed"`
2852
2853 - `"cancelled"`
2854
2855 - `"failed"`
2856
2857 - `vector_store_id: str`
2858
2859 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2860
2861### Example
2862
2863```python
2864import os
2865from openai import OpenAI
2866
2867client = OpenAI(
2868 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
2869)
2870vector_store_file_batch = client.vector_stores.file_batches.retrieve(
2871 batch_id="vsfb_abc123",
2872 vector_store_id="vs_abc123",
2873)
2874print(vector_store_file_batch.id)
2875```
2876
2877#### Response
2878
2879```json
2880{
2881 "id": "id",
2882 "created_at": 0,
2883 "file_counts": {
2884 "cancelled": 0,
2885 "completed": 0,
2886 "failed": 0,
2887 "in_progress": 0,
2888 "total": 0
2889 },
2890 "object": "vector_store.files_batch",
2891 "status": "in_progress",
2892 "vector_store_id": "vector_store_id"
2893}
2894```
2895
2896### Example
2897
2898```python
2899from openai import OpenAI
2900client = OpenAI()
2901
2902vector_store_file_batch = client.vector_stores.file_batches.retrieve(
2903 vector_store_id="vs_abc123",
2904 batch_id="vsfb_abc123"
2905)
2906print(vector_store_file_batch)
2907```
2908
2909#### Response
2910
2911```json
2912{
2913 "id": "vsfb_abc123",
2914 "object": "vector_store.file_batch",
2915 "created_at": 1699061776,
2916 "vector_store_id": "vs_abc123",
2917 "status": "in_progress",
2918 "file_counts": {
2919 "in_progress": 1,
2920 "completed": 1,
2921 "failed": 0,
2922 "cancelled": 0,
2923 "total": 0,
2924 }
2925}
2926```
2927
2928## Cancel vector store file batch
2929
2930`vector_stores.file_batches.cancel(strbatch_id, FileBatchCancelParams**kwargs) -> VectorStoreFileBatch`
2931
2932**post** `/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel`
2933
2934Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.
2935
2936### Parameters
2937
2938- `vector_store_id: str`
2939
2940- `batch_id: str`
2941
2942### Returns
2943
2944- `class VectorStoreFileBatch: …`
2945
2946 A batch of files attached to a vector store.
2947
2948 - `id: str`
2949
2950 The identifier, which can be referenced in API endpoints.
2951
2952 - `created_at: int`
2953
2954 The Unix timestamp (in seconds) for when the vector store files batch was created.
2955
2956 - `file_counts: FileCounts`
2957
2958 - `cancelled: int`
2959
2960 The number of files that where cancelled.
2961
2962 - `completed: int`
2963
2964 The number of files that have been processed.
2965
2966 - `failed: int`
2967
2968 The number of files that have failed to process.
2969
2970 - `in_progress: int`
2971
2972 The number of files that are currently being processed.
2973
2974 - `total: int`
2975
2976 The total number of files.
2977
2978 - `object: Literal["vector_store.files_batch"]`
2979
2980 The object type, which is always `vector_store.file_batch`.
2981
2982 - `"vector_store.files_batch"`
2983
2984 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
2985
2986 The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
2987
2988 - `"in_progress"`
2989
2990 - `"completed"`
2991
2992 - `"cancelled"`
2993
2994 - `"failed"`
2995
2996 - `vector_store_id: str`
2997
2998 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
2999
3000### Example
3001
3002```python
3003import os
3004from openai import OpenAI
3005
3006client = OpenAI(
3007 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
3008)
3009vector_store_file_batch = client.vector_stores.file_batches.cancel(
3010 batch_id="batch_id",
3011 vector_store_id="vector_store_id",
3012)
3013print(vector_store_file_batch.id)
3014```
3015
3016#### Response
3017
3018```json
3019{
3020 "id": "id",
3021 "created_at": 0,
3022 "file_counts": {
3023 "cancelled": 0,
3024 "completed": 0,
3025 "failed": 0,
3026 "in_progress": 0,
3027 "total": 0
3028 },
3029 "object": "vector_store.files_batch",
3030 "status": "in_progress",
3031 "vector_store_id": "vector_store_id"
3032}
3033```
3034
3035### Example
3036
3037```python
3038from openai import OpenAI
3039client = OpenAI()
3040
3041deleted_vector_store_file_batch = client.vector_stores.file_batches.cancel(
3042 vector_store_id="vs_abc123",
3043 file_batch_id="vsfb_abc123"
3044)
3045print(deleted_vector_store_file_batch)
3046```
3047
3048#### Response
3049
3050```json
3051{
3052 "id": "vsfb_abc123",
3053 "object": "vector_store.file_batch",
3054 "created_at": 1699061776,
3055 "vector_store_id": "vs_abc123",
3056 "status": "in_progress",
3057 "file_counts": {
3058 "in_progress": 12,
3059 "completed": 3,
3060 "failed": 0,
3061 "cancelled": 0,
3062 "total": 15,
3063 }
3064}
3065```
3066
3067## List vector store files in a batch
3068
3069`vector_stores.file_batches.list_files(strbatch_id, FileBatchListFilesParams**kwargs) -> SyncCursorPage[VectorStoreFile]`
3070
3071**get** `/vector_stores/{vector_store_id}/file_batches/{batch_id}/files`
3072
3073Returns a list of vector store files in a batch.
3074
3075### Parameters
3076
3077- `vector_store_id: str`
3078
3079- `batch_id: str`
3080
3081- `after: Optional[str]`
3082
3083 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.
3084
3085- `before: Optional[str]`
3086
3087 A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
3088
3089- `filter: Optional[Literal["in_progress", "completed", "failed", "cancelled"]]`
3090
3091 Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
3092
3093 - `"in_progress"`
3094
3095 - `"completed"`
3096
3097 - `"failed"`
3098
3099 - `"cancelled"`
3100
3101- `limit: Optional[int]`
3102
3103 A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
3104
3105- `order: Optional[Literal["asc", "desc"]]`
3106
3107 Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.
3108
3109 - `"asc"`
3110
3111 - `"desc"`
3112
3113### Returns
3114
3115- `class VectorStoreFile: …`
3116
3117 A list of files attached to a vector store.
3118
3119 - `id: str`
3120
3121 The identifier, which can be referenced in API endpoints.
3122
3123 - `created_at: int`
3124
3125 The Unix timestamp (in seconds) for when the vector store file was created.
3126
3127 - `last_error: Optional[LastError]`
3128
3129 The last error associated with this vector store file. Will be `null` if there are no errors.
3130
3131 - `code: Literal["server_error", "unsupported_file", "invalid_file"]`
3132
3133 One of `server_error`, `unsupported_file`, or `invalid_file`.
3134
3135 - `"server_error"`
3136
3137 - `"unsupported_file"`
3138
3139 - `"invalid_file"`
3140
3141 - `message: str`
3142
3143 A human-readable description of the error.
3144
3145 - `object: Literal["vector_store.file"]`
3146
3147 The object type, which is always `vector_store.file`.
3148
3149 - `"vector_store.file"`
3150
3151 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
3152
3153 The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use.
3154
3155 - `"in_progress"`
3156
3157 - `"completed"`
3158
3159 - `"cancelled"`
3160
3161 - `"failed"`
3162
3163 - `usage_bytes: int`
3164
3165 The total vector store usage in bytes. Note that this may be different from the original file size.
3166
3167 - `vector_store_id: str`
3168
3169 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.
3170
3171 - `attributes: Optional[Dict[str, Union[str, float, bool]]]`
3172
3173 Set of 16 key-value pairs that can be attached to an object. This can be
3174 useful for storing additional information about the object in a structured
3175 format, and querying for objects via API or the dashboard. Keys are strings
3176 with a maximum length of 64 characters. Values are strings with a maximum
3177 length of 512 characters, booleans, or numbers.
3178
3179 - `str`
3180
3181 - `float`
3182
3183 - `bool`
3184
3185 - `chunking_strategy: Optional[FileChunkingStrategy]`
3186
3187 The strategy used to chunk the file.
3188
3189 - `class StaticFileChunkingStrategyObject: …`
3190
3191 - `static: StaticFileChunkingStrategy`
3192
3193 - `chunk_overlap_tokens: int`
3194
3195 The number of tokens that overlap between chunks. The default value is `400`.
3196
3197 Note that the overlap must not exceed half of `max_chunk_size_tokens`.
3198
3199 - `max_chunk_size_tokens: int`
3200
3201 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.
3202
3203 - `type: Literal["static"]`
3204
3205 Always `static`.
3206
3207 - `"static"`
3208
3209 - `class OtherFileChunkingStrategyObject: …`
3210
3211 This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
3212
3213 - `type: Literal["other"]`
3214
3215 Always `other`.
3216
3217 - `"other"`
3218
3219### Example
3220
3221```python
3222import os
3223from openai import OpenAI
3224
3225client = OpenAI(
3226 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
3227)
3228page = client.vector_stores.file_batches.list_files(
3229 batch_id="batch_id",
3230 vector_store_id="vector_store_id",
3231)
3232page = page.data[0]
3233print(page.id)
3234```
3235
3236#### Response
3237
3238```json
3239{
3240 "data": [
3241 {
3242 "id": "id",
3243 "created_at": 0,
3244 "last_error": {
3245 "code": "server_error",
3246 "message": "message"
3247 },
3248 "object": "vector_store.file",
3249 "status": "in_progress",
3250 "usage_bytes": 0,
3251 "vector_store_id": "vector_store_id",
3252 "attributes": {
3253 "foo": "string"
3254 },
3255 "chunking_strategy": {
3256 "static": {
3257 "chunk_overlap_tokens": 0,
3258 "max_chunk_size_tokens": 100
3259 },
3260 "type": "static"
3261 }
3262 }
3263 ],
3264 "first_id": "file-abc123",
3265 "has_more": false,
3266 "last_id": "file-abc456",
3267 "object": "list"
3268}
3269```
3270
3271### Example
3272
3273```python
3274from openai import OpenAI
3275client = OpenAI()
3276
3277vector_store_files = client.vector_stores.file_batches.list_files(
3278 vector_store_id="vs_abc123",
3279 batch_id="vsfb_abc123"
3280)
3281print(vector_store_files)
3282```
3283
3284#### Response
3285
3286```json
3287{
3288 "object": "list",
3289 "data": [
3290 {
3291 "id": "file-abc123",
3292 "object": "vector_store.file",
3293 "created_at": 1699061776,
3294 "vector_store_id": "vs_abc123"
3295 },
3296 {
3297 "id": "file-abc456",
3298 "object": "vector_store.file",
3299 "created_at": 1699061776,
3300 "vector_store_id": "vs_abc123"
3301 }
3302 ],
3303 "first_id": "file-abc123",
3304 "last_id": "file-abc456",
3305 "has_more": false
3306}
3307```
3308
3309## Domain Types
3310
3311### Vector Store File Batch
3312
3313- `class VectorStoreFileBatch: …`
3314
3315 A batch of files attached to a vector store.
3316
3317 - `id: str`
3318
3319 The identifier, which can be referenced in API endpoints.
3320
3321 - `created_at: int`
3322
3323 The Unix timestamp (in seconds) for when the vector store files batch was created.
3324
3325 - `file_counts: FileCounts`
3326
3327 - `cancelled: int`
3328
3329 The number of files that where cancelled.
3330
3331 - `completed: int`
3332
3333 The number of files that have been processed.
3334
3335 - `failed: int`
3336
3337 The number of files that have failed to process.
3338
3339 - `in_progress: int`
3340
3341 The number of files that are currently being processed.
3342
3343 - `total: int`
3344
3345 The total number of files.
3346
3347 - `object: Literal["vector_store.files_batch"]`
3348
3349 The object type, which is always `vector_store.file_batch`.
3350
3351 - `"vector_store.files_batch"`
3352
3353 - `status: Literal["in_progress", "completed", "cancelled", "failed"]`
3354
3355 The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`.
3356
3357 - `"in_progress"`
3358
3359 - `"completed"`
3360
3361 - `"cancelled"`
3362
3363 - `"failed"`
3364
3365 - `vector_store_id: str`
3366
3367 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) that the [File](https://platform.openai.com/docs/api-reference/files) is attached to.