v1

latestSwagger 2.02026-07-1745767.1 KB

Gets chat completions for the provided chat messages. Completions support a wide variety of tasks and generate text that continues from or "completes" provided prompt data. The method makes a REST API call to the /chat/completions route on the given endpoint.

Deprecated: This API is deprecated. Use the OpenAI API instead. See migration guide.

post/chat/completions

Query parameters

api-versionstring required

The API version to use for this operation.

Headers

extra-parameters'error' | 'drop' | 'pass-through'

Controls what happens if extra parameters, undefined by the REST API, are passed in the JSON request payload. This sets the HTTP request header extra-parameters.

Request body

frequency_penaltynumber float

A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text. Positive values will make tokens less likely to appear as their frequency increases and decrease the likelihood of the model repeating the same statements verbatim. Supported range is [-2, 2].

streamboolean

A value indicating whether chat completions should be streamed for this request.

presence_penaltynumber float

A value that influences the probability of generated tokens appearing based on their existing presence in generated text. Positive values will make tokens less likely to appear when they already exist and increase the model's likelihood to output new topics. Supported range is [-2, 2].

temperaturenumber float

The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict. Supported range is [0, 1].

top_pnumber float

An alternative to sampling with temperature called nucleus sampling. This value causes the model to consider the results of tokens with the provided probability mass. As an example, a value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be considered. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict. Supported range is [0, 1].

max_tokensinteger

The maximum number of tokens to generate.

stopstring[]

A collection of textual sequences that will end completions generation.

{"stackTrail":"components:schemas:ChatCompletionsOptions:properties:tool_choice","oasType":"schema","type":"unknown","description":"If specified, the model will configure which of the provided tools it can use for the chat completions response.","extensionFields":{"x-ms-client-name":"toolChoice"}}
seedinteger

If specified, the 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.

modelstring

ID of the specific AI model to use, if more than one model is available on the endpoint.

modalitiesChatCompletionsModality[]

The modalities that the model is allowed to use for the chat completions response. The default modality is text. Indicating an unsupported modality combination results in a 422 error.

Response

The request has succeeded.

idstring required

A unique identifier associated with this chat completions response.

object'chat.completion' required

The response object type, which is always chat.completion.

createdinteger required

The first timestamp associated with generation activity for this completions response, represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.

modelstring required

The model used for the chat completion.

All 4 operations