Connect Yandex AI Studio to run CodeGraph’s text-generation and embedding requests through the provider API. Analysis workflows use a common interface: they pass a system instruction and a user question, and receive generated text with model and usage metadata.
CodeGraph reads settings from config.yaml, resolves environment references, and connects to the selected provider. CODEGRAPH_LLM_PROVIDER selects it for the current process; otherwise CodeGraph uses llm.provider. Choose a model and quota available in your provider account, then verify the connection with the request below.
What CodeGraph sends
Text generation sends system_prompt, user_prompt, and generation parameters. Embedding calls
send the supplied texts. Requests leave the CodeGraph boundary for the configured Yandex endpoint.
The client sets x-folder-id and x-data-logging-enabled: false. That header disables provider-side request logging, as described in the Yandex logging reference. See LLM security.
Configure credentials
Run commands in PowerShell from the CodeGraph source repository root with the project Python
environment installed. Replace angle-bracket placeholders with approved values. Merge the YAML
fragment into the existing llm section; do not create a duplicate section.
Store the API key in the approved secret manager and expose only environment references to CodeGraph:
$env:CODEGRAPH_LLM_PROVIDER = 'yandex'
$env:YANDEX_API_KEY = '<secret-from-approved-store>'
$env:YANDEX_FOLDER_ID = '<approved-folder-id>'
llm:
provider: yandex
yandex:
api_key: ${YANDEX_API_KEY}
folder_id: ${YANDEX_FOLDER_ID}
model: <approved-model-name>
base_url: https://llm.api.cloud.yandex.net/v1
embedding_model: <approved-embedding-model>
timeout: 60
The provider forms generation URIs as gpt://<folder_id>/<model> and embedding URIs as emb://<folder_id>/<model>. Use a folder whose IAM policy grants the operations needed by the pilot. Keep the API key in the secret manager.
Select models
Set model and embedding_model to models available in your folder. CodeGraph resolves compatible model aliases to a model name, then builds its URI with the folder identifier. Use the Yandex AI Studio API reference to check available interfaces and your account to check model access and quota.
Save the current settings before changing them. Change generation and embedding models independently so a failed check can be traced to one setting.
Verify the integration
First run python -m src.cli llm providers to inspect the provider in the configuration and credential-variable presence. For the request below, CODEGRAPH_LLM_PROVIDER selects the provider; the response’s provider field identifies the provider actually used. Then run this request from the repository root in the same PowerShell session. It loads the complete llm configuration and sends a short question to the selected provider:
$env:PYTHONUTF8 = '1'
@'
import json
from src.llm import create_llm_provider
provider = create_llm_provider()
response = provider.generate(
system_prompt="Explain software concepts in one short sentence.",
user_prompt="What is a call graph?",
max_tokens=128,
)
print(response.content)
fields = ("provider", "model", "latency_ms", "prompt_tokens", "completion_tokens")
print(json.dumps({key: response.metadata.get(key) for key in fields}, ensure_ascii=False))
'@ | python -
Expect one sentence explaining that a call graph connects functions through their calls, followed by a JSON metadata line. Wording varies by model. Check provider, model, and latency_ms; compare prompt_tokens and completion_tokens with the usage record in the provider account.
The example requests at most 128 output tokens. For an authentication, model-access, TLS, or quota error, use the matching recovery action below and repeat the same question after correcting the setting.
Failure handling
- Authentication or folder error: check key scope and
YANDEX_FOLDER_ID; rotate the key securely. - Unknown or unavailable model: check the configured name and model access in your folder.
- Rate limit: reduce concurrency or request quota; do not turn retries into an uncontrolled loop.
- Timeout or connection error: inspect network policy and request size before increasing timeout.
- Data-policy mismatch: stop remote processing and switch to an approved provider or local path.
Rollback restores the previous provider/model configuration and repeats both construction and bounded end-to-end checks.
Related guides
- Configuration — select the provider and configure the instance.
- CLI guide — prepare the Python environment and run commands.
- Troubleshooting — check services and collect failure details.