---
title: "Creates a completion for the chat message"
method: POST
path: "/chat/completions"
---

# Creates a completion for the chat message

`POST /chat/completions`

Creates a completion for the chat message

## Query parameters

- `api-version` string, required — api version

## Request body

- object
  - `messages` object[], required — The messages to generate chat completions for, in the chat format.
    - `role` 'system' | 'user' | 'assistant', required — The role of the author of this message.
    - `content` string, required — The contents of the message
    - `name` string — The name of the user in a multi-user chat
  - `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. We generally recommend altering this or `temperature` but not both.
  - `n` integer, nullable — How many chat completion choices to generate for each input message.
  - `stream` boolean, nullable — If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.
  - `stop` union — Up to 4 sequences where the API will stop generating further tokens.
    - string, nullable
    - string[] — Array minimum size of 1 and maximum of 4
  - `max_tokens` integer — The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).
  - `presence_penalty` number — 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.
  - `frequency_penalty` number — 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.
  - `user` string — A unique identifier representing your end-user, which can help Azure OpenAI to monitor and detect abuse.

## Response `200`

OK

- object
  - `id` string, required
  - `object` string, required
  - `created` integer, required
  - `model` string, required
  - `choices` object[], required
    - `index` integer
    - `message` object
      - `role` 'system' | 'user' | 'assistant', required — The role of the author of this message.
      - `content` string, required — The contents of the message
    - `finish_reason` string
  - `usage` object
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required

---

[API](https://skmtc.dev/azure/apis/gpt-4.md) · [All operations](https://skmtc.dev/azure/apis/gpt-4/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/azure/gpt-4/revisions/f41ec1ae9100/schema)
