List Files
GET/files
Returns a list of files that belong to the user, with cursor-based pagination.
Request
Query Parameters
A file_id cursor for pagination. Returns files listed after this one.
Possible values: >= 1 and <= 1000
Default value: 1000
The number of files to return. Must be between 1 and 1000.
Possible values: [asc, desc]
Default value: asc
Sort order by creation time. asc for ascending, desc for descending.
Possible values: [user_data]
Only return files with the given purpose. Only user_data is supported.
Responses
- 200
OK, returns a list of file object.
- application/json
- Schema
- Example (from schema)
- Example
Schema
Array [
]
Possible values: [list]
The object type, which is always list.
data
object[]
required
The list of file objects.
The file identifier, of the form file-api-..., which can be referenced in chat completion requests.
Possible values: [file]
The object type, which is always file.
The size of the file in bytes.
The Unix timestamp (in seconds) of when the file was created.
The name of the file.
Possible values: [user_data]
The intended purpose of the file.
The Unix timestamp (in seconds) of when the file expires. Only present when an expiration was set at upload time.
The ID of the first file in the list. Useful as a pagination cursor.
The ID of the last file in the list. Useful as a pagination cursor.
Whether there are more files beyond this page.
{
"object": "list",
"data": [
{
"id": "string",
"object": "file",
"bytes": 0,
"created_at": 0,
"filename": "string",
"purpose": "user_data",
"expires_at": 0
}
],
"first_id": "string",
"last_id": "string",
"has_more": true
}
{
"object": "list",
"data": [
{
"id": "file-api-0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"object": "file",
"bytes": 102400,
"created_at": 1700000000,
"filename": "image.jpg",
"purpose": "user_data"
}
],
"first_id": "file-api-0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"last_id": "file-api-0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"has_more": false
}