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