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

# Create chat completion

`POST /chat/completions`

Generates a completion for the supplied prompt. Streaming mode is supported. All extra options described in the documentation are optional and follow the OpenAI‑compatible naming.

## Request body

- CreateChatCompletionDto — Request body for `POST /v1/chat/completion`. All fields follow the OpenAI naming; fields marked *optional* are not required.
  - `model` string, required — The unique identifier of the model to use.
  - `messages` ChatCompletionMessage[], required — Array of chat messages that form the prompt.
    - `role` 'system' | 'assistant' | 'user', required — Who sent the message.
    - `content` string, required — The textual content of the message.
  - `stream` boolean — If true, the server streams tokens as they are generated.
  - `max_tokens` integer — Maximum number of tokens to generate.
  - `stop` string[] — Stop sequences – generation stops before emitting any of these strings.
  - `temperature` number — Adjusts randomness of the output.
  - `dynatemp_range` number — Dynamic‑temperature range – final temperature is sampled from `[temperature‑range, temperature+range]`.
  - `dynatemp_exponent` number — Exponent for dynamic‑temperature scaling.
  - `top_k` integer — Restricts sampling to the K most probable tokens.
  - `top_p` number — Nucleus sampling cutoff (cumulative probability).
  - `min_p` number — Minimum probability for a token to be considered relative to the most likely token.
  - `typical_p` number — Enable locally typical sampling with parameter p.
  - `n_predict` integer — Maximum number of tokens to predict; -1 = unlimited, 0 = evaluate prompt only.
  - `n_indent` integer — Minimum line indentation for generated code.
  - `n_keep` integer — Tokens from the prompt to retain when context is exceeded. 0 = none, -1 = all.
  - `presence_penalty` number — Presence penalty (0.0 = disabled).
  - `frequency_penalty` number — Frequency penalty (0.0 = disabled).
  - `repeat_penalty` number — Repetition penalty for token sequences.
  - `repeat_last_n` integer — How many last tokens to consider for repeat penalty (0 = disabled, -1 = context size).
  - `dry_multiplier` number — DRY (Don’t Repeat Yourself) multiplier (0.0 = disabled).
  - `dry_base` number — DRY base value.
  - `dry_allowed_length` integer — Length after which DRY penalty grows exponentially.
  - `dry_penalty_last_n` integer — How many tokens to scan for DRY repetitions (0 = disabled, -1 = context size).
  - `dry_sequence_breakers` string[] — Sequence breakers for DRY sampling.
  - `xtc_probability` number — Probability for token removal via XTC sampler (0.0 = disabled).
  - `xtc_threshold` number — Minimum probability threshold for XTC.
  - `mirostat` integer — Enable Mirostat sampling (0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0).
  - `mirostat_tau` number — Target entropy for Mirostat.
  - `mirostat_eta` number — Learning rate for Mirostat.
  - `grammar` string — Grammar for grammar‑based sampling.
  - `json_schema` object — JSON schema for grammar‑based sampling.
  - `seed` integer — RNG seed; -1 = random.
  - `ignore_eos` boolean — Continue generating after EOS token.
  - `logit_bias` object — Modify the likelihood of a token appearing. Accepts a JSON object mapping token IDs to a bias value from -100 to 100, or `false` to ban a token.
  - `n_probs` integer — If > 0, top-N token probabilities are returned.
  - `min_keep` integer — Force samplers to return at least N tokens.
  - `t_max_predict_ms` integer — Maximum generation time in milliseconds (0 = disabled).
  - `id_slot` integer — Assign the request to a specific inference slot (-1 = auto).
  - `cache_prompt` boolean — Reuse KV cache from previous requests when possible.
  - `return_tokens` boolean — Include raw token IDs in the response.
  - `samplers` string[] — Ordered list of samplers to apply.
  - `timings_per_token` boolean — Include timing information per token.
  - `return_progress` boolean — Include prompt‑processing progress when streaming.
  - `post_sampling_probs` boolean — Return top‑N probabilities *after* sampling.
  - `response_fields` string[] — Select which fields to include in the response.
  - `lora` object[] — LoRA adapters to apply for this request.
    - `id` integer, required
    - `scale` number, required
  - `multimodal_data` string[] — Base64‑encoded multimodal data (images, audio, …). Must match the number of `<__media__>` markers in the prompt.

## Response `200`

Completion result

- ChatCompletionResponseDto — Response from `POST /v1/chat/completion`.
  - `id` string, required — Unique identifier for the completion.
  - `object` 'chat.completion', required
  - `created` integer, required — Unix timestamp of creation.
  - `model` string, required — Model used for the completion.
  - `choices` ChoiceDto[], required — List of generated choices.
    - `index` integer, required
    - `message` ChatCompletionMessage, required — A single turn in a chat conversation.
      - `role` 'system' | 'assistant' | 'user', required — Who sent the message.
      - `content` string, required — The textual content of the message.
    - `finish_reason` string, required — Why the generation stopped (e.g., `stop`, `length`, `model`).
    - `logprobs` ChatChoiceLogprobs[], nullable — Log probability information for the choice, if requested.
      - `id` integer — The token ID.
      - `token` string — The most likely token.
      - `logprob` number — The log probability of the most likely token.
      - `prob` number — The probability of the most likely token (if post_sampling_probs is true).
      - `bytes` integer[] — The most likely token represented as a list of bytes.
      - `top_logprobs` LogprobContent[] — List of the most likely tokens and their log probs.
        - `id` integer — The token ID.
        - `token` string — The token string.
        - `logprob` number — The log probability of this token.
        - `prob` number — The probability of this token (if post_sampling_probs is true).
        - `bytes` integer[] — The token represented as a list of bytes.
      - `top_probs` LogprobContent[] — List of the most likely tokens and their probs (if post_sampling_probs is true).
        - `id` integer — The token ID.
        - `token` string — The token string.
        - `logprob` number — The log probability of this token.
        - `prob` number — The probability of this token (if post_sampling_probs is true).
        - `bytes` integer[] — The token represented as a list of bytes.
  - `usage` UsageDto, required — Token usage statistics.
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required
  - `system_fingerprint` string — Fingerprint of the system configuration used.
  - `generation_settings` object — The generation settings used for the completion.
  - `prompt` string — The processed prompt.
  - `truncated` boolean — True if the context size was exceeded.
  - `tokens_cached` integer — Number of tokens from the prompt which were reused from a cache.
  - `tokens_evaluated` integer — Number of tokens evaluated in total from the prompt.

## Changes

- **2025-09-19** `2b68043ead73` — 1 info
  - endpoint added
- **2025-09-19** `97bc26aa608a` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/janhq/apis/jan-api-server-endpoints/changes/chat/completions/post.md)

---

[API](https://skmtc.dev/janhq/apis/jan-api-server-endpoints.md) · [All operations](https://skmtc.dev/janhq/apis/jan-api-server-endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/janhq/jan-api-server-endpoints/revisions/8e64bd346c2f/schema)
