> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ttapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Завершения чата Gemini

<Note>
  Параметры запроса и ответа остаются совместимыми с официальным API. Подробнее см. в <a href="https://ai.google.dev/gemini-api/docs/text-generation" target="_blank">официальной документации Google</a>.
</Note>


## OpenAPI

````yaml openapi/ru/llm.json POST /gemini/chat/completions
openapi: 3.1.0
info:
  title: Документация API языковых моделей
  version: 1.0.0
  description: TTAPI LLM API сервис.
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /gemini/chat/completions:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiRequest'
      responses:
        '200':
          description: >-
            Успешный ответ (stream=false возвращает JSON,stream=true возвращает
            поток Gemini)
          content:
            application/json:
              schema:
                type: object
                properties:
                  choices:
                    type: array
                    description: Список результатов ответа
                    items:
                      type: object
                      properties:
                        finish_reason:
                          type: string
                          description: Причина остановки ответа
                          example: stop
                        index:
                          type: integer
                          description: Индекс результата
                          example: 0
                        message:
                          type: object
                          description: Тело ответного сообщения
                          properties:
                            content:
                              type: string
                              description: Контент создан Gemini
                              example: >-
                                Hello! Nice to chat with you.


                                How can I help you? Or what would you like to
                                talk about? 😊
                            role:
                              type: string
                              description: Роль сообщения
                              example: assistant
                          required:
                            - content
                            - role
                      required:
                        - finish_reason
                        - index
                        - message
                  created:
                    type: integer
                    description: Время создания ответа (секунды)
                    example: 1757472417
                  id:
                    type: string
                    description: Уникальный идентификатор запроса
                    example: oebAaMTvMfCUjMcP_prYwAs
                  model:
                    type: string
                    description: Используемая версия модели Gemini
                    example: gemini-2.5-pro
                  object:
                    type: string
                    description: Тип объекта ответа
                    example: chat.completion
                  usage:
                    type: object
                    description: Статистика использования токенов
                    properties:
                      completion_tokens:
                        type: integer
                        description: >-
                          Количество токенов, потребляемых сгенерированным
                          контентом
                        example: 21
                      prompt_tokens:
                        type: integer
                        description: Количество токенов, использованных подсказкой
                        example: 3
                      total_tokens:
                        type: integer
                        description: Общее количество израсходованных токенов
                        example: 1466
                    required:
                      - completion_tokens
                      - prompt_tokens
                      - total_tokens
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GeminiRequest:
      type: object
      properties:
        messages:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
              content:
                type: string
          example:
            - role: user
              content: Hello!
        model:
          type: string
          description: >-
            Модели, поддерживаемые TTAPI, см. [Поддерживаемые модели
            Gemini](/grids/ru/start/pricing/llm)
        stream:
          type: boolean
          default: 'false'
          description: >-
            Использовать ли события отправляемые сервером для передачи
            прогрессивного ответа
      required:
        - messages
        - model
  responses:
    400Response:
      description: Ошибка параметров
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: Ошибка авторизации
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        Вы можете получить API-ключ в <a href='https://dashboard.ttapi.io'
        target='_blank'>панель управления TTAPI</a>.

````