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._threads.domain.AsyncThreads
  • class yandex_cloud_ml_sdk._threads.thread.AsyncThread
  1. Yandex Cloud ML SDK
  2. SDK reference
  3. Async SDK
  4. Threads domain

Threads domain

Written by
Yandex Cloud
Updated at August 25, 2025
  • class yandex_cloud_ml_sdk._threads.domain.AsyncThreads
  • class yandex_cloud_ml_sdk._threads.thread.AsyncThread

class yandexcloudmlsdk.threads.domain.AsyncThreadsclass yandex_cloud_ml_sdk._threads.domain.AsyncThreads

A class for managing threads. It is a part of Assistants API.

This class provides methods to create, retrieve, and list threads.

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

Create a new thread.

This method creates a new thread with the specified parameters.

Parameters

  • name (str | Undefined) – the name of the thread.
  • description (str | Undefined) – a description for the thread.
  • labels (dict[str, str] | Undefined) – a set of labels for the thread.
  • ttl_days (int | Undefined) – time-to-live in days for the thread.
  • 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 service call in seconds. Defaults to 60 seconds.

Return type

AsyncThread

async get(thread_id, *, timeout=60)

Retrieve a thread by its id.

This method fetches an already created thread using its unique identifier.

Parameters

  • thread_id (str) – the unique identifier of the thread to retrieve.
  • timeout (float) – timeout for the service call in seconds. Defaults to 60 seconds.

Return type

AsyncThread

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

List threads in the specified folder.

This method retrieves a list of threads. It continues to fetch threads until there are no more available.

Parameters

  • page_size (int | Undefined) – the maximum number of threads to return per page.
  • timeout (float) – timeout for the service call in seconds. Defaults to 60 seconds.

Return type

AsyncIterator[AsyncThread]

class yandexcloudmlsdk.threads.thread.AsyncThreadclass yandex_cloud_ml_sdk._threads.thread.AsyncThread

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

Update the thread’s properties, including the name, the description, labels, ttl days, and the expiration policy of the thread.

Parameters

  • name (str | Undefined) – the new name of the thread.
  • description (str | Undefined) – the new description for the thread.
  • labels (dict[str, str] | Undefined) – a set of new labels for the thread.
  • ttl_days (int | Undefined) – the updated time-to-live in days for the thread.
  • 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) – an updated expiration policy for the file.
  • timeout (float) – timeout for the operation in seconds. Defaults to 60 seconds.

Return type

Self

async delete(*, timeout=60)

Delete the thread.

This method deletes the thread and marks it as deleted. Raises an exception if the deletion fails.

Parameters

timeout (float) – timeout for the operation. Defaults to 60 seconds.

Return type

None

async write(message, *, labels=Undefined, timeout=60)

Write a message to the thread.

This method allows sending a message to the thread with optional labels.

Parameters

  • message (TextMessage | TextMessageDict | TextMessageProtocol | str) – the message to be sent to the thread. Could be a string, a dictionary, or a result object. Read more about other possible message types in the documentation.
  • labels (dict[str, str] | Undefined) – optional labels for the message.
  • timeout (float) – timeout for the operation. Defaults to 60 seconds.

Return type

Message

async read(*, timeout=60)

Read messages from the thread.

This method allows iterating over messages in the thread.

Parameters

timeout (float) – timeout for the operation. Defaults to 60 seconds.

Return type

AsyncIterator[Message]

name: str | None

the name of the thread

description: str | None

the description of the thread

created_by: str

the identifier of the user who created the thread

created_at: datetime

the timestamp when the thread was created

updated_by: str

the identifier of the user who last updated the thread

updated_at: datetime

the timestamp when the thread was last updated

expires_at: datetime

the timestamp when the thread will expire

labels: dict[str, str] | None

additional labels associated with the thread

expiration_config: ExpirationConfig

id: str

Was the article helpful?

Previous
Files domain
Next
Runs domain
© 2025 Direct Cursus Technology L.L.C.