### Install SDK with All Extras Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Install the SDK with all optional extras for maximum compatibility. ```bash pip install "yandex-ai-studio-sdk[cli-wiki,cli-s3]" ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/CONTRIBUTING.md Install Sphinx and other necessary packages for working with project documentation. This command should be run from the repository root. ```bash pip install -r docs/requirements.txt -e . ``` -------------------------------- ### Logging Setup Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/sdk.md Configures the default logging for the SDK. ```APIDOC ## setup_default_logging(log_level='INFO', log_format='[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s', date_format='%Y-%m-%d %H:%M:%S') ### Description Sets up the default logging configuration for the SDK. Allows customization of log level, format, and date format. ### Parameters - **log_level** (string) - Optional - The logging level (e.g., 'INFO', 'DEBUG'). Defaults to 'INFO'. - **log_format** (string) - Optional - The format string for log messages. Defaults to '[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s'. - **date_format** (string) - Optional - The date format for log timestamps. Defaults to '%Y-%m-%d %H:%M:%S'. ``` -------------------------------- ### Install Vector Stores CLI Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Commands to install the Yandex AI Studio SDK and its optional components for S3 and Wikipedia support. ```bash pip install yandex-ai-studio-sdk pip install "yandex-ai-studio-sdk[cli-s3]" # S3 / Yandex Object Storage support pip install "yandex-ai-studio-sdk[cli-wiki]" # Wikipedia / MediaWiki support ``` -------------------------------- ### Integer Bit Length Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/domain.md Demonstrates how to get the number of bits necessary to represent an integer in binary. ```python >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` -------------------------------- ### Install CLI with Wikipedia/MediaWiki Support for Yandex AI Studio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/README.md Install the Yandex AI Studio SDK CLI with support for Wikipedia and MediaWiki. This allows indexing content from these platforms. ```sh pip install "yandex-ai-studio-sdk[cli-wiki]" ``` -------------------------------- ### Install Yandex AI Studio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/README.md Install the SDK using pip. This command is used to add the library to your Python environment. ```sh pip install yandex-ai-studio-sdk ``` -------------------------------- ### Install Test Dependencies Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/CONTRIBUTING.md Install all necessary dependencies for testing, including extra requirements, directly using pip. This bypasses tox for dependency management. ```bash pip install -r test_requirements.txt -r test_requirements_extra.txt ``` -------------------------------- ### Install CLI with S3 Support for Yandex AI Studio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/README.md Install the Yandex AI Studio SDK CLI with support for S3-compatible storage, including Yandex Object Storage. Use this if you need to index data from S3. ```sh pip install "yandex-ai-studio-sdk[cli-s3]" ``` -------------------------------- ### Install LangChain Extra for Yandex AI Studio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/README.md Install the SDK with the 'langchain' extra to enable LangChain integration. This is required before using LangChain features. ```sh pip install yandex-ai-studio-sdk[langchain] ``` -------------------------------- ### Async Streaming Example with YandexGPT Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Demonstrates how to use the SDK for asynchronous streaming of responses from a YandexGPT model. Requires importing asyncio and the AIStudio SDK. ```python import asyncio from langchain_core.messages import HumanMessage from yandex.ai.studio.sdk import AIStudio async def stream_example(): sdk_async = AIStudio() alc_model = sdk_async.models.completions('yandexgpt').langchain(model_type="chat") async for chunk in alc_model.astream([HumanMessage(content="Tell me a joke")]): print(chunk.content, end="", flush=True) asyncio.run(stream_example()) ``` -------------------------------- ### Integer to Ratio Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/domain.md Illustrates converting an integer into a pair of integers representing its ratio with a positive denominator. ```python >>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1) ``` -------------------------------- ### Text Output Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Displays the success message and index details in plain text format. ```text Search index created successfully! Search Index ID: fvt-xxxxxxxxxxxxxxxx Name: my-index ``` -------------------------------- ### RecognitionClassifier Initialization Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/speech_to_text.md Demonstrates how to initialize a `RecognitionClassifier` with a string trigger and trigger type. Shows examples with single and multiple triggers, and using the `on_utterance` alternative constructor. ```python RecognitionClassifier('insult', 'on_final') ``` ```python RecognitionClassifier('insult', ['on_final', 'on_partial']) ``` ```python RecognitionClassifier.on_utterance('insult') ``` -------------------------------- ### Index Multiple Local Files Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example of indexing multiple individual text and markdown files. ```bash yandex-ai-studio vector-stores local docs/intro.txt docs/guide.md ``` -------------------------------- ### Index Local File with Custom Name Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example of indexing a local file and specifying a custom name for the search index. ```bash yandex-ai-studio vector-stores local report.pdf --name "Q4 Report" ``` -------------------------------- ### Simple chat completion run Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Shows a basic example of running a chat completion with a specified model and temperature. ```APIDOC ## Simple run ### Description Performs a simple chat completion request using a specified model and configures the temperature. ### Method `model.run(prompt)` ### Parameters #### Model Configuration - **temperature** (float) - Optional - Controls the randomness of the output. ### Request Example ```python from yandex_ai_studio_sdk import AIStudio sdk = AIStudio() model = sdk.chat.completions('qwen3-235b-a22b-fp8').configure(temperature=0.5) result = model.run("How to calculate the Hirsch index in O(N)?") print(result.text) ``` ``` -------------------------------- ### JSON Output Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Displays the success message and index details in JSON format when the --format json option is used. ```json { "status": "success", "folder_id": "b1gxxxxxxxxxxxxx", "search_index": { "id": "fvt-xxxxxxxxxxxxxxxx", "name": "my-index" } } ``` -------------------------------- ### Index Local Files with Shell Globbing Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example using shell globbing to include all .txt and .md files from a directory. ```bash yandex-ai-studio vector-stores local sample_docs/*.txt sample_docs/*.md ``` -------------------------------- ### Configure Web Search Settings Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/search_api.md Use the `.configure` method to change initial search settings for web searches. This example shows how to switch the search type from 'BE' to 'RU'. ```python >>> search = sdk.search_api.web(search_type='BE') >>> search = search.configure(search_type='RU') ``` -------------------------------- ### Basic SDK Usage for Text Generation Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/README.md Demonstrates initializing the SDK with folder ID and authentication, configuring a completion model, and running a text generation request. Ensure you replace placeholders with your actual credentials and folder ID. ```python from yandex_ai_studio_sdk import AIStudio sdk = AIStudio(folder_id="...", auth="") model = sdk.models.completions('yandexgpt') model = model.configure(temperature=0.5) result = model.run("foo") for alternative in result: print(alternative) ``` -------------------------------- ### Compute Text Embeddings and Similarities Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Use 'query' and 'doc' model variants to get vector representations of text and compute cosine similarity. Ensure `scipy` and `numpy` are installed. ```python import numpy as np from scipy.spatial.distance import cdist from yandex_ai_studio_sdk import AIStudio sdk = AIStudio() doc_texts = [ "Alexander Pushkin (1799–1837) was a Russian poet and novelist.", "Chamomile is a flowering plant of the family Asteraceae.", ] query_model = sdk.models.text_embeddings('query') doc_model = sdk.models.text_embeddings('doc') query_result = query_model.run("When was Pushkin born?") doc_results = [doc_model.run(text) for text in doc_texts] query_vec = np.array(query_result.embedding) doc_vecs = np.array([r.embedding for r in doc_results]) similarities = 1 - cdist([query_vec], doc_vecs, metric='cosine')[0] best_match = doc_texts[np.argmax(similarities)] print(best_match) # → "Alexander Pushkin (1799–1837) was a Russian poet and novelist." ``` -------------------------------- ### Serve Documentation with Auto-rebuild Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/CONTRIBUTING.md Run a local web server to view the generated documentation and automatically rebuild it when source files change. This provides a live preview during development. ```bash sphinx-autobuild docs docs/_build --watch src ``` -------------------------------- ### Get Binary Representation of an Integer Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/types/batch.md Demonstrates how to get the binary representation of an integer using the bin() function. ```python >>> bin(37) '0b100101' ``` -------------------------------- ### AsyncAIStudio Initialization Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/sdk.md Instantiate the main class to interact with the SDK. Various optional parameters can be provided for configuration. ```APIDOC ## AsyncAIStudio Constructor ### Description Construct a new asynchronous SDK instance. ### Parameters * **folder_id** (str) - Optional - Yandex Cloud folder identifier. * **endpoint** (str) - Optional - Domain and port for the Yandex Cloud API. * **auth** (str | BaseAuth | Undefined) - Optional - Authentication credentials. * **service_map** (Dict[str, str]) - Optional - Dictionary to redefine service endpoints. * **enable_server_data_logging** (bool | Undefined) - Optional - Enable or disable server-side data logging. * **verify** (bool | pathlib.Path | str | os.PathLike) - Optional - SSL certificates for verification. * **retry_policy** (RetryPolicy | Undefined) - Optional - Retry policy configuration. * **yc_profile** (str | Undefined) - Optional - Yandex Cloud profile name. * **interceptors** (Sequence[ClientInterceptor] | Undefined) - Optional - Sequence of client interceptors. ``` -------------------------------- ### Configure Text-to-Speech Settings Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/text_to_speech.md Demonstrates how to initialize and reconfigure Text-to-Speech settings, such as audio format. The `configure` method allows overriding initial settings. ```python >>> tts = sdk.speechkit.text_to_speech(audio_format='mp3') >>> tts = tts.configure(audio_format='WAV') ``` -------------------------------- ### Confluence On-Premise URL Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example of an on-premise Confluence page URL format that includes a numeric page ID. ```bash https://confluence.example.com/pages/viewpage.action?pageId=123456 ``` -------------------------------- ### Confluence Cloud URL Example Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example of a Confluence Cloud page URL format that includes a numeric page ID. ```bash https://your-domain.atlassian.net/wiki/spaces/SPACE/pages/123456/Page+Title ``` -------------------------------- ### setup_default_logging Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/internals/bases.md Sets up the default logging configuration for the SDK. ```APIDOC ## setup_default_logging(log_level='INFO', log_format='[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s', date_format='%Y-%m-%d %H:%M:%S') Sets up the default logging configuration. Read more about log_levels, log_format, and date_format in [Python documentation (logging)](https://docs.python.org/3/library/logging.html). ### Parameters * **log_level** (Literal['CRITICAL', 'FATAL', 'ERROR', 'WARN', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] | ~typing.Literal['critical', 'fatal', 'error', 'warn', 'warning', 'info', 'debug', 'TRACE'] | int) – The logging level to set. * **log_format** (str) – The format of the log messages. * **date_format** (str) – The format for timestamps in log messages. ### Returns The instance of the SDK with logging configured. ### Return type Self ``` -------------------------------- ### setup_default_logging Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/sdk.md Sets up the default logging configuration for the SDK. Allows customization of log level, format, and date format. ```APIDOC ## setup_default_logging(log_level='INFO', log_format='[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s', date_format='%Y-%m-%d %H:%M:%S') ### Description Sets up the default logging configuration for the SDK. This function allows users to configure the verbosity and format of log messages generated by the SDK. ### Parameters #### Keyword Parameters * **log_level** (Literal['CRITICAL', 'FATAL', 'ERROR', 'WARN', 'WARNING', 'INFO', 'DEBUG', 'TRACE'] | ~typing.Literal['critical', 'fatal', 'error', 'warn', 'warning', 'info', 'debug', 'TRACE'] | int) - Optional - The logging level to set. Defaults to 'INFO'. * **log_format** (str) - Optional - The format of the log messages. Defaults to '[%(levelname)1.1s %(asctime)s %(name)s:%(lineno)d] %(message)s'. * **date_format** (str) - Optional - The format for timestamps in log messages. Defaults to '%Y-%m-%d %H:%M:%S'. ### Returns The instance of the SDK with logging configured. ### Return type Self ``` -------------------------------- ### Create and Manage Search Indexes Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Demonstrates creating a text search index, adding files to it, renaming, and listing files. Ensure files are uploaded before creating an index. ```python from yandex_ai_studio_sdk import AIStudio from yandex_ai_studio_sdk.search_indexes import ( StaticIndexChunkingStrategy, TextSearchIndexType, VectorSearchIndexType, HybridSearchIndexType, ) sdk = AIStudio() # Upload source files files = [ sdk.files.upload('docs/turkey.txt', ttl_days=5, expiration_policy='static'), sdk.files.upload('docs/maldives.txt', ttl_days=5, expiration_policy='static'), ] # Create text (BM25) search index op = sdk.search_indexes.create_deferred( [files[0]], index_type=TextSearchIndexType( chunking_strategy=StaticIndexChunkingStrategy( max_chunk_size_tokens=700, chunk_overlap_tokens=300, ) ), ) index = op.wait() print(f"Index created: {index.id}") # Add more files to an existing index add_op = index.add_files_deferred(files[1]) add_op.wait() # Rename the index index.update(name="travel-knowledge-base") # List files in index for f in index.list_files(): print(f.id) # List and delete all indexes for idx in sdk.search_indexes.list(): idx.delete() ``` -------------------------------- ### LLMPostProcessing Class Initialization Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/speech_to_text.md Demonstrates how to initialize the LLMPostProcessing class with a model URI, model name, or model name and version. ```APIDOC ## LLMPostProcessing Initialization ### Description Initializes the LLMPostProcessing class to configure post-processing for speech-to-text results using a specified language model. ### Parameters * **model_name** (str) - The identifier for the language model. Can be a full URI (e.g., 'gpt:///yandexgt/latest') or a model name (e.g., 'yandexgt'). If a model name is provided without a URI scheme, it will be constructed using the configured folder ID. * **model_version** (str, optional) - The version of the model to use. Defaults to 'latest'. * **instructions** (Sequence[LLMPostProcessingInstruction], optional) - An initial sequence of instructions to apply. Defaults to an empty tuple. ### Request Example ```python # Using a full model URI llm_post_processor_uri = LLMPostProcessing('gpt:///yandexgt/latest') # Using a model name (folder_id is configured separately) llm_post_processor_name = LLMPostProcessing('yandexgt') # Using a model name and specific version llm_post_processor_version = LLMPostProcessing('yandexgt', model_version='2024-04-09') ``` ``` -------------------------------- ### Initialize AsyncAIStudio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/examples/async/image_generation/run_deferred.ipynb Initializes the asynchronous SDK client. Authentication can be managed via environment variables for tokens and folder IDs. ```python from yandex_ai_studio_sdk import AsyncAIStudio # You can set authentication using environment variables instead of the 'auth' argument: # YC_OAUTH_TOKEN, YC_TOKEN, YC_IAM_TOKEN, or YC_API_KEY # You can also set 'folder_id' using the YC_FOLDER_ID environment variable sdk = AsyncAIStudio( # folder_id="", # auth="", ) model = sdk.models.image_generation('yandex-art') ``` -------------------------------- ### Adding Instructions with LLMPostProcessing Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/speech_to_text.md Shows how to add instructions to an LLMPostProcessing object using the `with_instruction` method. ```APIDOC ## LLMPostProcessing with_instruction Method ### Description Appends a new instruction to the LLMPostProcessing object, returning a new instance with the added instruction. This method does not mutate the original object. ### Parameters * **instruction** (str) - The instruction text to be given to the language model. * **response_format** (Literal['json'] | ~yandex_ai_studio_sdk._types.schemas.JsonSchemaResponseType | type | None, optional) - Specifies the desired format of the model's response. - `None`: Returns a standard text response (default). - `'json'`: Instructs the model to return a JSON object. - `dict`: A dictionary representing a JSON schema to enforce a specific JSON structure. - `pydantic model or pydantic dataclass`: The SDK will transform this into a JSON schema. ### Return type LLMPostProcessing - A new LLMPostProcessing object with the appended instruction. ### Request Example ```python # Initialize post processor llm_post_processor = LLMPostProcessing('yandexgt') # Add a simple text instruction llm_post_processor = llm_post_processor.with_instruction("Make a short review") # Add an instruction with JSON response format llm_post_processor = llm_post_processor.with_instruction( "What the conversation topic", response_format="json" ) # Add an instruction with a specific JSON schema response format # Assuming MySchema is a defined Pydantic model or dict schema # llm_post_processor = llm_post_processor.with_instruction( # "Extract key entities", # response_format=MySchema # ) ``` ### Object Representation After Adding Instructions ```python # Example of how the object might look after adding instructions # LLMPostProcessing(model_name='yandexgt', model_version='latest', ..., instructions=(LLMPostProcessingInstruction(...), LLMPostProcessingInstruction(...))) ``` ``` -------------------------------- ### id Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/types/tuning.md Gets the unique identifier for the fine-tuning task. ```APIDOC ## id ### Description Get fine-tuning task identifier. ### Return type str ``` -------------------------------- ### Manage Datasets for Fine-tuning and Batch Inference Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Demonstrates creating, uploading, and managing datasets. Supports both a shortcut API for completions datasets and a generic API for other task types. Datasets can be uploaded directly or deferred. ```python from yandex_ai_studio_sdk import AIStudio sdk = AIStudio() # --- Completions dataset (shortcut API) --- draft = sdk.datasets.completions.draft_from_path( 'training_data.jsonlines', upload_format='jsonlines', name='my-completions-v1', ) draft.allow_data_logging = True dataset = draft.upload() print(f"Dataset ready: {dataset.id}, status={dataset.status}") # --- Generic dataset --- draft2 = sdk.datasets.draft_from_path( task_type='TextToTextGeneration', path='data.jsonlines', upload_format='jsonlines', name='generic-dataset', ) # Deferred upload: returns Operation to track progress op = draft2.upload_deferred() dataset2 = op.wait() # List datasets with filters for ds in sdk.datasets.completions.list(name_pattern='my-completions'): print(ds.id, ds.status) # Get single dataset by ID ds = sdk.datasets.get('some-dataset-id') ds.delete() ``` -------------------------------- ### Initialize AI Studio SDK Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Instantiate the SDK client for synchronous or asynchronous operations. Authentication and folder ID can be provided explicitly or inferred from environment variables. ```python from yandex_ai_studio_sdk import AIStudio, AsyncAIStudio # Sync client — auth and folder_id read from env vars sdk = AIStudio().setup_default_logging() # Explicit credentials sdk = AIStudio( folder_id="b1gxxxxxxxxxxxxxxxxx", auth="AQVNxxxxxxxxxxxxxxxxx", # API key, IAM token, or OAuth token ) # Async client for use inside asyncio applications import asyncio from yandex_ai_studio_sdk import AsyncAIStudio async def main(): sdk = AsyncAIStudio(folder_id="b1gxxxxxxxxxxxxxxxxx", auth="AQVNxxxxxxxxxxxxxxxxx") model = sdk.models.completions('yandexgpt') result = await model.configure(temperature=0.5).run("Hello!") print(result[0].text) asyncio.run(main()) ``` -------------------------------- ### Get Thread Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/threads.md Retrieves a specific thread by its unique identifier. ```APIDOC ## get ### Description Retrieve a thread by its id. This method fetches an already created thread using its unique identifier. ### Method Signature `get(thread_id, timeout=60)` ### Parameters #### Path Parameters - **thread_id** (str) - the unique identifier of the thread to retrieve. #### Optional Parameters - **timeout** (float) - timeout for the service call in seconds. Defaults to 60 seconds. ### Return Type `Thread` ``` -------------------------------- ### Get Assistant Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/assistants.md Retrieves an existing assistant by its unique ID. ```APIDOC ## get Assistant ### Description Get an existing assistant by ID. ### Method `get` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **assistant_id** (str) - Required - ID of the assistant to retrieve - **timeout** (float) - Optional - Timeout in seconds (defaults to 60) ### Request Example ```python assistant = assistants.get("assistant-id") ``` ### Response #### Success Response (200) - **Assistant** (Assistant) - The retrieved assistant object ``` -------------------------------- ### Get Search Index Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/search_indexes.md Retrieves a search index by its unique identifier. ```APIDOC ## get ### Description Retrieve a search index by its id. This method fetches an already created search index using its unique identifier. ### Method Signature `get(search_index_id, timeout=60)` ### Parameters * **search_index_id** (*str*) – Required - The unique identifier of the search index to retrieve. * **timeout** (*float*) – Optional - The time to wait for the operation to complete. Defaults to 60 seconds. ### Return type *SearchIndex* ``` -------------------------------- ### Initialize AsyncAIStudio SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/examples/async/speechkit/text_to_speech/simple_run.ipynb Initializes the asynchronous AI Studio SDK. Authentication can be set via environment variables or directly using the 'auth' argument. The folder ID can also be configured. ```python from yandex_ai_studio_sdk import AsyncAIStudio from yandex_ai_studio_sdk._experimental.audio.out import AsyncAudioOut SAMPLERATE = 44100 ``` ```python # You can set authentication using environment variables instead of the 'auth' argument: # YC_OAUTH_TOKEN, YC_TOKEN, YC_IAM_TOKEN, or YC_API_KEY # You can also set 'folder_id' using the YC_FOLDER_ID environment variable sdk = AsyncAIStudio( # folder_id="", # auth="", ).setup_default_logging() ``` -------------------------------- ### SDK Initialization — AIStudio / AsyncAIStudio Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Entry point for all SDK functionality. Instantiate once per application, then access feature domains as attributes. Auth and folder ID can come from arguments or environment variables. ```APIDOC ## SDK Initialization — `AIStudio` / `AsyncAIStudio` Entry point for all SDK functionality. Instantiate once per application, then access feature domains as attributes. Auth and folder ID can come from arguments or environment variables. ```python from yandex_ai_studio_sdk import AIStudio, AsyncAIStudio # Sync client — auth and folder_id read from env vars sdk = AIStudio().setup_default_logging() # Explicit credentials sdk = AIStudio( folder_id="b1gxxxxxxxxxxxxxxxxx", auth="AQVNxxxxxxxxxxxxxxxxx", # API key, IAM token, or OAuth token ) # Async client for use inside asyncio applications import asyncio from yandex_ai_studio_sdk import AsyncAIStudio async def main(): sdk = AsyncAIStudio(folder_id="b1gxxxxxxxxxxxxxxxxx", auth="AQVNxxxxxxxxxxxxxxxxx") model = sdk.models.completions('yandexgpt') result = await model.configure(temperature=0.5).run("Hello!") print(result[0].text) asyncio.run(main()) ``` ``` -------------------------------- ### Get Assistant Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/assistants.md Asynchronously retrieves an existing assistant by its unique ID. ```APIDOC ## async get ### Description Get an existing assistant by ID. ### Method async ### Parameters * **assistant_id** (str) - Required - ID of the assistant to retrieve * **timeout** (float) - Optional - The timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds. ### Return type AsyncAssistant ``` -------------------------------- ### Get Dataset Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/datasets.md Fetches a specific dataset using its unique identifier. ```APIDOC ## get ### Description Fetch a dataset from the server using its ID. ### Method async ### Parameters #### Path Parameters - **dataset_id** (str) - Required - the unique identifier of the dataset to fetch. - **timeout** (float) - Optional - the time to wait for the request. Defaults to 60 seconds. ### Return type AsyncDataset ``` -------------------------------- ### Configure ByImage Search Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/search_api.md Demonstrates how to configure initial search settings for by_image search. Use the `.configure` method to change parameters like the target site. ```python >>> search = sdk.search_api.by_image(site="ya.ru") >>> search = search.configure(site="yandex.ru") ``` -------------------------------- ### Get File Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/files.md Retrieves a file from the server using its unique identifier. ```APIDOC ## async get(file_id, timeout=60) ### Description Retrieves a file by its ID. ### Parameters #### Path Parameters * **file_id** (str) - Required - The unique identifier of the file to retrieve. #### Query Parameters * **timeout** (float) - Optional - Timeout for the operation in seconds. Defaults to 60. ### Return type AsyncFile ``` -------------------------------- ### TimeSpan Class Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/types/speechkit.md Represents a time interval with a start and end time. ```APIDOC ### Class: yandex_ai_studio_sdk._speechkit.speech_to_text.result.utils.TimeSpan TimeSpan(start_time_ms: int, end_time_ms: int) #### Attributes: * **start_time_ms** (*int*): Audio segment start time in milliseconds. * **end_time_ms** (*int*): Audio segment end time in milliseconds. #### Properties: * **length_ms** (*int*): Returns the length of the given time span in milliseconds. ``` -------------------------------- ### Integer Bit Length and Count Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/internals/bases.md Demonstrates how to get the bit length and bit count of an integer. ```python >>> bin(37) '0b100101' >>> (37).bit_length() 6 ``` ```python >>> bin(13) '0b1101' >>> (13).bit_count() 3 ``` -------------------------------- ### Initialize LLMPostProcessing with Full Model URI Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/speech_to_text.md Instantiate the LLMPostProcessing class using a complete model URI. This is useful when you need to specify the exact model and version. ```python >>> llm_post_processor = LLMPostProcessing('gpt:///yandexgt/latest') ``` -------------------------------- ### LLMPostProcessing with_instruction Method Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/speechkit/speech_to_text.md Shows how to add instructions to an LLMPostProcessing object, optionally specifying a response format. ```APIDOC ## LLMPostProcessing.with_instruction ### Description Appends a new instruction to the post-processor configuration, returning a new LLMPostProcessing object with the added instruction. ### Parameters * **instruction** (str) - The instruction text for the language model. * **response_format** (Literal['json'] | ~yandex_ai_studio_sdk._types.schemas.JsonSchemaResponseType | type | None, optional) - Specifies the desired format of the model's response. Can be None for text, 'json' for JSON output, a JsonSchema, or a Pydantic model/dataclass. Defaults to None. ### Return type LLMPostProcessing - A new LLMPostProcessing object with the appended instruction. ### Request Example ```py llm_post_processor = LLMPostProcessing('yandexgt') # Add a simple text instruction llm_post_processor = llm_post_processor.with_instruction("Make a short review") # Add an instruction with JSON response format llm_post_processor = llm_post_processor.with_instruction( "What the conversation topic", response_format="json" ) ``` ``` -------------------------------- ### Initialize SpeechKit SDK Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/text_to_speech.md Initializes the SpeechKit SDK with necessary parameters. Requires an SDK instance, a URI, and optionally a configuration object and owner. ```python #### __init__(, sdk, uri, config=None, owner=None) * **Parameters:** * **sdk** ([*yandex_ai_studio_sdk._sdk.BaseSDK*](../../internals/bases.md#yandex_ai_studio_sdk._sdk.BaseSDK)) * **uri** (*str*) * **config** ([*ConfigTypeT](../../types/other.md#yandex_ai_studio_sdk._types.model_config.ConfigTypeT) *|* *None*) * **owner** (*str* *|* *None*) ``` -------------------------------- ### Run Result Properties Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/types/runs.md Access properties of a run result object to get detailed information about the execution. ```APIDOC ## Run Result Object ### Description Represents the outcome of a run, providing access to text content, status, errors, and tool calls. ### Properties - **text** (str | None) - The text content of the message if available, otherwise None. - **status** (StatusTypeT) - The current status of the run. - **error** (str | None) - An error message if the run failed, otherwise None. - **tool_calls** (ToolCallList | None) - A list of tool calls made during the run, if any. ``` -------------------------------- ### Index MediaWiki Pages with Yandex AI Studio CLI Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Use the `vector-stores wiki` command to create a search index from MediaWiki pages. Requires installation with the `cli-wiki` extra. Supports indexing multiple pages, exporting in different formats (text, html, markdown), and accessing private wikis with credentials. ```bash yandex-ai-studio vector-stores wiki https://en.wikipedia.org/wiki/Machine_learning ``` ```bash yandex-ai-studio vector-stores wiki \ https://en.wikipedia.org/wiki/Machine_learning \ https://en.wikipedia.org/wiki/Neural_network \ https://en.wikipedia.org/wiki/Transformer_(deep_learning_architecture) ``` ```bash yandex-ai-studio vector-stores wiki \ "https://en.wikipedia.org/wiki/Python_(programming_language)" \ --export-format markdown ``` ```bash yandex-ai-studio vector-stores wiki \ https://wiki.example.com/wiki/Internal_docs \ --username alice \ --password secret ``` -------------------------------- ### Index a Single Local File Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Example of indexing a single PDF file using the local subcommand. ```bash yandex-ai-studio vector-stores local report.pdf ``` -------------------------------- ### Load Fine-tuned Model by URI Source: https://context7.com/yandex-cloud/yandex-ai-studio-sdk/llms.txt Demonstrates how to load and use a fine-tuned model by specifying its unique URI. ```python # Fine-tuned model by URI tuned_model = sdk.models.completions("gpt://b1gxxxxx/yandexgpt-lite/some-tuned-uri") print(tuned_model.run("Hey!")[0].text) ``` -------------------------------- ### tune_deferred Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/models/text_embeddings.md Initiates a deferred tuning process for the model. This method starts a tuning task that runs asynchronously. ```APIDOC ## tune_deferred(train_datasets, embeddings_tune_type, validation_datasets=Undefined, name=Undefined, description=Undefined, labels=Undefined, seed=Undefined, lr=Undefined, n_samples=Undefined, additional_arguments=Undefined, dimensions=Undefined, tuning_type=Undefined, scheduler=Undefined, optimizer=Undefined, timeout=60) ### Description Initiate a deferred tuning process for the model. ### Parameters * **train_datasets** (*str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *|* *tuple* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]* *|* *Iterable* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *|* *tuple* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]* *]* *|* *dict* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]*) – the dataset objects and/or dataset ids used for training of the model. * **embeddings_tune_type** (*Literal* *[* *'pair'* *,* *'triplet'* *]*) – the type of tuning to be applied (e.g. pair or triplet). * **validation_datasets** (*str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *|* *tuple* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]* *|* *Iterable* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *|* *tuple* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]* *]* *|* *dict* *[**str* *|* [*BaseDataset*](../../internals/bases.md#yandex_ai_studio_sdk._datasets.dataset.BaseDataset) *,* *float* *]* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – the dataset objects and/or dataset ids used for validation of the model. * **name** (*str* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – the name of the tuning task. * **description** (*str* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – the description of the tuning task. * **labels** (*dict* *[**str* *,* *str* *]* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – labels for the tuning task. * **seed** (*int* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – a random seed for reproducibility. * **lr** (*float* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – a learning rate for tuning. * **n_samples** (*int* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – a number of samples for tuning. * **additional_arguments** (*str* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – additional arguments for tuning. * **dimensions** (*Sequence* *[**int* *]* *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – dimensions for the embeddings. * **tuning_type** ([*BaseTuningType*](../../types/tuning.md#yandex_ai_studio_sdk._types.tuning.tuning_types.BaseTuningType) *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – a type of tuning to be applied. * **scheduler** ([*BaseScheduler*](../../types/tuning.md#yandex_ai_studio_sdk._types.tuning.schedulers.BaseScheduler) *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – a scheduler for tuning. * **optimizer** ([*BaseOptimizer*](../../types/tuning.md#yandex_ai_studio_sdk._types.tuning.optimizers.BaseOptimizer) *|* [*Undefined*](../../types/other.md#yandex_ai_studio_sdk._types.misc.Undefined)) – an optimizer for tuning. * **timeout** (*float*) – the timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds. ### Return type [*TuningTask*](../../types/tuning.md#yandex_ai_studio_sdk._tuning.tuning_task.TuningTask)[[*TextEmbeddingsModel*](#yandex_ai_studio_sdk._models.text_embeddings.model.TextEmbeddingsModel)] ``` -------------------------------- ### Index Data from S3-Compatible Storage with Yandex AI Studio CLI Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/src/yandex_ai_studio_sdk/cli/search_index/README.md Create a search index from an S3-compatible bucket using the `vector-stores s3` command. Requires installation with the `cli-s3` extra. Supports filtering by prefix, custom endpoints, AWS credentials, and include/exclude patterns. ```bash yandex-ai-studio vector-stores s3 my-bucket ``` ```bash yandex-ai-studio vector-stores s3 my-bucket --prefix docs/ ``` ```bash yandex-ai-studio vector-stores s3 my-bucket --include-pattern "*.pdf" ``` ```bash yandex-ai-studio vector-stores s3 my-bucket \ --endpoint-url https://storage.yandexcloud.net \ --region-name ru-central1 ``` -------------------------------- ### Get Recognition Result Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/speechkit/speech_to_text.md Retrieves the results of an asynchronous speech recognition operation. This method is used after the operation has completed. ```APIDOC ## async get_recognition_result(operation_id, timeout=60) ### Description Gets results of asynchronous recognition after finishing the operation. ### Parameters * **operation_id** (str) - Required - The ID of the recognition operation. * **timeout** (float) - Optional - The maximum time to wait for the results in seconds. Defaults to 60. ### Return type *AsyncDeferredSpeechToTextResult* ``` -------------------------------- ### Get Run Result Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/sync/runs.md Retrieves the final result of a completed run. This method should be called after the run has finished execution. ```APIDOC ## GET /runs/{run_id}/result ### Description Get the result of a run. ### Method GET ### Endpoint `/runs/{run_id}/result` ### Parameters #### Path Parameters - **run_id** (str) - Required - Run ID #### Query Parameters - **timeout** (float) - Optional - The timeout, or the maximum time to wait for the request to complete in seconds. Defaults to 60 seconds. ### Response #### Success Response (200) - **AnyResultTypeT_co** (*object*) - The final result of the run. ### Response Example ```json { "type": "text", "value": "The weather is sunny." } ``` ``` -------------------------------- ### Get File from Search Index Source: https://github.com/yandex-cloud/yandex-ai-studio-sdk/blob/master/docs/async/search_indexes.md Retrieves a specific file associated with a search index using its file ID. ```APIDOC ## Get File from Search Index ### Description Retrieves a file associated with the search index. ### Method `async get_file` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **file_id** (str) - Required - the ID of the file to retrieve. * **timeout** (float) - Optional - the time to wait for the get request. Defaults to 60 seconds. ### Request Example ```python file_data = await search_index.get_file(file_id="file_123", timeout=30.0) ``` ### Response #### Success Response (200) * **SearchIndexFile** - The retrieved file object. #### Response Example ```json { "id": "file_123", "name": "document.pdf", "size": 1024, "created_at": "2023-01-01T10:00:00Z" } ``` ```