API ResourcesFiles

Files

The Files API is the bridge for interacting with other OpenAI features, allowing you to securely upload documents and use them for various tasks. After uploading files, you can pass them to the Assistants API for retrieval or use them for Fine-tuning to customize models.


POST/beta/v1/files

Upload File

Upload a file that can be used across different endpoints. Individual files can be up to 50 MB, and the total size limit for all files in a team/enterprise subscription is 50 GB. Contact us to increase storage limits.

Request Headers

  • Name
    Content-Type
    Type
    string
    Required
    Required
    Description
    Value must be multipart/form-data.
  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Credentials for API authentication. See Authentication for details.
  • anthropic-version

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Pass your API key directly. Note: Do not use both Authorization and x-api-key simultaneously.
  • Name
    anthropic-version
    Type
    string
    Required
    Required
    Description
    Required when using x-api-key authentication. Specifies the API version to request, compatible with Anthropic's version control. Currently only 2023-06-01 is allowed.

Request Body

  • Name
    file
    Type
    file
    Required
    Required
    Description
    The file object to upload (not the filename).
  • Name
    purpose
    Type
    string
    Required
    Required
    Description
    The intended use of the uploaded file. Options include:
    • assistants:用于助手 API / for Assistants API
    • batch:用于批处理API / for Batch API
    • fine-tune:用于模型微调 / for model fine-tuning
  • Name
    expires_after
    Type
    object
    Optional
    Optional
    Description
    File expiration policy. By default, files expire after 30 days.

Response Body (OpenAI Format)

When using Authorization for authentication, the response body is in OpenAI format.

  • Name
    object
    Type
    string
    Required
    Required
    Description
    Object type, always file.
  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file, typically prefixed with file-.
  • Name
    bytes
    Type
    integer
    Required
    Required
    Description
    Total size of the file in bytes.
  • Name
    created_at
    Type
    integer
    Required
    Required
    Description
    Unix timestamp of when the file was created.
  • Name
    expires_at
    Type
    integer
    Required
    Required
    Description
    Unix timestamp of when the file expires.
  • Name
    filename
    Type
    string
    Required
    Required
    Description
    Original filename used during upload.
  • Name
    purpose
    Type
    string
    Required
    Required
    Description
    Intended use of the file, such as assistants or vision.

Response Body (Anthropic Format)

When using x-api-key for authentication, the response body is in Anthropic format.

  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file.
  • Name
    type
    Type
    string
    Required
    Required
    Description
    Object type, always file.
  • Name
    filename
    Type
    string
    Required
    Required
    Description
    Original filename used during upload.
  • Name
    created_at
    Type
    string
    Required
    Required
    Description
    File creation time in RFC 3339 format string.
  • Name
    mime_type
    Type
    string
    Required
    Required
    Description
    MIME type of the file, e.g., application/pdf.
  • Name
    size_bytes
    Type
    integer
    Required
    Required
    Description
    Total size of the file in bytes.
  • Name
    downloadable
    Type
    boolean
    Required
    Required
    Description
    Indicates whether the file is currently available for download.

Request

POST
/beta/v1/files
curl 'https://api.easytransnote.com/beta/v1/files' \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -F purpose="assistants" \
  -F file="@mydata.pdf"
  -F expires_after[anchor]="created_at"
  -F expires_after[seconds]=3600

Response

{
    "id": "file-abc123",
    "object": "file",
    "bytes": 12000,
    "created_at": 1756260550,
    "expires_at": 1756264150,
    "filename": "mydata.pdf",
    "purpose": "assistants",
}

GET/beta/v1/files

List Files

List files uploaded by the current user.

Request Headers

  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Credentials for API authentication. See Authentication for details.
  • anthropic-version

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Pass your API key directly. Note: Do not use both Authorization and x-api-key simultaneously.
  • Name
    anthropic-version
    Type
    string
    Required
    Required
    Description
    Required when using x-api-key authentication. Specifies the API version to request, compatible with Anthropic's version control. Currently only 2023-06-01 is allowed.

Query Parameters (OpenAI Format)

