Skip to main content

files

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

Overview

Namefiles
TypeResource
Idopenai.vector_stores.files

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.
attributesobjectSet 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. (x-oaiTypeLabel: map)
chunking_strategyobjectThe strategy used to chunk the file. (title: Static Chunking Strategy)
created_atinteger (unixtime)The Unix timestamp (in seconds) for when the vector store file was created.
last_errorobjectThe last error associated with this vector store file. Will be null if there are no errors.
objectstringThe object type, which is always vector_store.file. (vector_store.file)
statusstringThe 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. (in_progress, completed, cancelled, failed)
usage_bytesintegerThe total vector store usage in bytes. Note that this may be different from the original file size.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectvector_store_id, file_idopenai-organization, openai-project
listselectvector_store_idlimit, order, after, before, filter, openai-organization, openai-project
createinsertvector_store_id, file_idopenai-organization, openai-projectThis endpoint is subject to a per-vector-store write rate limit of 300 requests per minute, shared with /vector_stores/{vector_store_id}/file_batches.
For uploading multiple files to the same vector store, use the file batches endpoint to reduce request volume.
updateupdatevector_store_id, file_id, attributesopenai-organization, openai-project
deletedeletevector_store_id, file_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
file_idstringThe ID of the file to delete.
vector_store_idstringThe ID of the vector store that the file belongs to.
afterstringA 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.
beforestringA 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.
filterstringFilter by file status. One of in_progress, completed, failed, cancelled.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Automatically applied from a SQL LIMIT clause - SELECT ... LIMIT 10 sends limit=10 on the wire. Setting it explicitly in a WHERE clause is not required.
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.
orderstringSort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

SELECT examples

OK

SELECT
id,
vector_store_id,
attributes,
chunking_strategy,
created_at,
last_error,
object,
status,
usage_bytes
FROM openai.vector_stores.files
WHERE vector_store_id = '{{ vector_store_id }}' -- required
AND file_id = '{{ file_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

INSERT examples

This endpoint is subject to a per-vector-store write rate limit of 300 requests per minute, shared with /vector_stores/{vector_store_id}/file_batches.
For uploading multiple files to the same vector store, use the file batches endpoint to reduce request volume.

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

UPDATE examples

No description available.

UPDATE openai.vector_stores.files
SET
attributes = '{{ attributes }}'
WHERE
vector_store_id = '{{ vector_store_id }}' --required
AND file_id = '{{ file_id }}' --required
AND attributes = '{{ attributes }}' --required
AND "openai-organization" = '{{ openai-organization}}'
AND "openai-project" = '{{ openai-project}}'
RETURNING
id,
vector_store_id,
attributes,
chunking_strategy,
created_at,
last_error,
object,
status,
usage_bytes;

DELETE examples

No description available.

DELETE FROM openai.vector_stores.files
WHERE vector_store_id = '{{ vector_store_id }}' --required
AND file_id = '{{ file_id }}' --required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;