Creating a text agent with web search
Written by
Updated at December 23, 2025
In Yandex AI Studio, you can create a text agent that will access information from the internet to generate a response.
Getting started
To use an example:
Python
Get API authentication credentials as described in Authentication with the Yandex AI Studio API.
Create
Python
-
Create a file named
index.pyand add the following code to it:import openai import json YANDEX_CLOUD_FOLDER = "..." YANDEX_CLOUD_API_KEY = "..." YANDEX_CLOUD_MODEL = "yandexgpt" client = openai.OpenAI( api_key=YANDEX_CLOUD_API_KEY, base_url="https://rest-assistant.api.cloud.yandex.net/v1", project=YANDEX_CLOUD_FOLDER ) response = client.responses.create( model=f"gpt://{YANDEX_CLOUD_FOLDER}/{YANDEX_CLOUD_MODEL}", input="Give me a quick overview of LLM news for September 2025.", tools=[ { "web_search": { "filters": { "allowed_domains": [ "habr.ru" ] }, "user_location": { "region": "213", } } } ], temperature=0.3, max_output_tokens=1000 ) # Response text print("Response text:") print(response.output_text) print("\n" + "=" * 50 + "\n") # Full response print("Full response (JSON):") print(json.dumps(response.model_dump(), indent=2, ensure_ascii=False))xs -
Save authentication data into environment variables:
export YANDEX_CLOUD_FOLDER=<folder_ID> export YANDEX_CLOUD_API_KEY=<API_key> export VECTOR_STORE_ID=<search_index_ID> -
Run the file you created:
python index.py