When using Authorization for authentication, the server expects a set of OpenAI-format query parameters.

  • Name
    after
    Type
    string
    Optional
    Optional
    Description
    Cursor for pagination. The after parameter is an object ID used to define your position in the list. For example, if you make a list request and receive 100 objects, and the last object's ID is obj_foo, you can get the next page by setting after = obj_foo.
  • Name
    limit
    Type
    integer
    Optional
    Optional
    Description
    Limit on the number of objects to return. Range is 1 to 10,000, with a default of 10,000.
  • Name
    order
    Type
    string
    Optional
    Optional
    Description
    Sort by the created_at timestamp of objects. asc for ascending order, desc for descending order. Default is desc.
  • Name
    purpose
    Type
    string
    Optional
    Optional
    Description
    Return only files with the specified purpose.

Query Parameters (Anthropic Format)

When using x-api-key for authentication, the server expects a set of Anthropic-format query parameters.

  • Name
    before_id
    Type
    string
    Optional
    Optional
    Description
    Object ID for pagination. When provided, returns the page of results immediately before this object.
  • Name
    after_id
    Type
    string
    Optional
    Optional
    Description
    Object ID for pagination. When provided, returns the page of results immediately after this object.
  • Name
    limit
    Type
    integer
    Optional
    Optional
    Description

    Number of items per page. 默认值为20。取值范围为1至1000。 / Default is 20. Range is 1 to 1000.

Response Body (OpenAI Format)

When using Authorization for authentication, the response body is in OpenAI format.

  • Name
    object
    Type
    string
    Required
    Required
    Description
    Object type, always list for list types.
  • Name
    data
    Type
    array
    Required
    Required
    Description
    List of file objects. Each object's structure in the array follows the single file response body format.
  • Name
    first_id
    Type
    string
    Required
    Required
    Description
    ID of the first file object in the current list.
  • Name
    last_id
    Type
    string
    Required
    Required
    Description
    ID of the last file object in the current list.
  • Name
    has_more
    Type
    boolean
    Required
    Required
    Description
    A boolean indicating whether there are more files available. If true, you can use pagination parameters to get the next page.

Response Body (Anthropic Format)

When using x-api-key for authentication, the response body is in Anthropic format.

  • Name
    data
    Type
    array
    Required
    Required
    Description
    List of file objects. Each object's structure in the array follows the single file response body format.
  • Name
    first_id
    Type
    string
    Required
    Required
    Description
    ID of the first file object in the current list.
  • Name
    last_id
    Type
    string
    Required
    Required
    Description
    ID of the last file object in the current list.
  • Name
    has_more
    Type
    boolean
    Required
    Required
    Description
    A boolean indicating whether there are more files available. If true, you can use pagination parameters to get the next page.

Request

GET
/beta/v1/files
curl 'https://api.easytransnote.com/beta/v1/files' \
  -H "Authorization: Bearer $YOUR_API_KEY"

Response

{
    "object": "list",
    "data": [
        {
        "id": "file-abc123",
        "object": "file",
        "bytes": 175,
        "created_at": 1613677385,
        "expires_at": 1677614202,
        "filename": "salesOverview.pdf",
        "purpose": "assistants",
        },
        {
        "id": "file-abc456",
        "object": "file",
        "bytes": 140,
        "created_at": 1613779121,
        "expires_at": 1677614202,
        "filename": "puppy.jsonl",
        "purpose": "fine-tune",
        }
    ],
    "first_id": "file-abc123",
    "last_id": "file-abc456",
    "has_more": false
}

GET/beta/v1/files/{file_id}

Retrieve File

Returns information about the specified file.

Request Headers

  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Credentials for API authentication. See Authentication for details.
  • anthropic-version

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Pass your API key directly. Note: Do not use both Authorization and x-api-key simultaneously.
  • Name
    anthropic-version
    Type
    string
    Required
    Required
    Description
    Required when using x-api-key authentication. Specifies the API version to request, compatible with Anthropic's version control. Currently only 2023-06-01 is allowed.

Path Parameters

  • Name
    file_id
    Type
    string
    Required
    Required
    Description
    The file ID for this request.

Response Body (OpenAI Format)

