# Create completion - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/api-reference/model-apis-llm-create-completion

# Create completion

POST

/

openai

/

v1

/

completions

Try it

Create completion

cURL

```
curl --request POST \
--url https://api.novita.ai/openai/v1/completions \
--header 'Authorization: &#x3C;authorization>' \
--header 'Content-Type: &#x3C;content-type>' \
--data '
{
"model": "&#x3C;string>",
"prompt": "&#x3C;string>",
"max_tokens": 123,
"stream": {},
"stream_options": {
"include_usage": true
},
"n": {},
"seed": {},
"frequency_penalty": {},
"presence_penalty": {},
"repetition_penalty": {},
"stop": {},
"temperature": {},
"top_p": {},
"top_k": {},
"min_p": {},
"logit_bias": {},
"logprobs": {},
"best_of": 123
}
'
```

200

```
{
"choices": [
{
"finish_reason": "&#x3C;string>",
"index": 123,
"logprobs": {
"text_offset": [
{}
],
"token_logprobs": [
{}
],
"tokens": [
{}
],
"top_logprobs": [
{
"{key}": 123
}
]
},
"text": "&#x3C;string>"
}
],
"created": 123,
"id": "&#x3C;string>",
"model": "&#x3C;string>",
"object": "&#x3C;string>",
"usage": {
"completion_tokens": 123,
"prompt_tokens": 123,
"total_tokens": 123
}
}
```

Creates a completion for the provided prompt and parameters.

##

[​](#request-headers)

Request Headers

[​](#param-content-type)

Content-Type

string

required

Enum: `application/json`

[​](#param-authorization)

Authorization

string

required

Bearer authentication format, for example: Bearer {{API Key}}.

##

[​](#request-body)

Request Body

[​](#param-model)

model

string

required

The name of the model to use.

[​](#param-prompt)

prompt

string

required

The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

[​](#param-max-tokens)

max_tokens

integer

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.

[​](#param-stream)

stream

boolean | null

default:false

Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events (SSE) as they become available, with the stream terminated by a `data: [DONE]` message.

[​](#param-stream-options)

stream_options

object | null

Options for streaming response. Only set this when you set stream: true.

Show properties

[​](#param-include-usage)

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. All other chunks will also include a usage field, but with a null value.

[​](#param-n)

n

integer | null

default:1

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.Required range: `1 < x < 128`

[​](#param-seed)

seed

integer | null

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.

[​](#param-frequency-penalty)

frequency_penalty

number | null

default: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.Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition.See also presence_penalty for penalizing tokens that have at least one appearance at a fixed rate.Required range: `-2 < x < 2`

[​](#param-presence-penalty)

presence_penalty

number | null

default: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.Reasonable value is around 0.1 to 1 if the aim is to just reduce repetitive samples somewhat. If the aim is to strongly suppress repetition, then one can increase the coefficients up to 2, but this can noticeably degrade the quality of samples. Negative values can be used to increase the likelihood of repetition.See also `frequency_penalty` for penalizing tokens at an increasing rate depending on how often they appear.Required range: `-2 < x < 2`

[​](#param-repetition-penalty)

repetition_penalty

number | null

Applies a penalty to repeated tokens to discourage or encourage repetition. A value of 1.0 means no penalty, allowing free repetition. Values above 1.0 penalize repetition, reducing the likelihood of repeating tokens. Values between 0.0 and 1.0 reward repetition, increasing the chance of repeated tokens. For a good balance, a value of 1.2 is often recommended. Note that the penalty is applied to both the generated output and the prompt in decoder-only models.Required range: `0 < x < 2`

[​](#param-stop)

stop

string | null

Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence.

[​](#param-temperature)

temperature

number | null

default:1

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.Required range: `0 < x < 2`

[​](#param-top-p)

top_p

number | null

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.Required range: `0 < x <= 1`

[​](#param-top-k)

top_k

integer | null

Top-k sampling is another sampling method where the k most probable next tokens are filtered and the probability mass is redistributed among only those k next tokens. The value of k controls the number of candidates for the next token at each step during text generation.Required range: `1 < x < 128`

[​](#param-min-p)

min_p

number | null

float that represents the minimum probability for a token to be considered, relative to the probability of the most likely token.Required range: `0 <= x <= 1`

[​](#param-logit-bias)

logit_bias

map[string, integer] | null

Modify the likelihood of specified tokens appearing in the completion.Accepts a JSON object that maps tokens 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.For example, by setting `"logit_bias":{"1639": 6}` will increase the likelihood of the token with token ID 1639.

[​](#param-logprobs)

logprobs

integer | null

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 maximum value for logprobs is 5.

[​](#param-best-of)

best_of

integer

Defaults to 1. Generates best_of completions server-side and returns the “best” (the one with the highest log probability per token). Results cannot be streamed.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.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.

##

[​](#response)

Response

[​](#param-choices)

choices

array

required

The list of generated completion choices.

Show properties

[​](#param-finish-reason)

finish_reason

string

required

The reason the model stopped generating tokens. This will be “stop” if the model hit a natural stop point or a provided stop sequence, or “length” if the maximum number of tokens specified in the request was reached.Enum: `stop`, `length`

[​](#param-index)

index

integer

required

The index of the completion choice.

[​](#param-logprobs-1)

logprobs

object

required

The log probabilities of the most likely tokens.

Show properties

[​](#param-text-offset)

text_offset

array

Array of integers representing text offsets.

[​](#param-token-logprobs)

token_logprobs

array

Array of numbers representing token log probabilities.

[​](#param-tokens)

tokens

array

Array of strings representing tokens.

[​](#param-top-logprobs)

top_logprobs

array

Array of objects containing top log probabilities.

Show properties

[​](#param-key)

{key}

integer

required

Log probability value for the given key.

[​](#param-text)

text

string

required

The completion response.

[​](#param-created)

created

integer

required

The Unix time in seconds when the response was generated.

[​](#param-id)

id

string

required

A unique identifier of the response.

[​](#param-model-1)

model

string

required

The model used for the completion.

[​](#param-object)

object

string

required

The object type, which is always `text_completion`.

[​](#param-usage)

usage

object

required

Usage statistics.For streaming responses, usage field is included in the very last response chunk returned.

Show properties

[​](#param-completion-tokens)

completion_tokens

integer

required

The number of tokens in the generated completion.

[​](#param-prompt-tokens)

prompt_tokens

integer

required

The number of tokens in the prompt.

[​](#param-total-tokens)

total_tokens

integer

required

The total number of tokens used in the request (prompt + completion).

Last modified on November 10, 2025
