Vector Stores
List vector stores
vector_stores.list(**kwargs) -> CursorPage<VectorStore>
get /vector_stores
Returns a list of vector stores.
Parameters
-
after: StringA cursor for use in pagination.
afteris 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. -
before: StringA cursor for use in pagination.
beforeis 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. -
limit: IntegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: :asc | :descSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
:asc -
:desc
-
Returns
-
class VectorStoreA vector store is a collection of processed files can be used by the
file_searchtool.-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that were cancelled.
-
completed: IntegerThe number of files that have been successfully processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
last_active_at: IntegerThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
-
object: :vector_storeThe object type, which is always
vector_store.:vector_store
-
status: :expired | :in_progress | :completedThe status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
:expired -
:in_progress -
:completed
-
-
usage_bytes: IntegerThe total number of bytes used by the files in the vector store.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: IntegerThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.list
puts(page)
Response
{
"data": [
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"last_active_at": 0,
"metadata": {
"foo": "string"
},
"name": "name",
"object": "vector_store",
"status": "expired",
"usage_bytes": 0,
"expires_after": {
"anchor": "last_active_at",
"days": 1
},
"expires_at": 0
}
],
"first_id": "vs_abc123",
"has_more": false,
"last_id": "vs_abc456",
"object": "list"
}
Create vector store
vector_stores.create(**kwargs) -> VectorStore
post /vector_stores
Create a vector store.
Parameters
-
chunking_strategy: FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
class AutoFileChunkingStrategyParamThe default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: :autoAlways
auto.:auto
-
-
class StaticFileChunkingStrategyObjectParamCustomize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
-
description: StringA description for the vector store. Can be used to describe the vector store's purpose.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
file_ids: Array[String]A list of File IDs that the vector store should use. Useful for tools like
file_searchthat can access files. -
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
Returns
-
class VectorStoreA vector store is a collection of processed files can be used by the
file_searchtool.-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that were cancelled.
-
completed: IntegerThe number of files that have been successfully processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
last_active_at: IntegerThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
-
object: :vector_storeThe object type, which is always
vector_store.:vector_store
-
status: :expired | :in_progress | :completedThe status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
:expired -
:in_progress -
:completed
-
-
usage_bytes: IntegerThe total number of bytes used by the files in the vector store.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: IntegerThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store = openai.vector_stores.create
puts(vector_store)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"last_active_at": 0,
"metadata": {
"foo": "string"
},
"name": "name",
"object": "vector_store",
"status": "expired",
"usage_bytes": 0,
"expires_after": {
"anchor": "last_active_at",
"days": 1
},
"expires_at": 0
}
Retrieve vector store
vector_stores.retrieve(vector_store_id) -> VectorStore
get /vector_stores/{vector_store_id}
Retrieves a vector store.
Parameters
vector_store_id: String
Returns
-
class VectorStoreA vector store is a collection of processed files can be used by the
file_searchtool.-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that were cancelled.
-
completed: IntegerThe number of files that have been successfully processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
last_active_at: IntegerThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
-
object: :vector_storeThe object type, which is always
vector_store.:vector_store
-
status: :expired | :in_progress | :completedThe status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
:expired -
:in_progress -
:completed
-
-
usage_bytes: IntegerThe total number of bytes used by the files in the vector store.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: IntegerThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store = openai.vector_stores.retrieve("vector_store_id")
puts(vector_store)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"last_active_at": 0,
"metadata": {
"foo": "string"
},
"name": "name",
"object": "vector_store",
"status": "expired",
"usage_bytes": 0,
"expires_after": {
"anchor": "last_active_at",
"days": 1
},
"expires_at": 0
}
Modify vector store
vector_stores.update(vector_store_id, **kwargs) -> VectorStore
post /vector_stores/{vector_store_id}
Modifies a vector store.
Parameters
-
vector_store_id: String -
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
Returns
-
class VectorStoreA vector store is a collection of processed files can be used by the
file_searchtool.-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that were cancelled.
-
completed: IntegerThe number of files that have been successfully processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
last_active_at: IntegerThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
-
object: :vector_storeThe object type, which is always
vector_store.:vector_store
-
status: :expired | :in_progress | :completedThe status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
:expired -
:in_progress -
:completed
-
-
usage_bytes: IntegerThe total number of bytes used by the files in the vector store.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: IntegerThe Unix timestamp (in seconds) for when the vector store will expire.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store = openai.vector_stores.update("vector_store_id")
puts(vector_store)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"last_active_at": 0,
"metadata": {
"foo": "string"
},
"name": "name",
"object": "vector_store",
"status": "expired",
"usage_bytes": 0,
"expires_after": {
"anchor": "last_active_at",
"days": 1
},
"expires_at": 0
}
Delete vector store
vector_stores.delete(vector_store_id) -> VectorStoreDeleted
delete /vector_stores/{vector_store_id}
Delete a vector store.
Parameters
vector_store_id: String
Returns
-
class VectorStoreDeleted-
id: String -
deleted: bool -
object: :"vector_store.deleted":"vector_store.deleted"
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_deleted = openai.vector_stores.delete("vector_store_id")
puts(vector_store_deleted)
Response
{
"id": "id",
"deleted": true,
"object": "vector_store.deleted"
}
Search vector store
vector_stores.search(vector_store_id, **kwargs) -> Page<VectorStoreSearchResponse>
post /vector_stores/{vector_store_id}/search
Search a vector store for relevant chunks based on a query and file attributes filter.
Parameters
-
vector_store_id: String -
query: String | Array[String]A query string for a search
-
String = String -
UnionMember1 = Array[String]
-
-
filters: ComparisonFilter | CompoundFilterA filter to apply based on file attributes.
-
class ComparisonFilterA filter used to compare a specified attribute key to a given value using a defined comparison operation.
-
key: StringThe key to compare against the value.
-
type: :eq | :ne | :gt | 5 moreSpecifies the comparison operator:
eq,ne,gt,gte,lt,lte,in,nin.-
eq: equals -
ne: not equal -
gt: greater than -
gte: greater than or equal -
lt: less than -
lte: less than or equal -
in: in -
nin: not in -
:eq -
:ne -
:gt -
:gte -
:lt -
:lte -
:in -
:nin
-
-
value: String | Float | bool | Array[String | Float]The value to compare against the attribute key; supports string, number, or boolean types.
-
String = String -
Float = Float -
UnionMember2 = bool -
UnionMember3 = Array[String | Float]-
String = String -
Float = Float
-
-
-
-
class CompoundFilterCombine multiple filters using
andoror.-
filters: Array[ComparisonFilter | untyped]Array of filters to combine. Items can be
ComparisonFilterorCompoundFilter.-
class ComparisonFilterA filter used to compare a specified attribute key to a given value using a defined comparison operation.
-
UnionMember1 = untyped
-
-
type: :and | :orType of operation:
andoror.-
:and -
:or
-
-
-
-
max_num_results: IntegerThe maximum number of results to return. This number should be between 1 and 50 inclusive.
-
ranking_options: RankingOptions{ ranker, score_threshold}Ranking options for search.
-
ranker: :none | :auto | :"default-2024-11-15"Enable re-ranking; set to
noneto disable, which can help reduce latency.-
:none -
:auto -
:"default-2024-11-15"
-
-
score_threshold: Float
-
-
rewrite_query: boolWhether to rewrite the natural language query for vector search.
Returns
-
class VectorStoreSearchResponse-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
content: Array[Content{ text, type}]Content chunks from the file.
-
text: StringThe text content returned from search.
-
type: :textThe type of content.
:text
-
-
file_id: StringThe ID of the vector store file.
-
filename: StringThe name of the vector store file.
-
score: FloatThe similarity score for the result.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.search("vs_abc123", query: "string")
puts(page)
Response
{
"data": [
{
"attributes": {
"foo": "string"
},
"content": [
{
"text": "text",
"type": "text"
}
],
"file_id": "file_id",
"filename": "filename",
"score": 0
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.search_results.page",
"search_query": [
"string"
]
}
Domain Types
Auto File Chunking Strategy Param
-
class AutoFileChunkingStrategyParamThe default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: :autoAlways
auto.:auto
-
File Chunking Strategy
-
FileChunkingStrategy = StaticFileChunkingStrategyObject | OtherFileChunkingStrategyObjectThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
File Chunking Strategy Param
-
FileChunkingStrategyParam = AutoFileChunkingStrategyParam | StaticFileChunkingStrategyObjectParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
class AutoFileChunkingStrategyParamThe default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: :autoAlways
auto.:auto
-
-
class StaticFileChunkingStrategyObjectParamCustomize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
Other File Chunking Strategy Object
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
Static File Chunking Strategy
-
class StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
Static File Chunking Strategy Object
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
Static File Chunking Strategy Object Param
-
class StaticFileChunkingStrategyObjectParamCustomize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
Vector Store
-
class VectorStoreA vector store is a collection of processed files can be used by the
file_searchtool.-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that were cancelled.
-
completed: IntegerThe number of files that have been successfully processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
last_active_at: IntegerThe Unix timestamp (in seconds) for when the vector store was last active.
-
metadata: MetadataSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
-
name: StringThe name of the vector store.
-
object: :vector_storeThe object type, which is always
vector_store.:vector_store
-
status: :expired | :in_progress | :completedThe status of the vector store, which can be either
expired,in_progress, orcompleted. A status ofcompletedindicates that the vector store is ready for use.-
:expired -
:in_progress -
:completed
-
-
usage_bytes: IntegerThe total number of bytes used by the files in the vector store.
-
expires_after: ExpiresAfter{ anchor, days}The expiration policy for a vector store.
-
anchor: :last_active_atAnchor timestamp after which the expiration policy applies. Supported anchors:
last_active_at.:last_active_at
-
days: IntegerThe number of days after the anchor time that the vector store will expire.
-
-
expires_at: IntegerThe Unix timestamp (in seconds) for when the vector store will expire.
-
Vector Store Deleted
-
class VectorStoreDeleted-
id: String -
deleted: bool -
object: :"vector_store.deleted":"vector_store.deleted"
-
Vector Store Search Response
-
class VectorStoreSearchResponse-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
content: Array[Content{ text, type}]Content chunks from the file.
-
text: StringThe text content returned from search.
-
type: :textThe type of content.
:text
-
-
file_id: StringThe ID of the vector store file.
-
filename: StringThe name of the vector store file.
-
score: FloatThe similarity score for the result.
-
Files
List vector store files
vector_stores.files.list(vector_store_id, **kwargs) -> CursorPage<VectorStoreFile>
get /vector_stores/{vector_store_id}/files
Returns a list of vector store files.
Parameters
-
vector_store_id: String -
after: StringA cursor for use in pagination.
afteris 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. -
before: StringA cursor for use in pagination.
beforeis 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. -
filter: :in_progress | :completed | :failed | :cancelledFilter by file status. One of
in_progress,completed,failed,cancelled.-
:in_progress -
:completed -
:failed -
:cancelled
-
-
limit: IntegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: :asc | :descSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
:asc -
:desc
-
Returns
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.files.list("vector_store_id")
puts(page)
Response
{
"data": [
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
],
"first_id": "file-abc123",
"has_more": false,
"last_id": "file-abc456",
"object": "list"
}
Create vector store file
vector_stores.files.create(vector_store_id, **kwargs) -> VectorStoreFile
post /vector_stores/{vector_store_id}/files
Create a vector store file by attaching a File to a vector store.
Parameters
-
vector_store_id: String -
file_id: StringA File ID that the vector store should use. Useful for tools like
file_searchthat can access files. For multi-file ingestion, we recommendfile_batchesto minimize per-vector-store write requests. -
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
class AutoFileChunkingStrategyParamThe default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: :autoAlways
auto.:auto
-
-
class StaticFileChunkingStrategyObjectParamCustomize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
Returns
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file = openai.vector_stores.files.create("vs_abc123", file_id: "file_id")
puts(vector_store_file)
Response
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
Update vector store file attributes
vector_stores.files.update(file_id, **kwargs) -> VectorStoreFile
post /vector_stores/{vector_store_id}/files/{file_id}
Update attributes on a vector store file.
Parameters
-
vector_store_id: String -
file_id: String -
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
Returns
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file = openai.vector_stores.files.update(
"file-abc123",
vector_store_id: "vs_abc123",
attributes: {foo: "string"}
)
puts(vector_store_file)
Response
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
Retrieve vector store file
vector_stores.files.retrieve(file_id, **kwargs) -> VectorStoreFile
get /vector_stores/{vector_store_id}/files/{file_id}
Retrieves a vector store file.
Parameters
-
vector_store_id: String -
file_id: String
Returns
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file = openai.vector_stores.files.retrieve("file-abc123", vector_store_id: "vs_abc123")
puts(vector_store_file)
Response
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
Delete vector store file
vector_stores.files.delete(file_id, **kwargs) -> VectorStoreFileDeleted
delete /vector_stores/{vector_store_id}/files/{file_id}
Delete 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 endpoint.
Parameters
-
vector_store_id: String -
file_id: String
Returns
-
class VectorStoreFileDeleted-
id: String -
deleted: bool -
object: :"vector_store.file.deleted":"vector_store.file.deleted"
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file_deleted = openai.vector_stores.files.delete("file_id", vector_store_id: "vector_store_id")
puts(vector_store_file_deleted)
Response
{
"id": "id",
"deleted": true,
"object": "vector_store.file.deleted"
}
Retrieve vector store file content
vector_stores.files.content(file_id, **kwargs) -> Page<FileContentResponse>
get /vector_stores/{vector_store_id}/files/{file_id}/content
Retrieve the parsed contents of a vector store file.
Parameters
-
vector_store_id: String -
file_id: String
Returns
-
class FileContentResponse-
text: StringThe text content
-
type: StringThe content type (currently only
"text")
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.files.content("file-abc123", vector_store_id: "vs_abc123")
puts(page)
Response
{
"data": [
{
"text": "text",
"type": "type"
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.file_content.page"
}
Domain Types
Vector Store File
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Vector Store File Deleted
-
class VectorStoreFileDeleted-
id: String -
deleted: bool -
object: :"vector_store.file.deleted":"vector_store.file.deleted"
-
File Content Response
-
class FileContentResponse-
text: StringThe text content
-
type: StringThe content type (currently only
"text")
-
File Batches
Create vector store file batch
vector_stores.file_batches.create(vector_store_id, **kwargs) -> VectorStoreFileBatch
post /vector_stores/{vector_store_id}/file_batches
Create a vector store file batch.
Parameters
-
vector_store_id: String -
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.-
class AutoFileChunkingStrategyParamThe default strategy. This strategy currently uses a
max_chunk_size_tokensof800andchunk_overlap_tokensof400.-
type: :autoAlways
auto.:auto
-
-
class StaticFileChunkingStrategyObjectParamCustomize your own chunking strategy by setting chunk size and chunk overlap.
-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
-
file_ids: Array[String]A list of File IDs that the vector store should use. Useful for tools like
file_searchthat can access files. Ifattributesorchunking_strategyare 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 withfiles. -
files: Array[File{ file_id, attributes, chunking_strategy}]A list of objects that each include a
file_idplus optionalattributesorchunking_strategy. Use this when you need to override metadata for specific files. The globalattributesorchunking_strategywill 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 withfile_ids.-
file_id: StringA File ID that the vector store should use. Useful for tools like
file_searchthat can access files. For multi-file ingestion, we recommendfile_batchesto minimize per-vector-store write requests. -
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyParamThe chunking strategy used to chunk the file(s). If not set, will use the
autostrategy. Only applicable iffile_idsis non-empty.
-
Returns
-
class VectorStoreFileBatchA batch of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that where cancelled.
-
completed: IntegerThe number of files that have been processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
object: :"vector_store.files_batch"The object type, which is always
vector_store.file_batch.:"vector_store.files_batch"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file_batch = openai.vector_stores.file_batches.create("vs_abc123")
puts(vector_store_file_batch)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
Retrieve vector store file batch
vector_stores.file_batches.retrieve(batch_id, **kwargs) -> VectorStoreFileBatch
get /vector_stores/{vector_store_id}/file_batches/{batch_id}
Retrieves a vector store file batch.
Parameters
-
vector_store_id: String -
batch_id: String
Returns
-
class VectorStoreFileBatchA batch of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that where cancelled.
-
completed: IntegerThe number of files that have been processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
object: :"vector_store.files_batch"The object type, which is always
vector_store.file_batch.:"vector_store.files_batch"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file_batch = openai.vector_stores.file_batches.retrieve("vsfb_abc123", vector_store_id: "vs_abc123")
puts(vector_store_file_batch)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
Cancel vector store file batch
vector_stores.file_batches.cancel(batch_id, **kwargs) -> VectorStoreFileBatch
post /vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel
Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.
Parameters
-
vector_store_id: String -
batch_id: String
Returns
-
class VectorStoreFileBatchA batch of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that where cancelled.
-
completed: IntegerThe number of files that have been processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
object: :"vector_store.files_batch"The object type, which is always
vector_store.file_batch.:"vector_store.files_batch"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
vector_store_file_batch = openai.vector_stores.file_batches.cancel("batch_id", vector_store_id: "vector_store_id")
puts(vector_store_file_batch)
Response
{
"id": "id",
"created_at": 0,
"file_counts": {
"cancelled": 0,
"completed": 0,
"failed": 0,
"in_progress": 0,
"total": 0
},
"object": "vector_store.files_batch",
"status": "in_progress",
"vector_store_id": "vector_store_id"
}
List vector store files in a batch
vector_stores.file_batches.list_files(batch_id, **kwargs) -> CursorPage<VectorStoreFile>
get /vector_stores/{vector_store_id}/file_batches/{batch_id}/files
Returns a list of vector store files in a batch.
Parameters
-
vector_store_id: String -
batch_id: String -
after: StringA cursor for use in pagination.
afteris 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. -
before: StringA cursor for use in pagination.
beforeis 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. -
filter: :in_progress | :completed | :failed | :cancelledFilter by file status. One of
in_progress,completed,failed,cancelled.-
:in_progress -
:completed -
:failed -
:cancelled
-
-
limit: IntegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
-
order: :asc | :descSort order by the
created_attimestamp of the objects.ascfor ascending order anddescfor descending order.-
:asc -
:desc
-
Returns
-
class VectorStoreFileA list of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store file was created.
-
last_error: LastError{ code, message}The last error associated with this vector store file. Will be
nullif there are no errors.-
code: :server_error | :unsupported_file | :invalid_fileOne of
server_error,unsupported_file, orinvalid_file.-
:server_error -
:unsupported_file -
:invalid_file
-
-
message: StringA human-readable description of the error.
-
-
object: :"vector_store.file"The object type, which is always
vector_store.file.:"vector_store.file"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store file, which can be either
in_progress,completed,cancelled, orfailed. The statuscompletedindicates that the vector store file is ready for use.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
usage_bytes: IntegerThe total vector store usage in bytes. Note that this may be different from the original file size.
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-
attributes: Hash[Symbol, String | Float | bool]Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.
-
String = String -
Float = Float -
UnionMember2 = bool
-
-
chunking_strategy: FileChunkingStrategyThe strategy used to chunk the file.
-
class StaticFileChunkingStrategyObject-
static: StaticFileChunkingStrategy-
chunk_overlap_tokens: IntegerThe number of tokens that overlap between chunks. The default value is
400.Note that the overlap must not exceed half of
max_chunk_size_tokens. -
max_chunk_size_tokens: IntegerThe maximum number of tokens in each chunk. The default value is
800. The minimum value is100and the maximum value is4096.
-
-
type: :staticAlways
static.:static
-
-
class OtherFileChunkingStrategyObjectThis is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the
chunking_strategyconcept was introduced in the API.-
type: :otherAlways
other.:other
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.file_batches.list_files("batch_id", vector_store_id: "vector_store_id")
puts(page)
Response
{
"data": [
{
"id": "id",
"created_at": 0,
"last_error": {
"code": "server_error",
"message": "message"
},
"object": "vector_store.file",
"status": "in_progress",
"usage_bytes": 0,
"vector_store_id": "vector_store_id",
"attributes": {
"foo": "string"
},
"chunking_strategy": {
"static": {
"chunk_overlap_tokens": 0,
"max_chunk_size_tokens": 100
},
"type": "static"
}
}
],
"first_id": "file-abc123",
"has_more": false,
"last_id": "file-abc456",
"object": "list"
}
Domain Types
Vector Store File Batch
-
class VectorStoreFileBatchA batch of files attached to a vector store.
-
id: StringThe identifier, which can be referenced in API endpoints.
-
created_at: IntegerThe Unix timestamp (in seconds) for when the vector store files batch was created.
-
file_counts: FileCounts{ cancelled, completed, failed, 2 more}-
cancelled: IntegerThe number of files that where cancelled.
-
completed: IntegerThe number of files that have been processed.
-
failed: IntegerThe number of files that have failed to process.
-
in_progress: IntegerThe number of files that are currently being processed.
-
total: IntegerThe total number of files.
-
-
object: :"vector_store.files_batch"The object type, which is always
vector_store.file_batch.:"vector_store.files_batch"
-
status: :in_progress | :completed | :cancelled | :failedThe status of the vector store files batch, which can be either
in_progress,completed,cancelledorfailed.-
:in_progress -
:completed -
:cancelled -
:failed
-
-
vector_store_id: StringThe ID of the vector store that the File is attached to.
-