---
title: "Chat Completions"
method: POST
path: "/v1/chat/completions"
tags: ["Chat"]
---

# Chat Completions

`POST /v1/chat/completions`

Creates a model response for the given chat conversation.

## Request body

- CreateChatCompletion
  - `messages` unknown[], required — A list of messages comprising the conversation so far.
    - unknown
  - `model` string, required — ID of the model to use. Call `/v1/models` endpoint to get the list of available models, only `text-generation` model type is supported.
  - `frequency_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
  - `logit_bias` object, nullable — Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
  - `logprobs` boolean, nullable — Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.
  - `top_logprobs` integer, nullable — An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
  - `presence_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
  - `max_completion_tokens` integer, nullable — An upper bound for the number of tokens that can be generated for a completion.
  - `n` integer, nullable — How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs.
  - `response_format` unknown
  - `seed` integer, nullable — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
  - `stop` union — Up to 4 sequences where the API will stop generating further tokens.
    - string
    - string[]
  - `stream` true | false, nullable — If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
  - `stream_options` unknown
  - `temperature` number, nullable — What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
  - `top_p` number, nullable — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.<br>We generally recommend altering this or `temperature` but not both.
  - `tools` object[], nullable
  - `tool_choice` string — Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.<br>`none` is the default when no tools are present. `auto` is the default if tools are present.
  - `parallel_tool_calls` boolean, nullable — Whether to call tools in parallel or sequentially. If true, the model will call tools in parallel. If false, the model will call tools sequentially. If None, the model will call tools in parallel if the model supports it, otherwise it will call tools sequentially.
  - `user` string, nullable — A unique identifier representing the user.

## Response `200`

Successful Response

- union
  - ChatCompletion
    - `id` string — A unique identifier for the chat completion.
    - `choices` OpenaiTypesChatChatCompletionChoice[], required
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', required
      - `index` integer, required
      - `logprobs` ChoiceLogprobs — Log probability information for the choice.
        - `content` ChatCompletionTokenLogprob[], nullable
          - `token` string, required
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `top_logprobs` TopLogprob[], required
            - `token` string, required
            - `bytes` integer[], nullable
            - `logprob` number, required
        - `refusal` ChatCompletionTokenLogprob[], nullable
          - `token` string, required
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `top_logprobs` TopLogprob[], required
            - `token` string, required
            - `bytes` integer[], nullable
            - `logprob` number, required
      - `message` ChatCompletionMessage, required — A chat completion message generated by the model.
        - `content` string, nullable
        - `refusal` string, nullable
        - `role` 'assistant', required
        - `annotations` Annotation[], nullable
          - `type` 'url_citation', required
          - `url_citation` AnnotationURLCitation, required — A URL citation when using web search.
            - `end_index` integer, required
            - `start_index` integer, required
            - `title` string, required
            - `url` string, required
        - `audio` ChatCompletionAudio — If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
          - `id` string, required
          - `data` string, required
          - `expires_at` integer, required
          - `transcript` string, required
        - `function_call` FunctionCall — Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
          - `arguments` string, required
          - `name` string, required
        - `tool_calls` union[], nullable
          - union
            - ChatCompletionMessageFunctionToolCall — A call to a function tool created by the model.
              - …
            - ChatCompletionMessageCustomToolCall — A call to a custom tool created by the model.
              - …
    - `created` integer, required
    - `model` string, required
    - `object` 'chat.completion', required
    - `service_tier` 'auto' | 'default' | 'flex' | 'scale' | 'priority', nullable
    - `system_fingerprint` string, nullable
    - `usage` ApiSchemasUsageUsage
      - `prompt_tokens` integer — Number of prompt tokens (e.g. input tokens).
      - `completion_tokens` integer — Number of completion tokens (e.g. output tokens).
      - `total_tokens` integer — Total number of tokens (e.g. input and output tokens).
      - `cost` number — Total cost of the request.
      - `carbon` CarbonFootprintUsage
        - `kWh` CarbonFootprintUsageKWh
          - `min` number — Minimum carbon footprint in kWh.
          - `max` number — Maximum carbon footprint in kWh.
        - `kgCO2eq` CarbonFootprintUsageKgCO2eq
          - `min` number — Minimum carbon footprint in kgCO2eq (global warming potential).
          - `max` number — Maximum carbon footprint in kgCO2eq (global warming potential).
      - `impacts` ApiSchemasUsageEnvironmentalImpacts
        - `kWh` number — Carbon footprint in kWh.
        - `kgCO2eq` number — Carbon footprint in kgCO2eq (global warming potential).
      - `requests` integer — Number of model requests.
  - ChatCompletionChunk
    - `id` string, required
    - `choices` OpenaiTypesChatChatCompletionChunkChoice[], required
      - `delta` ChoiceDelta, required — A chat completion delta generated by streamed model responses.
        - `content` string, nullable
        - `function_call` ChoiceDeltaFunctionCall — Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
          - `arguments` string, nullable
          - `name` string, nullable
        - `refusal` string, nullable
        - `role` 'developer' | 'system' | 'user' | 'assistant' | 'tool', nullable
        - `tool_calls` ChoiceDeltaToolCall[], nullable
          - `index` integer, required
          - `id` string, nullable
          - `function` ChoiceDeltaToolCallFunction
            - `arguments` string, nullable
            - `name` string, nullable
          - `type` 'function', nullable
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', nullable
      - `index` integer, required
      - `logprobs` ChoiceLogprobs — Log probability information for the choice.
        - `content` ChatCompletionTokenLogprob[], nullable
          - `token` string, required
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `top_logprobs` TopLogprob[], required
            - `token` string, required
            - `bytes` integer[], nullable
            - `logprob` number, required
        - `refusal` ChatCompletionTokenLogprob[], nullable
          - `token` string, required
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `top_logprobs` TopLogprob[], required
            - `token` string, required
            - `bytes` integer[], nullable
            - `logprob` number, required
    - `created` integer, required
    - `model` string, required
    - `object` 'chat.completion.chunk', required
    - `service_tier` 'auto' | 'default' | 'flex' | 'scale' | 'priority', nullable
    - `system_fingerprint` string, nullable
    - `usage` CompletionUsage — Usage statistics for the completion request.
      - `completion_tokens` integer, required
      - `prompt_tokens` integer, required
      - `total_tokens` integer, required
      - `completion_tokens_details` CompletionTokensDetails — Breakdown of tokens used in a completion.
        - `accepted_prediction_tokens` integer, nullable
        - `audio_tokens` integer, nullable
        - `reasoning_tokens` integer, nullable
        - `rejected_prediction_tokens` integer, nullable
      - `prompt_tokens_details` PromptTokensDetails — Breakdown of tokens used in the prompt.
        - `audio_tokens` integer, nullable
        - `cached_tokens` integer, nullable

## Other responses

- `404` — Model not found. Collection not found.
- `422` — Wrong model type.
- `503` — Model is too busy, please try again later.

---

[API](https://skmtc.net/betagouv/apis/opengatellm.md) · [All operations](https://skmtc.net/betagouv/apis/opengatellm/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/betagouv/opengatellm/versions/f2624a610e5a/schema)
