---
title: "Create chat completion"
method: POST
path: "/v1/chat/completions"
tags: ["inference"]
---

# Create chat completion

`POST /v1/chat/completions`

Creates a model response for the given chat conversation.

## Query parameters

- `ai_project_id` string, nullable — current project ID

## Request body

- ChatCompletionRequest
  - `model` string, required — ID of the model to use.
  - `store` boolean, nullable — Whether or not to store the output of this chat completion request for use in our model distillation.
  - `messages` ChatCompletionMessage[], required — A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models).
    - `role` 'system' | 'user' | 'assistant' | 'tool', required
    - `content` union — The contents of the message.
      - string
      - union[]
        - union
          - ChatCompletionContentPartTextParam
            - `text` string, required — The text content.
            - `type` 'text', required — The type of the content part.
          - ChatCompletionContentPartImageParam
            - `image_url` ImageURL, required
              - …
            - `type` 'image_url', required — The type of the content part.
          - ChatCompletionContentPartVideoParam
            - `video_url` VideoURL, required
              - …
            - `type` 'video_url', required — The type of the content part.
    - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role
    - `tool_calls` ToolCall[], nullable — The tool calls generated by the model, such as function calls.
      - `id` string
      - `type` 'function'
      - `function` FunctionCall, required
        - `name` string, required
        - `arguments` string, required
    - `tool_call_id` string, nullable — Tool call that this message is responding to.
    - `reasoning_content` string, nullable — The reasoning content of the message.
    - `reasoning` string, nullable — The reasoning content of the message.
  - `max_tokens` integer, nullable — The maximum number of tokens that can be generated in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. If omitted or set to null, defaults to 8192 tokens.
  - `max_completion_tokens` integer, nullable — An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
  - `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.
  - `tools` ChatCompletionTool[], nullable
    - `type` 'function' — The type of the tool. Currently, only `function` is supported.
    - `function` FunctionObject, required
      - `name` string, required — The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
      - `description` string, nullable — A description of what the function does, used by the model to choose when and how to call the function.
      - `parameters` object, nullable — The parameters the function accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.
      - `strict` boolean, nullable — Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is true.
      - `defer_loading` boolean, nullable — Non-OpenAI hint for the deferred-tool-calling runtime (e.g. Kimi K2.7 Code): preserved and forwarded to the inference engine instead of being silently dropped during request (de)serialization.
  - `tool_choice` union
    - 'none'
    - 'auto'
    - 'required'
    - ChatCompletionNamedToolChoice
      - `type` 'function' — Specifies that the tool choice is a function.
      - `function` ChatCompletionNamedFunction, required
        - `name` string, required — Specifies the name of the function the model should call.
  - `reasoning_effort` union
    - 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
    - 'max'
  - `n` integer, nullable — How many completions to generate for each prompt. **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.
  - `stream` boolean, nullable — If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
  - `stream_options` object, nullable — If set to {"include_usage": True}, usage stats will be sent with the last chunk of data[Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions)
  - `stop` string[], nullable — Up to 4 sequences where the API will stop generating further tokens.
  - `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. [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
  - `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. [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
  - `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 GPT 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. As an example, you can pass `{"50256": -100}` to prevent the token from being generated.
  - `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 non-negative integer 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.
  - `user` string, nullable — A unique identifier representing your end-user, which can help us to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids).
  - `response_format` AppModelsChatCompletionResponseFormat
    - `type` 'text' | 'json_object' | 'json_schema', required
    - `json_schema` JsonSchemaResponseFormat
      - `name` string, required
      - `description` string, nullable
      - `schema` object, nullable, required
      - `strict` boolean, nullable
  - `extra_body` object, nullable — To provide extra parameters.
  - `service_tier` 'auto' | 'default' | 'over-limit' | 'flex' | 'no-limit' — Represents the service tier for requests. Attributes: Auto: Automatically choose the best available tier for the request (Default or OverLimit). Analyze response to determine which tier was used. Default: Return 429 errors on hitting the rate limit, do not exceed to the OverLimit tier. OverLimit: Indicate that the request was over the user limit. This tier cannot be set by user in the request, but us used in a response for tier=Auto. Flex: Do not consume rate-limit credits, but run with lower priority. May still result in 429 errors in case of if there is no resources to process.

## Response `200`

OK

- union
  - ChatCompletionResponse
    - `id` string, required — A unique identifier for the chat completion.
    - `object` 'chat.completion', required
    - `created` integer, required — The Unix timestamp (in seconds) of when the chat completion was created.
    - `model` string, required — The model used for the chat completion.
    - `choices` ChatCompletionChoice[], required — A list of chat completion choices. Can be more than one if `n` is greater than 1.
      - `index` integer, required — The index of the choice in the list of choices.
      - `message` ChatCompletionResponseMessage, required
        - `role` 'system' | 'user' | 'assistant' | 'tool', required
        - `content` string, nullable — The contents of the message.
        - `tool_calls` ToolCall[], nullable — The tool calls generated by the model, such as function calls.
          - `id` string
          - `type` 'function'
          - `function` FunctionCall, required
            - `name` string, required
            - `arguments` string, required
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter', required
      - `logprobs` ChatCompletionLogprobs, required
        - `content` ChatCompletionTokenLogprob[], nullable, required — A list of message content tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
          - `bytes` integer[], nullable, required — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
          - `top_logprobs` ChatCompletionTopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
            - `bytes` integer[], nullable, required — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
    - `usage` Usage, required
      - `completion_tokens` integer, required — Number of tokens in the generated completion.
      - `prompt_tokens` integer, required — Number of tokens in the prompt.
      - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
      - `prompt_tokens_details` PromptTokensDetails
        - `cached_tokens` integer, nullable
      - `completion_tokens_details` CompletionTokensDetails
        - `reasoning_tokens` integer, nullable
    - `service_tier` 'auto' | 'default' | 'over-limit' | 'flex' | 'no-limit', required — Represents the service tier for requests. Attributes: Auto: Automatically choose the best available tier for the request (Default or OverLimit). Analyze response to determine which tier was used. Default: Return 429 errors on hitting the rate limit, do not exceed to the OverLimit tier. OverLimit: Indicate that the request was over the user limit. This tier cannot be set by user in the request, but us used in a response for tier=Auto. Flex: Do not consume rate-limit credits, but run with lower priority. May still result in 429 errors in case of if there is no resources to process.
  - ChatCompletionChunk
    - `id` string, required — A unique identifier for the chat completion. Each chunk has the same ID.
    - `choices` ChatCompletionStreamChoice[], required — A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the; last chunk if you set `stream_options: {"include_usage": true}`.
      - `index` integer, required — The index of the choice in the list of choices.
      - `delta` ChatCompletionStreamResponseDelta, required
        - `content` string, nullable — The contents of the chunk message.
        - `role` 'system' | 'user' | 'assistant' | 'tool', required
        - `tool_calls` ToolCall[], nullable — The tool calls generated by the model, such as function calls.
          - `id` string
          - `type` 'function'
          - `function` FunctionCall, required
            - `name` string, required
            - `arguments` string, required
        - `reasoning_content` string, nullable — The reasoning content of the message.
        - `reasoning` string, nullable — The reasoning content of the message.
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter', required
      - `logprobs` ChatCompletionLogprobs, required
        - `content` ChatCompletionTokenLogprob[], nullable, required — A list of message content tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
          - `bytes` integer[], nullable, required — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
          - `top_logprobs` ChatCompletionTopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
            - `bytes` integer[], nullable, required — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
    - `created` integer, required — The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.
    - `model` string, required — The model to generate the completion.
    - `system_fingerprint` string, required — This fingerprint represents the backend configuration that the model runs with.; Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
    - `object` 'chat.completion.chunk', required
    - `usage` Usage, required
      - `completion_tokens` integer, required — Number of tokens in the generated completion.
      - `prompt_tokens` integer, required — Number of tokens in the prompt.
      - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
      - `prompt_tokens_details` PromptTokensDetails
        - `cached_tokens` integer, nullable
      - `completion_tokens_details` CompletionTokensDetails
        - `reasoning_tokens` integer, nullable

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/nebius/apis/nebius-openai-compatible-inference-api.md) · [All operations](https://skmtc.net/nebius/apis/nebius-openai-compatible-inference-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nebius/nebius-openai-compatible-inference-api/revisions/0fb323abba3c/schema)
