ym88659208ym87991671
API Reference | Documentation for developers

API Reference

Last updated on March 11, 2025

This document contains a REST API reference for GigaChat.

Authorization

GigaChat API is available to legal entities and individual entrepreneurs after concluding an agreement. Payments are made on a postpaid basis.

GigaChat API requests are validated via OAuth 2.0 protocol using access tokens. The access token is sent in the Authorization header:

curl https://gigachat.devices.sberbank.ru/api/v1/models \
-H 'Authorization: Bearer Token ***' \

For more information on using access tokens, see Authorization.

Description

The requests are processed under the following domain:

https://gigachat.devices.sberbank.ru/api/v1/

GET /models

Returns an array of objects containing the data for available models.

Request example:

curl https://gigachat.devices.sberbank.ru/api/v1/models \
-H 'Authorization: Bearer Token ***' \

Response:

{
"data": [
{
"id": "GigaChat:v1.2.19.2",
"object": "model",
"owned_by": "salutedevices"
}
],
"object": "list"
}

GET /models/{model}

Returns an object containing the description of the specified model.

Request example:

curl https://gigachat.devices.sberbank.ru/api/v1/models/GigaChat:v1.10.0 \
-H 'Authorization: Bearer Token ***' \

Request parameters:

ModelId

Last updated on March 11, 2025
    model
    string

    Model name

Response:

{
"id": "GigaChat:v1.2.19.2",
"object": "model",
"owned_by": "salutedevices"
}

POST /chat/completions

Returns a reply of the model considering the previously sent messages.

Request example:

curl https://gigachat.devices.sberbank.ru/api/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer Token ***' \
-d '{
"model": "GigaChat:latest",
"messages": [
{
"role": "user",
"content": "When will the AI take over the world?"
},
{
"role": "assistant",
"content": "So far, this has not been an inevitable menace. Although the AI is rapidly developing and is able to complete tricky tasks more and more effectively, it still has limited capabilities and cannot replace a human being in all areas. Also, there are AI-related ethic and legal constratins that are considered in its development and integration."
},
{
"role": "user",
"content": "Do you think we have a chance?"
}
],
"temperature": 0.7
}'

Request parameters:

Chat

Last updated on March 11, 2025
    model
    string
    required

    Name of the model you want to get a reply from.

    To select the latest model, use GigaChat:latest

    messages

    object[]

    required

    Array of messages. Send the amount of messages that the service needs to base its replies on.

    For more information, see Chat History

  • Array [

  • role
    string

    Возможные значения: [user, assistant, system]

    Message author role

    content
    string

    Message text

  • ]

  • temperature
    float

    Возможные значения: >= 0 и <= 2

    По умолчанию: 0.87

    Temperature of reply selection. The value ranges from 0 to 2. The greater the value, the more random reply the model gives.

    We recommend not to use this parameter along with top_p.

    top_p
    float

    Возможные значения: >= 0 и <= 1

    По умолчанию: 0.47

    This parameter is an alternative to temperature. It sets the possible array of tokens that is considered by the model. For example, if the value is 0.1, the model considers only tokens within top 10% of the probability mass.

    This parameter supports values from 0 to 1.

    We recommend not to use this parameter along with temperature.

    n
    int64

    Возможные значения: >= 1 и <= 4

    По умолчанию: 1

    The amount of reply options to generate for each message.

    stream
    boolean

    По умолчанию: false

    Indicates that messages should be sent in parts as a stream.

    The messages are sent via the SSE protocol.

    A stream ends with the data: [DONE] message.

    For more information, see Streaming Response Messages.

    max_tokens
    int64

    По умолчанию: 512

    The maximum ammount of tokens to use for replies.

    repetition_penalty
    number

    По умолчанию: 1.07

    The amount of repeating words:

    • For values from 0 to 1, the model repeats the words that are already used
    • Value 1 is a neutral value
    • For values greater than 1, the model avoids repeating words
    update_interval
    number

    По умолчанию: 0

    Streaming mode parameter ("stream": "true"). This parameter sets the minimal interval between token sendings in seconds. For example, if the value is set to 1, the messages are sent every second. This means that the size of each message is larger, because a larger amount of tokens is sent during one second.

Response:

{
"choices": [
{
"message": {
"role": "assistant",
"content": "Of course, mankind can always develop science and technologies to improve life quality and overcome challenges. It is important to continue researching the AI, find new methods of and approaches to its usage, and develop ethic principles and regulations that can help us make decisions based on our knowledge rather than emotions or prejudices."
},
"index": 0,
"finish_reason": "stop"
}
],
"created": 1678878333,
"model": "GigaChat:v1.2.19.2",
"usage": {
"prompt_tokens": 18,
"completion_tokens": 68,
"total_tokens": 86
},
"object": "chat.completion"
}

POST /tokens/count

Returns an object with tokens quantity, counted by the set model in the input array.

curl --location '{{baseUrl}}/tokens/count' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data '{
"model": "GigaChat",
"input": ["And the silken, sad, uncertain rustling of each purple curtain"]
}
'

Request parameters:

TokensCountBody

Last updated on March 11, 2025
    model
    string
    required

    The Model which counts tokens.

    input
    string[]
    required

    An array of strings in which tokens will be counted.

Response:

[
{
"object": "tokens",
"tokens": 7,
"characters": 36
}
]

Error Codes

Error CodeDescription
401Unauthorized
400Bad request format
404No such Model
422Validation error
429Too many requests
500Internal Server Error

See Also

Sber process cookies only to personalize services according to Cookies Usage Policy. You can prevent the processing of cookies in your browser settings.