> ## 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.

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

<Note>
  Параметры запроса и ответа остаются совместимыми с официальным API.
  Подробнее см. в <a href="https://docs.x.ai/developers/rest-api-reference/inference/chat#chat-completions" target="_blank">официальной документации Grok</a>.
</Note>


## OpenAPI

````yaml openapi/ru/llm.json POST /v1/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:
  /v1/chat/completions:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompletionsRequest'
      responses:
        '200':
          description: Успешный ответ
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: chatcmpl-9ugiTupGJUmeRNqyqUvYO34GOUzyv
                  object:
                    type: string
                    example: chat.completion
                  created:
                    type: integer
                    example: 1723297597
                  model:
                    type: string
                    example: gpt-3.5-turbo-0125
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          example: 0
                        message:
                          type: object
                          properties:
                            content:
                              type: string
                              example: Hello! How can I help you?
                            role:
                              type: string
                              example: assistant
                            refusal:
                              type:
                                - string
                                - 'null'
                              example: null
                        finish_reason:
                          type: string
                          example: stop
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                        example: 11
                      completion_tokens:
                        type: integer
                        example: 17
                      total_tokens:
                        type: integer
                        example: 28
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - Authorization: []
components:
  schemas:
    CompletionsRequest:
      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: >-
            Модель для использования, см. [Поддерживаемые
            модели](/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:
    Authorization:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Вы можете получить API-ключ в <a href='https://dashboard.ttapi.io'
        target='_blank'>панель управления TTAPI</a>.

````