v3

OpenAPI 3.1.0MIT2026-07-31192456807.8 KB
Completion

Create completion

Generate text completions for a given prompt using a language, code, or image model.

post/completions

Request body

promptstring required

A string providing context for the model to complete.

max_tokensinteger

The maximum number of tokens to generate.

stopstring[]

A list of string sequences that truncate (stop) inference text output. For example, "</s>" stops generation as soon as the model generates the given token.

temperaturenumber

A decimal number from 0-1 that determines the degree of randomness in the response. A temperature less than 1 favors more correctness and is appropriate for question answering or summarization. A value closer to 1 introduces more randomness in the output.

top_pnumber

A percentage (also called the nucleus parameter) that's used to dynamically adjust the number of choices for each predicted token based on the cumulative probabilities. It specifies a probability threshold below which all less likely tokens are filtered out. This technique helps maintain diversity and generate more fluent and natural-sounding text.

top_kinteger

An integer that's used to limit the number of choices for the next predicted word or token. It specifies the maximum number of tokens to consider at each step, based on their probability of occurrence. This technique helps to speed up the generation process and can improve the quality of the generated text by focusing on the most likely options.

repetition_penaltynumber

A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition.

streamboolean

If true, stream tokens as Server-Sent Events as the model generates them instead of waiting for the full model response. The stream terminates with data: [DONE]. If false, return a single JSON object containing the results.

logprobsinteger

An integer between 0 and 20 of the top k tokens to return log probabilities for at each generation step, instead of only the sampled token. Log probabilities help assess model confidence in token predictions.

echoboolean

If true, the response contains the prompt. Can be used with logprobs to return prompt logprobs.

ninteger

The number of completions to generate for each prompt.

min_pnumber

A number between 0 and 1 that can be used as an alternative to top-p and top-k.

presence_penaltynumber

A number between -2.0 and 2.0 where a positive value increases the likelihood of a model talking about new topics.

frequency_penaltynumber

A number between -2.0 and 2.0 where a positive value decreases the likelihood of repeating tokens that have already been mentioned.

logit_biasobject

Adjusts the likelihood of specific tokens appearing in the generated output.

seedinteger

Seed value for reproducibility.

Example request

{
  "prompt": "<s>[INST] What is the capital of France? [/INST]",
  "logit_bias": {
    "105": 21.4,
    "1024": -10.5
  },
  "seed": 42
}

Response

200

idstring required
createdinteger required
modelstring required
object'text.completion' required

The object type, which is always text.completion.

Example response

{
  "choices": [
    {
      "text": "The capital of France is Paris. It's located in the north-central part of the country and is one of the most populous and visited cities in the world, known for its iconic landmarks like the Eiffel Tower, Louvre Museum, Notre-Dame Cathedral, and more. Paris is also the capital of the Île-de-France region and is a major global center for art, fashion, gastronomy, and culture."
    }
  ],
  "prompt": [
    {
      "text": "<s>[INST] What is the capital of France? [/INST]"
    }
  ]
}