Skip to content

List files

GET https://api.fastapi.ai/v1/files

Returns a list of files.

Query parameters


purpose string Optional
Only return files with the given purpose.


limit integer Optional Defaults to 10000
A limit on the number of objects to be returned. Limit can range between 1 and 10,000, and the default is 10,000.


order string Optional Defaults to desc
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.


after string Optional
A 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.

Returns


A list of File objects.


The file object

The File object represents a document that has been uploaded to OpenAI.


id string
The file identifier, which can be referenced in the API endpoints.


bytes integer
The size of the file, in bytes.


created_at integer
The Unix timestamp (in seconds) for when the file was created.


expires_at integer
The Unix timestamp (in seconds) for when the file will expire.


filename string
The name of the file.


object string
The object type, which is always file.


purpose string
The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results and vision.


status Deprecated string
Deprecated. The current status of the file, which can be either uploaded, processed, or error.


status_details Deprecated string
Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job.


OBJECT The file object
bash
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 120000,
  "created_at": 1677610602,
  "expires_at": 1680202602,
  "filename": "salesOverview.pdf",
  "purpose": "assistants",
}

Example

Request

bash
curl https://api.fastapi.ai/v1/files \
  -H "Authorization: Bearer $FAST_API_KEY"

Response

bash
{
  "data": [
    {
      "id": "file-abc123",
      "object": "file",
      "bytes": 175,
      "created_at": 1613677385,
      "filename": "salesOverview.pdf",
      "purpose": "assistants",
    },
    {
      "id": "file-abc123",
      "object": "file",
      "bytes": 140,
      "created_at": 1613779121,
      "filename": "puppy.jsonl",
      "purpose": "fine-tune",
    }
  ],
  "object": "list"
}

那年我双手插兜, 让bug稳如老狗