Skip to main content

file_batches

Creates, updates, deletes, gets or lists a file_batches resource.

Overview

Namefile_batches
TypeResource
Idopenai.vector_stores.file_batches

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints.
vector_store_idstringThe ID of the vector store that the File is attached to.
created_atinteger (unixtime)The Unix timestamp (in seconds) for when the vector store files batch was created.
file_countsobject
objectstringThe object type, which is always vector_store.file_batch. (vector_store.files_batch)
statusstringThe status of the vector store files batch, which can be either in_progress, completed, cancelled or failed. (in_progress, completed, cancelled, failed)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectvector_store_id, batch_idopenai-organization, openai-project
createinsertvector_store_id, file_ids, filesopenai-organization, openai-projectThe maximum number of files in a single batch request is 2000.
Vector store file attach requests are rate limited per vector store (300 requests per minute across both this endpoint and /vector_stores/{vector_store_id}/files).
For ingesting multiple files into the same vector store, this batch endpoint is recommended.
cancelexecvector_store_id, batch_idopenai-organization, openai-project

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
batch_idstringThe ID of the file batch to cancel.
vector_store_idstringThe ID of the vector store that the file batch belongs to.
openai-organizationstringOptionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as openai_organization.
openai-projectstringOptionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as openai_project.

SELECT examples

OK

SELECT
id,
vector_store_id,
created_at,
file_counts,
object,
status
FROM openai.vector_stores.file_batches
WHERE vector_store_id = '{{ vector_store_id }}' -- required
AND batch_id = '{{ batch_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

INSERT examples

The maximum number of files in a single batch request is 2000.
Vector store file attach requests are rate limited per vector store (300 requests per minute across both this endpoint and /vector_stores/{vector_store_id}/files).
For ingesting multiple files into the same vector store, this batch endpoint is recommended.

INSERT INTO openai.vector_stores.file_batches (
file_ids,
files,
chunking_strategy,
attributes,
vector_store_id,
"openai-organization",
"openai-project"
)
SELECT
'{{ file_ids }}' /* required */,
'{{ files }}' /* required */,
'{{ chunking_strategy }}',
'{{ attributes }}',
'{{ vector_store_id }}',
'{{ openai-organization }}',
'{{ openai-project }}'
RETURNING
id,
vector_store_id,
created_at,
file_counts,
object,
status
;

Lifecycle Methods

OK

EXEC openai.vector_stores.file_batches.cancel
@vector_store_id='{{ vector_store_id }}' --required,
@batch_id='{{ batch_id }}' --required,
@openai-organization='{{ openai-organization }}',
@openai-project='{{ openai-project }}'
;