Skip to main content

GigaChat pass-through

The /gigachat route forwards GigaChat API paths, such as /chat/completions and /embeddings, to GigaChat unchanged. The body must carry a model. When it names a deployment from model_list, the gateway routes through that deployment with its retries and fallbacks, otherwise it calls GIGACHAT_API_BASE with the gateway's GigaChat credentials. The virtual key is checked first and the call is recorded with its cost.

A real-world scenario​

A regional support team uses GigaChat for Russian language replies from a tool that speaks GigaChat's own API. They point the tool at /gigachat on the gateway with a virtual key. The GigaChat credentials stay on the gateway and the team's spend joins its other model spend in one budget.

Before you start​

The gateway needs a GigaChat credential. It looks first for a model_list deployment of provider GigaChat with use_in_pass_through: true, then for the environment below.

VariablePurpose
GIGACHAT_API_KEYThe GigaChat credential the gateway sends upstream.
GIGACHAT_API_BASEOptional. Changes the upstream address.

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, on the Add Model tab pick GigaChat under Provider, pick a model, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or set GIGACHAT_API_KEY and restart the gateway.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Call GigaChat through the gateway.

    curl -X POST http://localhost:4000/gigachat/chat/completions \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "GigaChat-2-Max", "messages": [{"role": "user", "content": "Summarise this ticket in one sentence."}]}'
  4. Open /ui/logs and click the newest row to see the request, the key and its cost.

Expected result​

GigaChat's own response, with its status code and headers. Streaming is streamed through as it arrives.

{
"id": "chatcmpl-9f1c",
"object": "chat.completion",
"model": "GigaChat-2-Max",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "The customer wants one of two duplicate charges refunded."}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 18, "completion_tokens": 12, "total_tokens": 30}
}

The spend log row carries the key, team and user and the cost from usage.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /gigachat/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
400Model is required in request bodyThe body has no model. Add one.
401 from GigaChatGigaChat's authentication errorThe gateway forwarded the call with no usable credential. Add a deployment with Use in pass through routes on, or set GIGACHAT_API_KEY.
Any otherGigaChat's own error bodyGigaChat refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. The unified chat completions endpoint works with every provider and runs guardrails. The GigaChat provider page covers the unified integration.