When using Authorization for authentication, the response body is in OpenAI format.

  • Name
    object
    Type
    string
    Required
    Required
    Description
    Object type, always file.
  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file, typically prefixed with file-.
  • Name
    bytes
    Type
    integer
    Required
    Required
    Description
    Total size of the file in bytes.
  • Name
    created_at
    Type
    integer
    Required
    Required
    Description
    Unix timestamp of when the file was created.
  • Name
    expires_at
    Type
    integer
    Required
    Required
    Description
    Unix timestamp of when the file expires.
  • Name
    filename
    Type
    string
    Required
    Required
    Description
    Original filename used during upload.
  • Name
    purpose
    Type
    string
    Required
    Required
    Description
    Intended use of the file, such as assistants or vision.

Response Body (Anthropic Format)

When using x-api-key for authentication, the response body is in Anthropic format.

  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file.
  • Name
    type
    Type
    string
    Required
    Required
    Description
    Object type, always file.
  • Name
    filename
    Type
    string
    Required
    Required
    Description
    Original filename used during upload.
  • Name
    created_at
    Type
    string
    Required
    Required
    Description
    File creation time in RFC 3339 format string.
  • Name
    mime_type
    Type
    string
    Required
    Required
    Description
    MIME type of the file, e.g., application/pdf.
  • Name
    size_bytes
    Type
    integer
    Required
    Required
    Description
    Total size of the file in bytes.
  • Name
    downloadable
    Type
    boolean
    Required
    Required
    Description
    Indicates whether the file is currently available for download.

Request

GET
/beta/v1/files/{file_id}
curl 'https://api.easytransnote.com/beta/v1/files/YOUR_FILE_ID' \
  -H "Authorization: Bearer $YOUR_API_KEY"

Response

{
    "id": "file-abc123",
    "object": "file",
    "bytes": 12000,
    "created_at": 1756260550,
    "expires_at": 1756264150,
    "filename": "mydata.pdf",
    "purpose": "assistants",
}

DELETE/beta/v1/files/{file_id}

Delete File

Delete an uploaded file.

Request Headers

  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Credentials for API authentication. See Authentication for details.
  • anthropic-version

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Pass your API key directly. Note: Do not use both Authorization and x-api-key simultaneously.
  • Name
    anthropic-version
    Type
    string
    Required
    Required
    Description
    Required when using x-api-key authentication. Specifies the API version to request, compatible with Anthropic's version control. Currently only 2023-06-01 is allowed.

Path Parameters

  • Name
    file_id
    Type
    string
    Required
    Required
    Description
    The file ID for this request.

Response Body (OpenAI Format)

When using Authorization for authentication, the response body is in OpenAI format.

  • Name
    object
    Type
    string
    Required
    Required
    Description
    Object type, always file.
  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file, typically prefixed with file-.
  • Name
    deleted
    Type
    boolean
    Required
    Required
    Description
    Whether the file was successfully deleted.

Response Body (Anthropic Format)

When using x-api-key for authentication, the response body is in Anthropic format.

  • Name
    id
    Type
    string
    Required
    Required
    Description
    Unique identifier for the file.
  • Name
    type
    Type
    string
    Required
    Required
    Description
    Operation type, always file_deleted.

Request

DELETE
/beta/v1/files/{file_id}
curl 'https://api.easytransnote.com/beta/v1/files/YOUR_FILE_ID' \
  -X DELETE \
  -H "Authorization: Bearer $YOUR_API_KEY"

Response

{
    "id": "file-abc123",
    "object": "file",
    "deleted": true
}

GET/beta/v1/files/{file_id}/content

Download File

Returns information about the specified file.

Request Headers

  • Name
    Authorization
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Credentials for API authentication. See Authentication for details.
  • anthropic-version

  • Name
    x-api-key
    Type
    string
    Optional
    Optional
    Description
    Optional authentication method. Pass your API key directly. Note: Do not use both Authorization and x-api-key simultaneously.
  • Name
    anthropic-version
    Type
    string
    Required
    Required
    Description
    Required when using x-api-key authentication. Specifies the API version to request, compatible with Anthropic's version control. Currently only 2023-06-01 is allowed.

Path Parameters

  • Name
    file_id
    Type
    string
    Required
    Required
    Description
    The file ID for this request.

Response Body

File content.

Request

GET
/beta/v1/files/{file_id}/content
curl -o downloaded_file.pdf \
  'https://api.easytransnote.com/beta/v1/files/YOUR_FILE_ID/content' \
  -H "Authorization: Bearer $YOUR_API_KEY"

Was this page helpful?