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

# Risposta del modello

> Genera una risposta del modello nel formato OpenAI Chat Completions, come JSON o in streaming.



## OpenAPI

````yaml it/openapi/it-openai-api-openapi.yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: ER:LC Russia - API compatibile con OpenAI
  version: 1.0.0
  description: >-
    Metodi compatibili con OpenAI per Chat Completions, consultazione dei
    modelli e sintesi vocale ER:LC Russia. Consulta i parametri supportati nella
    pagina di ogni metodo.
servers:
  - url: https://api.erlcrussia.com
    description: Server principale
  - url: https://api.erlcrussia.xyz
    description: Server di backup
security: []
tags:
  - name: Audio
  - name: Chat Completions
  - name: Models
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Risposta del modello
      description: >-
        Genera una risposta del modello nel formato OpenAI Chat Completions,
        come JSON o in streaming.
      parameters:
        - name: X-Session-ID
          in: header
          required: false
          schema:
            type: string
          description: >-
            ID della sessione di conversazione (alternativa al campo session_id
            nel corpo).
      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: Risposta del modello o flusso di blocchi (SSE) riuscita.
          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: >-
                  Uno stream Server-Sent Events in formato OpenAI. Ogni evento è
                  una riga `data: {...}` con un oggetto `chat.completion.chunk`.
                  Il primo chunk ha `delta.role` uguale ad `assistant` e ogni
                  chunk ha `finish_reason`: `null` mentre la risposta arriva,
                  `stop` o `tool_calls` nell’ultimo. Con
                  `stream_options.include_usage: true` prima della fine arriva
                  un chunk con `choices: []` e `usage`. Lo stream termina con
                  `data: [DONE]`. Se la generazione si interrompe, arriva un
                  evento `{"error": {...}}` seguito da `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: Corpo della richiesta non valido.
          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: La chiave manca o non è valida.
          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: >-
            Limite di richieste superato (`type: requests`) o crediti IA
            esauriti (`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: Il modello non è temporaneamente disponibile, riprova più tardi.
          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: >-
            ID modello:

            - `niya-1` - Niya (modello principale per compiti generali e
            moderazione, contesto 1M)

            - `emmy-1` - Emmy (modello intellettuale con ragionamento passo
            passo, contesto 1M)

            - `hubert-1` - Hubert (modello personalizzato, contesto 1M)
          example: niya-1
        messages:
          type: array
          minItems: 1
          description: Un elenco dei messaggi precedenti nella conversazione.
          items:
            $ref: '#/components/schemas/ChatMessage'
        files:
          type: array
          description: Elenco aggiuntivo di file o immagini allegati alla richiesta.
          items:
            $ref: '#/components/schemas/FilePart'
        stream:
          type: boolean
          default: false
          description: >-
            Abilita lo streaming delle risposte agli eventi inviati dal server
            (SSE).
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
              default: false
              description: >-
                Se `true`, subito prima di `data: [DONE]` arriva un chunk
                separato con `choices` vuoto e il campo `usage`. Senza, lo
                stream non contiene `usage`.
        thinking:
          type: boolean
          description: >-
            Abilitazione della modalità di pensiero passo passo (catena di
            ragionamento).
          example: true
        surzhyk:
          type: boolean
          default: false
          description: >-
            Per il modello hubert-1 include un surzhik proprietario. Per
            impostazione predefinita, Hubert risponde nella lingua dell'ultimo
            messaggio dell'utente.
        effort:
          type: string
          enum:
            - low
            - medium
            - high
            - extra
            - max
          description: |-
            Grado di dettaglio del ragionamento (livello di riflessione):
            - `low` - verifica dei fatti di base;
            - `medium` — analisi bilanciata (predefinita);
            - `high`: analisi completa passo dopo passo;
            - `extra` / `max`: il massimo livello di analisi.
          example: medium
        session_id:
          type: string
          description: >-
            Identificatore della sessione di chat pubblica (UUIDv4). Consente di
            salvare il contesto tra le richieste.
          example: f47ac10b-58cc-4372-a567-0e02b2c3d479
        regenerate:
          type: boolean
          description: Flag per la rigenerazione forzata dell'ultima risposta.
        tools:
          type: array
          items:
            type: object
          description: >-
            Strumenti nel formato OpenAI. Funzionano solo con una chiave agente
            (`sk-agent-…`); con una chiave chat vengono ignorati.
        tool_choice:
          description: Scelta dello strumento nel formato OpenAI.
          oneOf:
            - type: string
            - type: object
        reasoning_effort:
          type: string
          description: Livello di ragionamento nel formato OpenAI. Uguale a `effort`.
        web_search:
          type: boolean
          description: Consente al modello di cercare sul web.
      description: >-
        I campi standard di OpenAI `temperature`, `top_p`, `max_tokens`,
        `max_completion_tokens`, `stop`, `n` e `response_format` sono accettati
        ma non applicati.
    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: >-
                      Testo della catena di ragionamento del modello (se il
                      pensiero è abilitato).
                  reasoning_content:
                    type: string
                    description: >-
                      Campo di ragionamento duplicato per compatibilità con
                      diversi client (formato DeepSeek/vLLM).
              finish_reason:
                type: string
                example: stop
        usage:
          type: object
          description: >-
            Consumo di token. `prompt_tokens` include i token in cache;
            `total_tokens = prompt_tokens + completion_tokens`. `cost_credits`
            sono i crediti IA addebitati.
          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: Crediti IA addebitati.
              example: 0.42
    ErrorResponse:
      type: object
      description: >-
        Un errore in formato OpenAI. `code` è un codice stringa OpenAI
        (`invalid_api_key`, `model_not_found`, `insufficient_quota`,
        `rate_limit_exceeded`) oppure `null`. Il codice numerico di ER:LC Russia
        è in `erlc_code`, vedi i [codici di
        errore](/it/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: >-
            Ruolo dell'autore del post:

            - `system` - istruzioni di sistema e regole di comportamento del
            modello;

            - `user`: richiesta o risposta dell'utente;

            - `assistant` - risposta del modello precedente per salvare il
            contesto.
          example: user
        content:
          oneOf:
            - type: string
              description: Contenuto testuale del messaggio.
              example: Привет! Чем ты можешь помочь?
            - type: array
              description: Serie multimodale di blocchi (testo, immagini, file).
              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: ID della richiesta per il supporto.
      schema:
        type: string
        example: req_8f2c1e9b4a7d4c0e9f1a2b3c4d5e6f70
    ProcessingMs:
      description: Tempo di elaborazione in millisecondi.
      schema:
        type: integer
        example: 412
    RateLimitRequests:
      description: Limite di richieste nella finestra corrente.
      schema:
        type: integer
        example: 120
    RateLimitRemainingRequests:
      description: Richieste rimaste nella finestra corrente.
      schema:
        type: integer
        example: 119
    RateLimitResetRequests:
      description: Tempo prima del reset del limite, ad esempio `1s` o `6m0s`.
      schema:
        type: string
        example: 1s
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Passaggio del token di autorizzazione nell'intestazione
        dell'autorizzazione: Bearer <token>.
    ApiKeyAuth:
      type: apiKey
      in: header
      name: erlcrussia-api-ai-key
      description: La chiave nell'header erlcrussia-api-ai-key.

````

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