---
title: "Create completion"
method: POST
path: "/2/ai/{product_id}/openai/v1/completions"
tags: ["Usage > V2 > OpenAI-compatible"]
---

# Create completion

`POST /2/ai/{product_id}/openai/v1/completions`

OpenAI compatible completion, see the [OpenAI documentation](https://developers.openai.com/api/reference/resources/completions/methods/create).
<br><br>
Some models are in **beta** and may being subject to changes,
use [GET `/1/ai/models`](/docs/api/get/1/ai/models) to check what model are in **beta**
and see our [General Terms and Conditions](https://www.infomaniak.com/gtl/rgpd.documents).
<br><br>
List of models available on this endpoint could be retrieve with [GET `/2/ai/{product_id}/openai/v1/models`](/docs/api/get/2/ai/{product_id}/openai/v1/models).

## Path parameters

- `product_id` integer, required

## Request body

- object
  - `best_of` number, double — Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.<br>When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than n.<br>**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`.
  - `echo` boolean — Echo back the prompt in addition to the completion.
  - `frequency_penalty` number, double — 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.<br>See [more information about frequency and presence penalties (OpenAI)](https://developers.openai.com/docs/guides/text-generation).
  - `logit_bias` unknown[] — Modify the likelihood of specified tokens appearing in the completion.<br>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`. You can use this [OpenAI tokenizer tool](https://developers.openai.com/tokenizer?view=bpe) to convert text to token IDs. 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.<br>As an example, you can pass `{"50256": -100}` to prevent the `<|endoftext|>` token from being generated.
    - unknown
  - `logprobs` number, double — Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to `logprobs+1` elements in the response.
  - `max_tokens` integer — The maximum number of tokens that can be generated in the completion.<br>The token count of your prompt plus max_tokens cannot exceed the model’s context length.
  - `model` string, required — Model name used to generate the response, like `qwen3` or `swiss-ai/Apertus-70B-Instruct-2509`. Infomaniak offers a wide range of models with different capabilities, performance characteristics, and price points. Use the endpoint [GET `/1/ai/models`](/docs/api/get/1/ai/models) to retrieve the models list with various informations.
  - `n` integer — How many completions to generate for each prompt.<br>**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`.
  - `presence_penalty` number, double — 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.<br>See [more information about frequency and presence penalties (OpenAI)](https://developers.openai.com/docs/guides/text-generation).
  - `prompt` array[]
    - number[] — The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.<br>Note that `<|endoftext|>` is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.
  - `seed` number, double — 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.<br>Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.<br>Format: `int64`.
  - `stop` string — Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
  - `stream` boolean — Whether to stream back partial progress. If set, 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.
  - `stream_options` object — Options for streaming response. Only set this when you set `stream: true`.
    - `include_obfuscation` boolean — When true, stream obfuscation will be enabled. Stream obfuscation adds random characters to an `obfuscation` field on streaming delta events to normalize payload sizes as a mitigation to certain side-channel attacks. These obfuscation fields are included by default, but add a small amount of overhead to the data stream. You can set `include_obfuscation` to false to optimize for bandwidth if you trust the network links between your application and the OpenAI API.
    - `include_usage` boolean — If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array.<br>All other chunks will also include a usage field, but with a null value.<br>**Note**: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request.
  - `temperature` number, double — *Defaults to* `1`<br>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, double — <i>Defaults to</i> `1`<br>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.<br>We generally recommend altering this or `temperature` but not both.
  - `user` string — A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. See [OpenAI documentation to learn more](https://developers.openai.com/docs/guides/safety-best-practices#end-user-ids)

## Response `200`

OK

- 4cee7ea0OpenAiV1Completions — OpenAI response format of /v1/completions
  - `id` string, required — A unique identifier for the chat completion.
  - `object` string, required — The object type, which is always `text_completion`
  - `created` integer, required — The Unix timestamp (in seconds) of when the response was created.
  - `model` string, required — The model used for the chat completion.
  - `choices` 4cee7ea0OpenAiV1CompletionsChoice[], required
    - `index` integer, required
    - `text` string, required
    - `logprobs` 4cee7ea0OpenAiV1CompletionsLogprobs, required — Log probability information.
      - `text_offset` number[], required
      - `token_logprobs` number[], required
      - `tokens` string[], required
      - `top_logprobs` unknown[], required
        - unknown
    - `finish_reason` string, required — In `"stop"`, `"length"`, `"content_filter"`.<br>The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters.
  - `system_fingerprint` string, nullable, required — This fingerprint represents the backend configuration that the model runs with.<br>Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.
  - `usage` 4cee7ea0OpenAiCompletionUsage, required — Usage statistics for the completion request.
    - `prompt_tokens` integer, required — Number of tokens in the prompt.
    - `completion_tokens` integer, required — Number of tokens in the generated completion.
    - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
    - `prompt_tokens_details` 4cee7ea0OpenAiCompletionUsagePromptTokensDetails, required — Breakdown of tokens used in the prompt.
      - `audio_tokens` integer, required — Audio input tokens present in the prompt.
      - `cached_tokens` integer, required — Cached tokens present in the prompt.
    - `completion_tokens_details` 4cee7ea0OpenAiCompletionUsageCompletionTokensDetails, required — Breakdown of tokens used in a completion
      - `accepted_prediction_tokens` integer, required — When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
      - `audio_tokens` integer, required — Audio input tokens generated by the model.
      - `reasoning_tokens` integer, required — Tokens generated by the model for reasoning.
      - `rejected_prediction_tokens` integer, required — When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.

---

[API](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools.md) · [All operations](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools/llms.txt) · [OpenAPI document](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools/revisions/7389fd9b99ee?raw)
