Skip to main content

GigaChat integration

Configure GigaChat credentials and model selection for CodeGraph. Inspect provider configuration, request handling, and error recovery.

Integrations

Connect GigaChat 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

For text generation, CodeGraph sends the system instruction, user question, and generation parameters to the API endpoint. Streaming sends the same inputs and returns the answer in chunks. For embeddings, CodeGraph sends the source text and receives its numeric representation. GigaChat processes these requests in its infrastructure.

Classify and redact data before it reaches this provider. The system-wide controls are described in LLM security.

Configure credentials

Sber’s quick start says that, since September 1, 2026, new customers and customers who have not purchased a package can pay for model access through Cloud.ru. Foundation Models exposes an OpenAI-compatible API. In CodeGraph, select the openai provider and set the Cloud.ru key, API endpoint, and model ID:

$env:CODEGRAPH_LLM_PROVIDER = 'openai'
$env:OPENAI_API_KEY = '<cloud.ru-api-key>'
llm:
  provider: openai
  openai:
    api_key: ${OPENAI_API_KEY}
    base_url: https://foundation-models.api.cloud.ru/v1
    model: <model-id-from-cloud.ru>

See the Cloud.ru Foundation Models quick start and API reference. Its OpenAI-compatible reference documents model listing and text generation, not embedding requests.

For an existing GigaChat API account, use the native configuration below. In the project settings, create an Authorization Key.

Run commands in PowerShell from the CodeGraph source repository root with the project Python environment and langchain-gigachat package installed. Prepare a GigaChat API project with access to the selected model and a request quota. Create an Authorization Key in the project settings and save it in your secret store. Setup steps for existing accounts appear in the GigaChat API quick starts for individuals and businesses.

Replace angle-bracket placeholders with your key and model name. Merge the YAML fragment into the existing llm section; do not create a duplicate section.

Keep credentials outside the repository. The CLI configuration display recognizes GIGACHAT_AUTH_KEY. The YAML below resolves that value into credentials. To use GIGACHAT_CREDENTIALS instead, reference ${GIGACHAT_CREDENTIALS} in the same field.

$env:CODEGRAPH_LLM_PROVIDER = 'gigachat'
$env:GIGACHAT_AUTH_KEY = '<secret-from-approved-store>'

Reference the environment value from config.yaml:

llm:
  provider: gigachat
  gigachat:
    credentials: ${GIGACHAT_AUTH_KEY}
    model: <approved-model-name>
    base_url: https://api.giga.chat/v1
    scope: GIGACHAT_API_PERS
    verify_ssl_certs: true
    ca_bundle_file: ''

base_url sets the endpoint for model requests. The example uses https://api.giga.chat/v1 from the provider documentation. The SDK exchanges the authorization key for an access token.

verify_ssl_certs defaults to true. When a corporate TLS proxy requires a private CA, set ca_bundle_file to the approved bundle instead of disabling verification. Do not commit the resolved credential or a secret-bearing .env file.

Select a model and scope

Set model to the name available in your GigaChat account. CodeGraph sends this name in API requests. Choose scope for the account: GIGACHAT_API_PERS for individuals, GIGACHAT_API_B2B for prepaid business access, or GIGACHAT_API_CORP for business pay-as-you-go access. See the provider authorization reference.

Save the current provider and model values before changing them. Check model access and quota in the provider account, then change one setting at a time.

Verify the integration

First run python -m src.cli llm providers to inspect the configured provider and credential-variable presence. 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

  • Credential or scope errors: verify the approved account and rotate the secret; do not log it.
  • TLS errors: validate the endpoint and CA chain; keep verify_ssl_certs enabled.
  • Rate limits: reduce concurrency or request a quota; repeat after the quota is available.
  • Unknown model: check the configured name and model access in your provider account.
  • Timeout: check the connection to GigaChat and the request size.

To roll back, restore the previous provider or model and repeat the question from “Verify the integration.” Check the answer and the model name in the metadata.

Next steps