---
title: "Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). Please [contact us](https://help.openai.com/) if you need to increase these storage limits."
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/operations/createFile"
---

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

# Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. The Batch API only supports `.jsonl` files up to 200 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). Please [contact us](https://help.openai.com/) if you need to increase these storage limits.

`POST` `/files`

Operation ID: `createFile`

## Request body (required)

Content types: `multipart/form-data`

## 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:
    post:
      operationId: createFile
      tags:
        - Files
      summary: >
        Upload a file that can be used across various endpoints. Individual
        files can be up to 512 MB, and the size of all files uploaded by one
        organization can be up to 100 GB.


        The Assistants API supports files up to 2 million tokens and of specific
        file types. See the [Assistants Tools guide](/docs/assistants/tools) for
        details.


        The Fine-tuning API only supports `.jsonl` files. The input also has
        certain required formats for fine-tuning
        [chat](/docs/api-reference/fine-tuning/chat-input) or
        [completions](/docs/api-reference/fine-tuning/completions-input) models.


        The Batch API only supports `.jsonl` files up to 200 MB in size. The
        input also has a specific required
        [format](/docs/api-reference/batch/request-input).


        Please [contact us](https://help.openai.com/) if you need to increase
        these storage limits.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/CreateFileRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OpenAIFile"
      x-oaiMeta:
        name: Upload file
        group: files
        returns: The uploaded [File](/docs/api-reference/files/object) object.
        examples:
          request:
            curl: |
              curl https://api.openai.com/v1/files \
                -H "Authorization: Bearer $OPENAI_API_KEY" \
                -F purpose="fine-tune" \
                -F file="@mydata.jsonl"
            python: |
              from openai import OpenAI
              client = OpenAI()

              client.files.create(
                file=open("mydata.jsonl", "rb"),
                purpose="fine-tune"
              )
            node.js: |-
              import fs from "fs";
              import OpenAI from "openai";

              const openai = new OpenAI();

              async function main() {
                const file = await openai.files.create({
                  file: fs.createReadStream("mydata.jsonl"),
                  purpose: "fine-tune",
                });

                console.log(file);
              }

              main();
          response: |
            {
              "id": "file-abc123",
              "object": "file",
              "bytes": 120000,
              "created_at": 1677610602,
              "filename": "mydata.jsonl",
              "purpose": "fine-tune",
            }
security:
  - ApiKeyAuth: []
components:
  schemas:
    CreateFileRequest:
      type: object
      additionalProperties: false
      properties:
        file:
          description: |
            The File object (not file name) to be uploaded.
          type: string
          format: binary
        purpose:
          description: >
            The intended purpose of the uploaded file.


            Use "assistants" for [Assistants](/docs/api-reference/assistants)
            and [Message](/docs/api-reference/messages) files, "vision" for
            Assistants image file inputs, "batch" for [Batch
            API](/docs/guides/batch), and "fine-tune" for
            [Fine-tuning](/docs/api-reference/fine-tuning).
          type: string
          enum:
            - assistants
            - batch
            - fine-tune
            - vision
      required:
        - file
        - purpose
    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
```
