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

# Create completions

`POST /v1/completions`

This function processes completion requests by using the chat completions endpoint.

## Returns

Returns a Response containing either:
- A streaming SSE connection for real-time completions
- A single JSON response for non-streaming completions

## Errors

Returns an error status code if:
- The request processing fails
- The streaming/non-streaming handlers encounter errors
- The underlying inference service returns an error

## Request body

- CompletionsRequest
  - `best_of` integer, nullable
  - `echo` boolean, nullable
  - `frequency_penalty` number, float, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far
  - `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.
  - `logprobs` integer, nullable — An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
  - `max_tokens` integer, nullable — The maximum number of tokens to generate in the chat completion
  - `model` string, required — ID of the model to use
  - `n` integer, nullable — How many chat completion choices to generate for each input message
  - `presence_penalty` number, float, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far
  - `prompt` union, required
    - string — A single string prompt
    - string[] — An array of strings prompts
    - integer[] — An array of tokens
    - array[] — An array of token arrays
      - integer[]
  - `seed` integer, nullable — If specified, our system will make a best effort to sample deterministically
  - `stop` string[], nullable — Up to 4 sequences where the API will stop generating further tokens
  - `stream` boolean, nullable — Whether to stream back partial progress
  - `stream_options` StreamOptions — Specifies the stream options for the request.
    - `include_usage` boolean, nullable — 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.
  - `suffix` string, nullable — The suffix that comes after a completion of inserted text.
  - `temperature` number, float, nullable — What sampling temperature to use, between 0 and 2
  - `top_p` number, float, nullable — An alternative to sampling with temperature
  - `user` string, nullable — A unique identifier representing your end-user

## Response `200`

Chat completions

- CompletionsResponse
  - `choices` CompletionChoice[], required — Array of completion choices response
    - `finish_reason` string, required — The reason the model stopped generating tokens
    - `index` integer, required — The index of the choice in the list of choices
    - `logprobs` LogProbs
      - `text_offset` integer[], required — The text offset of the tokens
      - `token_logprobs` number[], required — The log probabilities of the tokens
      - `tokens` string[], required — The tokens
      - `top_logprobs` object[], required — The top log probabilities
    - `text` string, required — The generated text
  - `created` integer, required — The creation time of the request
  - `id` string, required — The ID of the request
  - `model` string, required — The model used for the request
  - `object` string, required — The object type
  - `system_fingerprint` string, required — The system fingerprint
  - `usage` Usage, required
    - `completion_tokens` integer, required — The number of completion tokens used
    - `completion_tokens_details` CompletionTokensDetails, required — The details of the completion tokens
      - `accepted_prediction_tokens` integer, required — The number of tokens in the completion
      - `audio_tokens` integer, required — The number of audio tokens
      - `reasoning_tokens` integer, required — The number of reasoning tokens
      - `rejected_prediction_tokens` integer, required — The number of rejected prediction tokens
    - `prompt_tokens` integer, required — The number of prompt tokens used
    - `prompt_tokens_details` PromptTokensDetails, required
      - `audio_tokens` integer, required — The number of audio tokens
      - `cached_tokens` integer, required — The number of cached tokens
    - `total_tokens` integer, required — The total number of tokens used

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `500` — Internal server error

---

[API](https://skmtc.net/atomaai/apis/atoma-proxy.md) · [All operations](https://skmtc.net/atomaai/apis/atoma-proxy/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/atomaai/atoma-proxy/revisions/07694b7228b0/schema)
