Yandex Cloud
Поиск
Связаться с намиПодключиться
  • Истории успеха
  • Документация
  • Блог
  • Все сервисы
  • Статус работы сервисов
    • Доступны в регионе
    • Инфраструктура и сеть
    • Платформа данных
    • Контейнеры
    • Инструменты разработчика
    • Бессерверные вычисления
    • Безопасность
    • Мониторинг и управление ресурсами
    • ИИ для бизнеса
    • Бизнес-инструменты
  • Все решения
    • По отраслям
    • По типу задач
    • Экономика платформы
    • Безопасность
    • Техническая поддержка
    • Каталог партнёров
    • Обучение и сертификация
    • Облако для стартапов
    • Облако для крупного бизнеса
    • Центр технологий для общества
    • Партнёрская программа
    • Поддержка IT-бизнеса
    • Облако для фрилансеров
    • Обучение и сертификация
    • Блог
    • Документация
    • Мероприятия и вебинары
    • Контакты, чаты и сообщества
    • Идеи
    • Тарифы Yandex Cloud
    • Промоакции и free tier
    • Правила тарификации
  • Истории успеха
  • Документация
  • Блог
Проект Яндекса
© 2025 ТОО «Облачные Сервисы Казахстан»
Yandex AI Studio
  • Начало работы с Model Gallery
    • О сервисе Yandex AI Studio
    • Yandex Workflows
    • Квоты и лимиты
    • Термины и определения
  • Переход с AI Assistant API на Responses API
  • Совместимость с OpenAI
    • О 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
  • Управление доступом
  • Правила тарификации
  • Аудитные логи Audit Trails
  • Публичные материалы
  • История изменений

В этой статье:

  • class yandex_cloud_ml_sdk._files.domain.AsyncFiles
  • class yandex_cloud_ml_sdk._files.file.AsyncFile
  1. Yandex Cloud ML SDK
  2. Справочник SDK (англ.)
  3. Async SDK
  4. Files domain

Files domain

Статья создана
Yandex Cloud
Обновлена 25 августа 2025 г.
  • class yandex_cloud_ml_sdk._files.domain.AsyncFiles
  • class yandex_cloud_ml_sdk._files.file.AsyncFile

class yandexcloudmlsdk.files.domain.AsyncFilesclass yandex_cloud_ml_sdk._files.domain.AsyncFiles

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.

async 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

AsyncFile

async 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

AsyncFile

async 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

AsyncFile

async 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

AsyncIterator[AsyncFile]

class yandexcloudmlsdk.files.file.AsyncFileclass yandex_cloud_ml_sdk._files.file.AsyncFile

async 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

async 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

AsyncFile

async 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

async 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

Была ли статья полезна?

Предыдущая
Tools domain
Следующая
Threads domain
Проект Яндекса
© 2025 ТОО «Облачные Сервисы Казахстан»