---
title: "Create Completion"
method: POST
path: "/v1/completions"
tags: ["text"]
---

# Create Completion

`POST /v1/completions`

Create a Completion.

## Request body

- CreateCompletionRequest — `POST https://text.octoai.run/v1/completions` Completes the provided prefix prompt given the parameters. You can view this as the "raw" API to the model which provides more complete user control than the chat completions API. This API is compatible with OpenAI's API.
  - `best_of` integer — Number of sequences that are generated from the prompt.`best_of` must be greater than or equal to `n`.
  - `echo` boolean — Echo back the prompt in addition to the completion.
  - `frequency_penalty` number — Penalizes new tokens based on their frequency in the generated text so far.
  - `ignore_eos` boolean — Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.
  - `log_prompt` boolean — OctoAI stores request prompt if True.
  - `logit_bias` object, nullable — Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) 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, 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. As an example, you can pass {'50256': -100} to prevent the <|endoftext|> token from being generated.
  - `loglikelihood` boolean — Return log probabilities for all prompt tokens excluding the first one from prefill step if True.
  - `logprobs` integer, nullable — Number of log probabilities to return per output token.
  - `max_tokens` integer — Maximum number of tokens to generate per output sequence.
  - `min_p` number — Sets a dynamic threshold of the top tokens to consider based on the probability value of the most likely next token. Following https://arxiv.org/abs/2407.01082.
  - `model` string, required — The identifier of the model to use. Can be a shared tenancy or custom model identifier.
  - `n` integer — Number of output sequences to return.
  - `peft` string, nullable — Parameter-efficient fine-tuning ID.
  - `presence_penalty` number — Penalizes new tokens based on whether they appear in the generated text so far.
  - `prompt` union, required — The prompt to generate completions from.
    - string
    - string[]
    - integer[]
    - array[]
      - integer[]
  - `repetition_penalty` number — Controls the likelihood of the model generating repeated texts.
  - `seed` integer — 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. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
  - `stop` union — Generation stop condition.
    - string
    - string[]
  - `stream` boolean — If set, tokens will be streamed incrementally to users. One or more tokens will be sent as server-sent events (SSE) as they become available. For more information on read above.
  - `stream_options` StreamOptions — Streaming options for the request.
    - `include_usage` boolean — Whether or not to include token usage stats on the final chunk before the [Done] message.
  - `suffix` string, nullable — The suffix that comes after a completion of inserted text.
  - `temperature` number — Controls the randomness of the sampling.
  - `top_p` number — Controls the cumulative probability of the top tokens to consider.
  - `user` string, nullable — A unique identifier representing your end-user.

## Response `200`

An OctoAI text endpoint can be requested in either a synchronous orstreaming mode.When the request body has `stream: False` set the content type will be`application/json`. When the request body has `stream: True` set thecontent type will be `text-event-stream` and will respond with a stream of[server-send-events (SSE)](https://en.wikipedia.org/wiki/Server-sent_events).

- CompletionResponse — Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).
  - `choices` CompletionChoice[], required — A list of completion choices.
    - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call' | 'cancelled' — The reason why the model stopped generating tokens. This will be `stop` if the model naturally completed generation or encountered 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, tool_calls if the model called a tool, or function_call (deprecated) if the model called a function.
    - `index` integer, required — A unique identifier for the completion.
    - `logprobs` Logprobs — An OpenAI API compatible schema for logprobs output. See details in `https://platform.openai.com/docs/api-reference/chat/object#chat-create-logprobs`.
      - `content` LogprobsContent[] — List of logprobs info.
        - `bytes` unknown[], nullable — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
          - unknown
        - `logprob` number, required — Logprob corresponding to the token.
        - `token` string, required — New generated token or token from prompt for loglikelihood case.
        - `top_logprobs` TopLogprobs[] — List of top tokens info.
          - `bytes` unknown[], nullable — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
            - unknown
          - `logprob` number, required — Logprob corresponding to the top token.
          - `token` string, required — Token from the top list.
    - `text` string, required — The generated text in completion response.
  - `created` integer, required — The Unix timestamp (in seconds) of when the completion was created.
  - `id` string, required — A unique identifier for the completion.
  - `model` string, required — The model used for the completion.
  - `object` 'text_completion' — Object type field which is a constant and preset.
  - `system_fingerprint` string, required — The system response fingerprint.
  - `usage` UsageStats — The token usage statistics for a request.
    - `completion_tokens` integer, required — Number of tokens in the prompt.
    - `prompt_tokens` integer, required — Number of tokens in the prompt.
    - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).

## Other responses

- `422` — Validation Error
- `500` — Internal Server Error

---

[API](https://skmtc.net/octoml/apis/ollm-api.md) · [All operations](https://skmtc.net/octoml/apis/ollm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/octoml/ollm-api/revisions/790b47aba5c5/schema)
