For the complete documentation index, see llms.txt. This page is also available as Markdown.

Chat

Chat Completions

post

Creates a model response for the given chat conversation.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
modelstringRequired

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_penaltynumber · nullableOptional

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.

Default: 0
logprobsboolean · nullableOptional

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.

Default: false
top_logprobsinteger · nullableOptional

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_penaltynumber · nullableOptional

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.

Default: 0
max_completion_tokensinteger · nullableOptional

An upper bound for the number of tokens that can be generated for a completion.

ninteger · nullableOptional

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.

Default: 1
response_formatany · nullableOptional

Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide. Setting to { "type": "json_object" } enables JSON mode, which ensures the message the model generates is valid JSON.
Important: when using JSON mode, you must also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length.

seedinteger · nullableOptional

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.

stopany of · nullableOptional

Up to 4 sequences where the API will stop generating further tokens.

stringOptional
or
string[]Optional
streamboolean · enum · nullableOptional

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.

Default: falsePossible values:
stream_optionsany · nullableOptional

Options for streaming response. Only set this when you set stream: true.

temperaturenumber · nullableOptional

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_pnumber · nullableOptional

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.
We generally recommend altering this or temperature but not both.

toolsany of · nullableOptional

A list of tools the model may call. Currently, only functions are supported as a tool.

or
nullOptional
tool_choiceanyOptional

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.
none is the default when no tools are present. auto is the default if tools are present.

Default: none
parallel_tool_callsboolean · nullableOptional

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.

Default: false
userstring · nullableOptional

A unique identifier representing the user.

Other propertiesanyOptional
Responses
200

Successful Response

application/json
or
post/v1/chat/completions
POST /v1/chat/completions HTTP/1.1
Host: albert.api.etalab.gouv.fr
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 440

{
  "messages": [],
  "model": "text",
  "frequency_penalty": 0,
  "logit_bias": {
    "ANY_ADDITIONAL_PROPERTY": 1
  },
  "logprobs": false,
  "top_logprobs": 1,
  "presence_penalty": 0,
  "max_completion_tokens": 1,
  "n": 1,
  "response_format": null,
  "seed": 1,
  "stop": "text",
  "stream": false,
  "stream_options": null,
  "temperature": 1,
  "top_p": 1,
  "tools": [
    {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "tool_choice": "none",
  "parallel_tool_calls": false,
  "user": "text",
  "ANY_ADDITIONAL_PROPERTY": "anything"
}
{
  "id": "text",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 1,
      "logprobs": {
        "content": [
          {
            "token": "text",
            "bytes": [
              1
            ],
            "logprob": 1,
            "top_logprobs": [
              {
                "token": "text",
                "bytes": [
                  1
                ],
                "logprob": 1,
                "ANY_ADDITIONAL_PROPERTY": "anything"
              }
            ],
            "ANY_ADDITIONAL_PROPERTY": "anything"
          }
        ],
        "refusal": [
          {
            "token": "text",
            "bytes": [
              1
            ],
            "logprob": 1,
            "top_logprobs": [
              {
                "token": "text",
                "bytes": [
                  1
                ],
                "logprob": 1,
                "ANY_ADDITIONAL_PROPERTY": "anything"
              }
            ],
            "ANY_ADDITIONAL_PROPERTY": "anything"
          }
        ],
        "ANY_ADDITIONAL_PROPERTY": "anything"
      },
      "message": {
        "content": "text",
        "refusal": "text",
        "role": "text",
        "annotations": [
          {
            "type": "text",
            "url_citation": {
              "end_index": 1,
              "start_index": 1,
              "title": "text",
              "url": "text",
              "ANY_ADDITIONAL_PROPERTY": "anything"
            },
            "ANY_ADDITIONAL_PROPERTY": "anything"
          }
        ],
        "audio": {
          "id": "text",
          "data": "text",
          "expires_at": 1,
          "transcript": "text",
          "ANY_ADDITIONAL_PROPERTY": "anything"
        },
        "function_call": {
          "arguments": "text",
          "name": "text",
          "ANY_ADDITIONAL_PROPERTY": "anything"
        },
        "tool_calls": [
          {
            "id": "text",
            "function": {
              "arguments": "text",
              "name": "text",
              "ANY_ADDITIONAL_PROPERTY": "anything"
            },
            "type": "text",
            "ANY_ADDITIONAL_PROPERTY": "anything"
          }
        ],
        "ANY_ADDITIONAL_PROPERTY": "anything"
      },
      "ANY_ADDITIONAL_PROPERTY": "anything"
    }
  ],
  "created": 1,
  "model": "text",
  "object": "text",
  "service_tier": "auto",
  "system_fingerprint": "text",
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "cost": 0,
    "impacts": {
      "kWh": 0,
      "kgCO2eq": 0,
      "ANY_ADDITIONAL_PROPERTY": "anything"
    },
    "requests": 0,
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "ANY_ADDITIONAL_PROPERTY": "anything"
}

Last updated

Was this helpful?