---
title: "Returns a list of files."
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/operations/listFiles"
---

> Full API specification: https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1.md

# Returns a list of files.

`GET` `/files`

Operation ID: `listFiles`

## Query parameters

- `purpose` (string, optional) - Only return files with the given purpose.
- `limit` (integer, optional) - 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) - 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.

## Responses

- `200` - OK

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
paths:
  /files:
    get:
      operationId: listFiles
      tags:
        - Files
      summary: Returns a list of files.
      parameters:
        - in: query
          name: purpose
          required: false
          schema:
            type: string
          description: Only return files with the given purpose.
        - name: limit
          in: query
          description: >
            A limit on the number of objects to be returned. Limit can range
            between 1 and 10,000, and the default is 10,000.
          required: false
          schema:
            type: integer
            default: 10000
        - name: order
          in: query
          description: >
            Sort order by the `created_at` timestamp of the objects. `asc` for
            ascending order and `desc` for descending order.
          schema:
            type: string
            default: desc
            enum:
              - asc
              - desc
        - name: after
          in: query
          description: >
            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.
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ListFilesResponse"
      x-oaiMeta:
        name: List files
        group: files
        returns: A list of [File](/docs/api-reference/files/object) objects.
        examples:
          request:
            curl: |
              curl https://api.openai.com/v1/files \
                -H "Authorization: Bearer $OPENAI_API_KEY"
            python: |
              from openai import OpenAI
              client = OpenAI()

              client.files.list()
            node.js: |-
              import OpenAI from "openai";

              const openai = new OpenAI();

              async function main() {
                const list = await openai.files.list();

                for await (const file of list) {
                  console.log(file);
                }
              }

              main();
          response: |
            {
              "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"
            }
security:
  - ApiKeyAuth: []
components:
  schemas:
    ListFilesResponse:
      type: object
      properties:
        object:
          type: string
          example: list
        data:
          type: array
          items:
            $ref: "#/components/schemas/OpenAIFile"
        first_id:
          type: string
          example: file-abc123
        last_id:
          type: string
          example: file-abc456
        has_more:
          type: boolean
          example: false
      required:
        - object
        - data
        - first_id
        - last_id
        - has_more
    OpenAIFile:
      title: OpenAIFile
      description: The `File` object represents a document that has been uploaded to OpenAI.
      properties:
        id:
          type: string
          description: The file identifier, which can be referenced in the API endpoints.
        bytes:
          type: integer
          description: The size of the file, in bytes.
        created_at:
          type: integer
          description: The Unix timestamp (in seconds) for when the file was created.
        filename:
          type: string
          description: The name of the file.
        object:
          type: string
          description: The object type, which is always `file`.
          enum:
            - file
          x-stainless-const: true
        purpose:
          type: string
          description: The intended purpose of the file. Supported values are
            `assistants`, `assistants_output`, `batch`, `batch_output`,
            `fine-tune`, `fine-tune-results` and `vision`.
          enum:
            - assistants
            - assistants_output
            - batch
            - batch_output
            - fine-tune
            - fine-tune-results
            - vision
        status:
          type: string
          deprecated: true
          description: Deprecated. The current status of the file, which can be either
            `uploaded`, `processed`, or `error`.
          enum:
            - uploaded
            - processed
            - error
        status_details:
          type: string
          deprecated: true
          description: Deprecated. For details on why a fine-tuning training file failed
            validation, see the `error` field on `fine_tuning.job`.
      required:
        - id
        - object
        - bytes
        - created_at
        - filename
        - purpose
        - status
      x-oaiMeta:
        name: The file object
        example: |
          {
            "id": "file-abc123",
            "object": "file",
            "bytes": 120000,
            "created_at": 1677610602,
            "filename": "salesOverview.pdf",
            "purpose": "assistants",
          }
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
```
