vust

Developer Docs · GigaChat

GigaChat API: a Safe Start, Step by Step

5 steps from a key to the first validated answer: an OAuth exchange with an explicit scope, TLS with a trusted certificate instead of insecure flags, a model picked from your own catalog — then structured output, functions, files and streaming, with the error-handling habits a stable integration is built on.

One token exchange · short-lived tokens · TLS verifiedAn independent guide built on the official documentation
One key exchange — a short-lived access tokenTLS verified: a trusted CA instead of insecure flagsJSON Schema, functions, files, vision and streaming in one API

The minimum safe scenario

  1. 01

    Get an Authorization Key

    Create a project in the developer account and obtain the authorization key. It is a token-exchange secret: keep it server-side and never embed it in client code.

  2. 02

    Exchange it for an access token

    One POST to the OAuth endpoint with an explicit scope returns a short-lived access token (the official reference states the lifetime — about 30 minutes at the time of writing). Cache it and refresh on expiry rather than exchanging per call.

  3. 03

    Set up TLS trust

    Add the Russian trusted root certificate to your HTTP client's trust store. Certificate verification stays on — insecure flags have no place in production.

  4. 04

    Pick a model from your own catalog

    Request the model list with your token and pin the chosen name in configuration. Your catalog is the only authoritative list of what your account can use.

  5. 05

    Make the first call and validate the answer

    Send a request to the chat endpoint with the pinned model. If you expect structured output, validate it against your schema before use — a day-one rule, not a late optimization.

What the API does — by job

Chat and generation

Dialogue, summarization, rewriting. Conversation context is assembled and sent by your side — plan history storage in your application.

Structured output and functions

JSON Schema describes the parameters; the model returns structured arguments. Schema validation on your side is a mandatory part of the contract.

Files and vision

Upload a file → get an identifier → attach it to a message. That is how document questions and image understanding work; check official limits for formats and sizes.

Streaming and images

Server-sent events for responsive interfaces; image generation returns a file you download by its identifier.

Common mistakes and fixes

  • Exchanging a token per request instead of caching it — extra latency and extra failures. Cache until expiry.
  • Disabling TLS verification instead of installing the trusted CA — a vulnerability, not a fix.
  • A prose 'answer strictly in JSON' with no schema and no validation — the format will drift eventually. Schema plus your own check.
  • A model name hardcoded from someone else's example — catalogs are account-specific and move. Read your own model list.
  • Hammering on a rate limit — it amplifies the problem. Exponential backoff and a bounded retry budget.

Frequently asked questions

How does GigaChat API authentication work?

You start from an Authorization Key issued in the developer account — it is a credential for the token exchange, not a reusable access token. Exchange it at the OAuth endpoint with an explicit scope (the official reference lists the exact values for personal, business and corporate access), receive a short-lived access token — about 30 minutes per the documentation at the time of writing; treat the official reference as authoritative — and cache it until shortly before expiry instead of exchanging on every request. Keep the key server-side and out of client code, logs and repositories.

Why does TLS need special setup, and what is the safe way?

The API endpoints present certificates issued by the Russian trusted root CA (the national certification authority), which most default trust stores do not include. The safe path is to add that root certificate to your HTTP client's trust store and keep TLS verification on. Disabling certificate verification 'to make it work' removes the protection TLS exists for — treat any snippet suggesting it as a bug.

Which model should I pick?

Request the model catalog with your own token and choose from what your account actually offers — the catalog you see is the authoritative list for you. For how the vendor positions each model, read the official model overview rather than third-party tier lists; then pin the exact model name in configuration, re-check the catalog when you upgrade, and let the task — not the biggest available name — drive the choice.

Does GigaChat support structured output and function calling?

Yes — you can describe functions with JSON Schema parameters, let the model decide when to call them, and get structured arguments back; the same mechanism is the reliable route to machine-readable output. Two habits make it production-grade: validate every returned object against your schema before acting on it, and never assume prose instructions alone will hold a format — the schema is the contract, the prompt is only a hint.

How do files, vision and image generation work?

You upload a file through the files endpoint, get an identifier, and attach that identifier to a chat message — that is the route for document questions and for image understanding. Image generation runs through the same chat interface: the response references a generated file that you then download by its identifier. Check the official limits for supported formats and sizes before wiring uploads into a product flow.

What is the right way to handle streaming and errors?

Enable streaming to receive the answer as server-sent events for responsive interfaces, and read chunks until the stream's terminating [DONE] event rather than assuming a fixed shape for the last message. On errors, inspect the returned status and message: refresh an expired access token and retry once; otherwise re-check the Authorization Key or token, scope and required headers; rate-limit responses deserve backoff, not hammering; and every structured answer gets validated before use. Log request identifiers, never request contents with user data.

The primary source is the official GigaChat API documentation: models, prices, limits and formats move — verify there before you start and again before release. Official API overview.