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

# Відповідь моделі

> Генерує відповідь моделі у форматі OpenAI Chat Completions, звичайним JSON або потоком.



## OpenAPI

````yaml uk/openapi/uk-openai-api-openapi.yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: ER:LC Росія - OpenAI-Сумісний API
  version: 1.0.0
  description: >-
    OpenAI-сумісні методи Chat Completions, отримання моделей і синтезу мовлення
    ER:LC Russia. Підтримувані параметри наведено в описі кожного методу.
servers:
  - url: https://api.erlcrussia.com
    description: Основний сервер
  - url: https://api.erlcrussia.xyz
    description: Резервний сервер
security: []
tags:
  - name: Audio
  - name: Chat Completions
  - name: Models
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Відповідь моделі
      description: >-
        Генерує відповідь моделі у форматі OpenAI Chat Completions, звичайним
        JSON або потоком.
      parameters:
        - name: X-Session-ID
          in: header
          required: false
          schema:
            type: string
          description: >-
            Ідентифікатор сесії діалогу (альтернатива полю session_id у тілі
            запиту).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            example:
              model: niya-1
              messages:
                - role: system
                  content: Ты — Ния, официальный ассистент сервера ER:LC Россия.
                - role: user
                  content: Как получить лицензию на оружие в игре?
              stream: false
      responses:
        '200':
          description: Успішна відповідь моделі або потік чанків (SSE).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
              example:
                id: chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c
                session_id: session_1726838400000_a1b2c3
                object: chat.completion
                created: 1726838400
                model: niya-1
                choices:
                  - index: 0
                    message:
                      role: assistant
                      content: >-
                        Для получения лицензии на оружие вам необходимо прибыть
                        в полицейский департамент...
                    finish_reason: stop
                usage:
                  prompt_tokens: 812
                  completion_tokens: 96
                  total_tokens: 908
                  completion_tokens_details:
                    reasoning_tokens: 0
                  prompt_tokens_details:
                    cached_tokens: 512
                  cost_credits: 0.42
            text/event-stream:
              schema:
                type: string
                description: >-
                  Потік Server-Sent Events у форматі OpenAI. Кожна подія — рядок
                  `data: {...}` з об’єктом `chat.completion.chunk`. У першому
                  чанку `delta.role` дорівнює `assistant`, кожен чанк має
                  `finish_reason`: `null`, поки відповідь триває, і `stop` або
                  `tool_calls` в останньому. При `stream_options.include_usage:
                  true` перед кінцем надходить чанк з `choices: []` і `usage`.
                  Потік закінчується рядком `data: [DONE]`. Якщо генерація
                  обірвалася, надходить подія `{"error": {...}}`, а за нею
                  `data: [DONE]`.
              example: >+
                data:
                {"id":"chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c","object":"chat.completion.chunk","created":1726838400,"model":"niya-1","choices":[{"index":0,"delta":{"role":"assistant","content":"Для
                получения "},"finish_reason":null}]}


                data:
                {"id":"chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c","object":"chat.completion.chunk","created":1726838400,"model":"niya-1","choices":[{"index":0,"delta":{"content":"лицензии..."},"finish_reason":null}]}


                data:
                {"id":"chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c","object":"chat.completion.chunk","created":1726838400,"model":"niya-1","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}


                data:
                {"id":"chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c","object":"chat.completion.chunk","created":1726838400,"model":"niya-1","choices":[],"usage":{"prompt_tokens":812,"completion_tokens":96,"total_tokens":908}}


                data: [DONE]

          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
            openai-processing-ms:
              $ref: '#/components/headers/ProcessingMs'
            x-ratelimit-limit-requests:
              $ref: '#/components/headers/RateLimitRequests'
            x-ratelimit-remaining-requests:
              $ref: '#/components/headers/RateLimitRemainingRequests'
            x-ratelimit-reset-requests:
              $ref: '#/components/headers/RateLimitResetRequests'
        '400':
          description: Некоректне тіло запиту.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: >-
                    We could not parse the JSON body of your request. Make sure
                    it is valid JSON.
                  type: invalid_request_error
                  param: null
                  code: null
                  erlc_code: '5034'
        '401':
          description: Ключ не передано або він недійсний.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: >-
                    Incorrect API key provided. Check the key or create a new
                    one in the dashboard.
                  type: invalid_request_error
                  param: null
                  code: invalid_api_key
                  erlc_code: '5008'
        '429':
          description: >-
            Перевищено ліміт запитів (`type: requests`) або закінчилися
            AI-кредити (`type: insufficient_quota`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limit:
                  value:
                    error:
                      message: Rate limit reached. Please slow down and retry later.
                      type: requests
                      param: null
                      code: rate_limit_exceeded
                      erlc_code: '5016'
                insufficient_quota:
                  value:
                    error:
                      message: >-
                        You exceeded your current quota, please check your plan
                        and billing details.
                      type: insufficient_quota
                      param: null
                      code: insufficient_quota
                      erlc_code: '5038'
        '503':
          description: Модель тимчасово недоступна, повторіть запит пізніше.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  message: AI model temporarily unavailable
                  type: server_error
                  param: null
                  code: '5141'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - messages
      properties:
        model:
          type: string
          enum:
            - niya-1
            - emmy-1
            - hubert-1
            - default
          default: niya-1
          description: >-
            Ідентифікатор моделі:

            - `niya-1` — Нія (основна модель для загальних завдань та модерації,
            1M контекст)

            - `emmy-1` - Еммі (інтелектуальна модель з покроковим міркуванням,
            1M контекст)

            - `hubert-1` - Хуберт (кастомна модель, 1M контекст)
          example: niya-1
        messages:
          type: array
          minItems: 1
          description: Список попередніх повідомлень розмови.
          items:
            $ref: '#/components/schemas/ChatMessage'
        files:
          type: array
          description: Додатковий список файлів або зображень, прикріплених до запиту.
          items:
            $ref: '#/components/schemas/FilePart'
        stream:
          type: boolean
          default: false
          description: Увімкнення потокової передачі відповідей Server-Sent Events (SSE).
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
              default: false
              description: >-
                Якщо `true`, перед `data: [DONE]` надходить окремий чанк з
                порожнім `choices` і полем `usage`. Без цього прапорця `usage` у
                потоці не надсилається.
        thinking:
          type: boolean
          description: Увімкнення режиму покрокового роздуму (ланцюжка міркувань).
          example: true
        surzhyk:
          type: boolean
          default: false
          description: >-
            Для моделі hubert-1 включає фірмовий суржик. За умовчанням Хуберт
            відповідає мовою останнього повідомлення користувача.
        effort:
          type: string
          enum:
            - low
            - medium
            - high
            - extra
            - max
          description: |-
            Ступінь деталізації міркувань (рівень роздумів):
            - `low` – базова перевірка фактів;
            - `medium` - збалансований аналіз (за замовчуванням);
            - `high` - вичерпний покроковий аналіз;
            - `extra` / `max` - граничний рівень аналітики.
          example: medium
        session_id:
          type: string
          description: >-
            Публічний ідентифікатор чату (UUIDv4). Дозволяє зберігати контекст
            між запитами.
          example: f47ac10b-58cc-4372-a567-0e02b2c3d479
        regenerate:
          type: boolean
          description: Прапор примусової повторної генерації останньої відповіді.
        tools:
          type: array
          items:
            type: object
          description: >-
            Інструменти у форматі OpenAI. Працюють лише з агентським ключем
            (`sk-agent-…`); для чат-ключа ігноруються.
        tool_choice:
          description: Вибір інструмента у форматі OpenAI.
          oneOf:
            - type: string
            - type: object
        reasoning_effort:
          type: string
          description: Рівень міркувань у форматі OpenAI. Те саме, що `effort`.
        web_search:
          type: boolean
          description: Дозволити моделі пошук в інтернеті.
      description: >-
        Стандартні поля OpenAI `temperature`, `top_p`, `max_tokens`,
        `max_completion_tokens`, `stop`, `n` і `response_format` приймаються,
        але не застосовуються.
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          example: chatcmpl-9b2f6c1e4a7d4c0e9f1a2b3c
        session_id:
          type: string
          example: f47ac10b-58cc-4372-a567-0e02b2c3d479
        object:
          type: string
          example: chat.completion
        created:
          type: integer
          example: 1726838400
        model:
          type: string
          example: niya-1
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                example: 0
              message:
                type: object
                properties:
                  role:
                    type: string
                    example: assistant
                  content:
                    type: string
                    example: Здравствуйте! Чем я могу вам помочь?
                  reasoning:
                    type: string
                    description: Текст ланцюжка міркувань моделі (якщо включений thinking).
                  reasoning_content:
                    type: string
                    description: >-
                      Дублююче поле reasoning для сумісності з різними клієнтами
                      (DeepSeek/vLLM формат).
              finish_reason:
                type: string
                example: stop
        usage:
          type: object
          description: >-
            Витрата токенів. `prompt_tokens` включає кешовані токени,
            `total_tokens = prompt_tokens + completion_tokens`. `cost_credits` —
            списані AI-кредити.
          properties:
            prompt_tokens:
              type: integer
              example: 812
            completion_tokens:
              type: integer
              example: 96
            total_tokens:
              type: integer
              example: 908
            completion_tokens_details:
              type: object
              properties:
                reasoning_tokens:
                  type: integer
                  example: 0
            prompt_tokens_details:
              type: object
              properties:
                cached_tokens:
                  type: integer
                  example: 512
            cost_credits:
              type: number
              description: Списано AI-кредитів.
              example: 0.42
    ErrorResponse:
      type: object
      description: >-
        Помилка у форматі OpenAI. `code` — рядковий код OpenAI
        (`invalid_api_key`, `model_not_found`, `insufficient_quota`,
        `rate_limit_exceeded`) або `null`. Числовий код ER:LC Росія — в
        `erlc_code`, див. [коди помилок](/uk/documentation/error-codes).
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              example: Insufficient AI Credits
            type:
              type: string
              enum:
                - invalid_request_error
                - insufficient_quota
                - requests
                - server_error
              example: insufficient_quota
            param:
              type:
                - string
                - 'null'
              example: null
            code:
              type:
                - string
                - 'null'
              example: insufficient_quota
            erlc_code:
              type: string
              description: ER:LC Russia numeric error code.
              example: '5038'
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
          description: |-
            Роль автора повідомлення:
            - `system` - системні інструкції та правила поведінки моделі;
            - `user` - запит або репліка користувача;
            - `assistant` – попередня відповідь моделі для збереження контексту.
          example: user
        content:
          oneOf:
            - type: string
              description: Текстовий вміст повідомлення.
              example: Привет! Чем ты можешь помочь?
            - type: array
              description: Мультимодальний масив блоків (текст, зображення, файли).
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - text
                      - image_url
                      - file
                  text:
                    type: string
                  image_url:
                    type: object
                    properties:
                      url:
                        type: string
                        example: https://cdn.erlcrussia.com/images/screenshot.png
                  file:
                    type: object
                    properties:
                      url:
                        type: string
                      mime:
                        type: string
                      filename:
                        type: string
    FilePart:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - file
          example: file
        mime:
          type: string
          example: image/png
        filename:
          type: string
          example: screenshot.png
        url:
          type: string
          example: https://cdn.erlcrussia.com/images/screenshot.png
  headers:
    RequestId:
      description: Ідентифікатор запиту для підтримки.
      schema:
        type: string
        example: req_8f2c1e9b4a7d4c0e9f1a2b3c4d5e6f70
    ProcessingMs:
      description: Час обробки запиту в мілісекундах.
      schema:
        type: integer
        example: 412
    RateLimitRequests:
      description: Ліміт запитів у поточному вікні.
      schema:
        type: integer
        example: 120
    RateLimitRemainingRequests:
      description: Скільки запитів залишилося в поточному вікні.
      schema:
        type: integer
        example: 119
    RateLimitResetRequests:
      description: Через скільки скинеться ліміт, наприклад `1s` або `6m0s`.
      schema:
        type: string
        example: 1s
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Передача токена авторизації у заголовку Authorization: Bearer <token>.'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: erlcrussia-api-ai-key
      description: Ключ у заголовку erlcrussia-api-ai-key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.