Skip to main content

files

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

Overview​

Namefiles
TypeResource
Idopenai.files.files

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe file identifier, which can be referenced in the API endpoints.
bytesintegerThe size of the file, in bytes.
created_atinteger (unixtime)The Unix timestamp (in seconds) for when the file was created.
expires_atinteger (unixtime)The Unix timestamp (in seconds) for when the file will expire.
filenamestringThe name of the file.
objectstringThe object type, which is always file. (file)
purposestringThe intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data. (assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, user_data)
statusstringDeprecated. The current status of the file, which can be either uploaded, processed, or error. (uploaded, processed, error)
status_detailsstringDeprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectfile_idopenai-organization, openai-project
listselectpurpose, limit, order, after, openai-organization, openai-project
deletedeletefile_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 use for this request.
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.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000. 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.
purposestringOnly return files with the given purpose.

SELECT examples​

OK

SELECT
id,
bytes,
created_at,
expires_at,
filename,
object,
purpose,
status,
status_details
FROM openai.files.files
WHERE file_id = '{{ file_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

DELETE examples​

No description available.

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