Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex AI Studio
    • About Yandex AI Studio
    • Yandex Workflows
    • Quotas and limits
    • Terms and definitions
  • Compatibility with OpenAI
    • About Yandex Cloud ML SDK
      • Overview
        • Overview
        • Models domain
        • Assistants domain
        • Tools domain
        • Files domain
        • Threads domain
        • Runs domain
        • Search indexes domain
        • Search API domain
        • Datasets domain
        • Tuning domain
        • Batch domain
        • Chat domain
      • Authentication
      • Request retries
  • Access management
  • Pricing policy
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • class yandex_cloud_ml_sdk._files.domain.Files
  • class yandex_cloud_ml_sdk._files.file.File
  1. Yandex Cloud ML SDK
  2. SDK reference
  3. SDK
  4. Files domain

Files domain

Written by
Yandex Cloud
Updated at August 25, 2025
  • class yandex_cloud_ml_sdk._files.domain.Files
  • class yandex_cloud_ml_sdk._files.file.File

class yandexcloudmlsdk.files.domain.Filesclass yandex_cloud_ml_sdk._files.domain.Files

Files domain, which contains API for working with files.

Files is a part of Assistants API, which is the only place you could use it. Provides upload, get and list methods that allow you to work with remote file objects you created earlier.

upload_bytes(data, *, name=Undefined, description=Undefined, mime_type=Undefined, labels=Undefined, ttl_days=Undefined, expiration_policy=Undefined, timeout=60)

Uploads a byte array as a file.

Parameters

  • data (bytes) – The byte data to upload.
  • name (str | Undefined) – The name of the file on the server.
  • description (str | Undefined) – A description of the file.
  • mime_type (str | Undefined) – The MIME type of the file. By default (i.e. when UNDEFINED) the server will try to auto-detect mime-type and you could override this file.
  • labels (dict[str, str] | Undefined) – Labels associated with the file.
  • ttl_days (int | Undefined) – Time-to-live in days for the file.
  • expiration_policy (ExpirationPolicy | Literal[1, 2] | ~typing.Literal['STATIC', 'SINCE_LAST_ACTIVE'] | ~typing.Literal['static', 'since_last_active'] | ~yandex_cloud_ml_sdk._types.misc.Undefined) – Expiration policy for the file. Assepts for passing static or :since_last_active strings. Should be defined if ttl_days has been defined, otherwise both parameters should be undefined.
  • timeout (float) – Timeout for the operation in seconds. Defaults to 60 seconds.

Return type

File

upload(path, *, name=Undefined, description=Undefined, mime_type=Undefined, labels=Undefined, ttl_days=Undefined, expiration_policy=Undefined, timeout=60)

Uploads a file from a specified path.

Parameters

  • path (str | PathLike) – The path of the file to upload.
  • name (str | Undefined) – The name of the file on the server.
  • description (str | Undefined) – A description of the file.
  • mime_type (str | Undefined) – The MIME type of the file. By default (i.e. when UNDEFINED) the server will try to auto-detect mime-type and you could override this file.
  • labels (dict[str, str] | Undefined) – Labels associated with the file.
  • ttl_days (int | Undefined) – Time-to-live in days for the file.
  • expiration_policy (ExpirationPolicy | Literal[1, 2] | ~typing.Literal['STATIC', 'SINCE_LAST_ACTIVE'] | ~typing.Literal['static', 'since_last_active'] | ~yandex_cloud_ml_sdk._types.misc.Undefined) – Expiration policy for the file. Assepts for passing static or since_last_active strings.
  • timeout (float) – Timeout for the operation in seconds. Defaults to 60.

Return type

File

get(file_id, *, timeout=60)

Retrieves a file by its ID.

Parameters

  • file_id (str) – The unique identifier of the file to retrieve.
  • timeout (float) – Timeout for the operation in seconds. Defaults to 60.

Return type

File

list(*, page_size=Undefined, timeout=60)

Lists Files in the SDK folder.

Parameters

  • page_size (int | Undefined) – The maximum number of files to return per page.
  • timeout (float) – Timeout for the operation in seconds. Defaults to 60.

Return type

Iterator[File]

class yandexcloudmlsdk.files.file.Fileclass yandex_cloud_ml_sdk._files.file.File

get_url(*, timeout=60)

Retrieve the URL for the file.

This method constructs a request to get the temporary URL for downloading the file and returns it.

Parameters

timeout (float) – Timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds.

Returns

The URL of the file given as a string.

Return type

str

update(*, name=Undefined, description=Undefined, labels=Undefined, ttl_days=Undefined, expiration_policy=Undefined, timeout=60)

Update the properties of the file.

This method allows updating various properties of the file, such as its name, description, labels, TTL (time-to-live) days, and expiration policy. Note that only the fields explicitly passed will be updated. You can also pass None, which will reset it. Keep in mind that the method is mutating and modifies the file object in-place.

Parameters

  • name (str | Undefined) – The new name for the updated file.
  • description (str | Undefined) – The new description for the file.
  • labels (dict[str, str] | Undefined) – A dictionary of labels to associate with the file.
  • ttl_days (int | Undefined) – The new TTL (time-to-live) for the file in days.
  • expiration_policy (ExpirationPolicy | Literal[1, 2] | ~typing.Literal['STATIC', 'SINCE_LAST_ACTIVE'] | ~typing.Literal['static', 'since_last_active'] | ~yandex_cloud_ml_sdk._types.misc.Undefined) – The new expiration policy for the file. Assepts for passing static or since_last_active strings.
  • timeout (float) – Timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds.

Returns

The updated instance of the file.

Return type

File

delete(*, timeout=60)

Delete the file.

This method constructs and executes a request to delete the file associated with the current instance.

Parameters

timeout (float) – Timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds.

Return type

None

download_as_bytes(*, chunk_size=32768, timeout=60)

Download the file as bytes.

This method retrieves the file’s URL and streams the file’s content as whole (this may overflow the user’s memory), returning it as a byte string.

Parameters

  • chunk_size (int) – The size of each chunk to read from the stream in bytes.
  • timeout (float) – Timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds.

Returns

The file contents as bytes.

Return type

bytes

name: str | None

description: str | None

mime_type: str

created_by: str

created_at: datetime

updated_by: str

updated_at: datetime

expires_at: datetime

labels: dict[str, str] | None

expiration_config: ExpirationConfig

id: str

Was the article helpful?

Previous
Tools domain
Next
Threads domain
© 2025 Direct Cursus Technology L.L.C.