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

# Create completion.

`POST /v1/completions`

Generate an OpenAI-compatible completion for the given prompt using the specified model.

## Request body

- OpenAICompletionRequestWithExtraBody — Request parameters for OpenAI-compatible completion endpoint.
  - `model` string, required — The identifier of the model to use.
  - `prompt` union, required — The prompt to generate a completion for.
    - string
    - string[]
    - integer[]
    - array[]
      - integer[]
  - `best_of` integer, nullable — The number of completions to generate.
  - `echo` boolean, nullable — Whether to echo the prompt.
  - `frequency_penalty` number, nullable — The penalty for repeated tokens.
  - `logit_bias` object, nullable — The logit bias to use.
  - `logprobs` integer, nullable — Include the log probabilities on the logprobs most likely output tokens.
  - `max_tokens` integer, nullable — The maximum number of tokens to generate.
  - `n` integer, nullable — The number of completions to generate.
  - `presence_penalty` number, nullable — The penalty for repeated tokens.
  - `seed` integer, nullable — The seed to use.
  - `stop` union — The stop tokens to use.
    - string
    - string[]
  - `stream` boolean, nullable — Whether to stream the response.
  - `stream_options` object, nullable — The stream options to use.
  - `temperature` number, nullable — The temperature to use.
  - `top_p` number, nullable — The top p to use.
  - `user` string, nullable — The user to use.
  - `suffix` string, nullable — The suffix that should be appended to the completion.

## Response `200`

An OpenAICompletion. When streaming, returns Server-Sent Events (SSE) with OpenAICompletion chunks.

- OpenAICompletion — Response from an OpenAI-compatible completion request.
  - `id` string, required — The ID of the completion.
  - `choices` OpenAICompletionChoice[], required — List of choices.
    - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', required — The reason the model stopped generating.
    - `text` string, required — The text of the choice.
    - `index` integer, required — The index of the choice.
    - `logprobs` object, nullable — The log probabilities for the tokens in the choice.
      - `content` OpenAITokenLogProb[], nullable — The log probabilities for the tokens in the message.
        - `token` string, required — The token.
        - `bytes` integer[], nullable — The bytes for the token.
        - `logprob` number, required — The log probability of the token.
        - `top_logprobs` OpenAITopLogProb[], nullable — The top log probabilities for the token.
          - `token` string, required — The token.
          - `bytes` integer[], nullable — The bytes for the token.
          - `logprob` number, required — The log probability of the token.
      - `refusal` OpenAITokenLogProb[], nullable — The log probabilities for the refusal tokens.
        - `token` string, required — The token.
        - `bytes` integer[], nullable — The bytes for the token.
        - `logprob` number, required — The log probability of the token.
        - `top_logprobs` OpenAITopLogProb[], nullable — The top log probabilities for the token.
          - `token` string, required — The token.
          - `bytes` integer[], nullable — The bytes for the token.
          - `logprob` number, required — The log probability of the token.
  - `created` integer, required — The Unix timestamp in seconds when the completion was created.
  - `model` string, required — The model that was used to generate the completion.
  - `object` 'text_completion' — The object type.

## Other responses

- `400` — The request was invalid or malformed
- `429` — The client has sent too many requests in a given amount of time
- `500` — The server encountered an unexpected error
- `default` — An error occurred

---

[API](https://skmtc.net/ogx-ai/apis/ogx-specification-stable-experimental-apis.md) · [All operations](https://skmtc.net/ogx-ai/apis/ogx-specification-stable-experimental-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ogx-ai/ogx-specification-stable-experimental-apis/versions/f3f783962256/schema)
