Skip to main content

files

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

Overview

Namefiles
TypeResource
Idopenai.containers.files

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringUnique identifier for the file.
container_idstringThe container this file belongs to.
bytesintegerSize of the file in bytes.
created_atinteger (unixtime)Unix timestamp (in seconds) when the file was created.
objectstringThe type of this object (container.file).
pathstringPath of the file in the container.
sourcestringSource of the file (e.g., user, assistant).

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectcontainer_id, file_idopenai-organization, openai-projectRetrieves a container file.
listselectcontainer_idlimit, order, after, openai-organization, openai-projectLists container files.
createinsertcontainer_idopenai-organization, openai-projectCreates a container file.
deletedeletecontainer_id, file_idopenai-organization, openai-projectDelete a container file.

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
container_idstring
file_idstring
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 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

Retrieves a container file.

SELECT
id,
container_id,
bytes,
created_at,
object,
path,
source
FROM openai.containers.files
WHERE container_id = '{{ container_id }}' -- required
AND file_id = '{{ file_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

INSERT examples

Creates a container file.

INSERT INTO openai.containers.files (
file_id,
container_id,
"openai-organization",
"openai-project"
)
SELECT
'{{ file_id }}',
'{{ container_id }}',
'{{ openai-organization }}',
'{{ openai-project }}'
RETURNING
id,
container_id,
bytes,
created_at,
object,
path,
source
;

DELETE examples

Delete a container file.

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