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

# Openai Completions

`POST /v1/completions`

## Headers

- `x-deepinfra-source` string, nullable
- `xi-api-key` string, nullable
- `x-api-key` string, nullable

## Request body

- OpenAICompletionsIn
  - `service_tier` 'default' | 'priority' | 'flex'
  - `fail_fast` boolean — If true, the request is rejected immediately with HTTP 429 when the model has no spare capacity, instead of waiting in the queue. Opt-in; the default (false) keeps standard queueing behavior.
  - `model` string, required — model name
  - `prompt` union, required — input prompt - a single string is currently supported
    - string
    - integer[]
  - `max_tokens` integer, nullable — The maximum number of tokens to generate in the completion. The total length of input tokens and generated tokens is limited by the model's context length.If explicitly set to None it will be the model's max context length minus input length or 65536, whichever is smaller.
  - `temperature` number — 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
  - `top_p` number — 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.
  - `min_p` number — Float that represents the minimum probability for a token to be considered, relative to the probability of the most likely token. Must be in [0, 1]. Set to 0 to disable this.
  - `top_k` integer — Sample from the best k (number of) tokens. 0 means off
  - `n` integer — number of sequences to return
  - `stream` boolean — whether to stream the output via SSE or return the full response
  - `logprobs` integer, nullable — return top tokens and their log-probabilities
  - `echo` boolean, nullable — return prompt as part of the respons
  - `stop` union — up to 16 sequences where the API will stop generating further tokens
    - string
    - string[]
  - `presence_penalty` number — 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.
  - `frequency_penalty` number — Positive values penalize new tokens based on how many times they appear in the text so far, increasing the model's likelihood to talk about new topics.
  - `response_format` union — The format of the response. Currently, only json is supported.
    - TextResponseFormat
      - `type` 'text'
    - JsonObjectResponseFormat
      - `type` 'json_object'
    - JsonSchemaResponseFormat
      - `type` 'json_schema'
      - `json_schema` JsonSchema, required
        - `name` string, required — Name identifier for the JSON schema
        - `schema` object, required — The actual JSON schema definition
    - RegexResponseFormat
      - `type` 'regex'
      - `regex` string, required — Regex pattern for structured output when type is 'regex'
  - `repetition_penalty` number — Alternative penalty for repetition, but multiplicative instead of additive (> 1 penalize, < 1 encourage)
  - `user` string, nullable — A unique identifier representing your end-user, which can help monitor and detect abuse. Avoid sending us any identifying information. We recommend hashing user identifiers.
  - `seed` integer, nullable — Seed for random number generator. If not provided, a random seed is used. Determinism is not guaranteed.
  - `stream_options` StreamOptions
    - `include_usage` boolean — whether to include usage data
    - `continuous_usage_stats` boolean — whether to include usage stats continuously with each streaming event
  - `stop_token_ids` integer[], nullable — Up to 16 token IDs where the API will stop generating further tokens. Merged with the model's built-in stop tokens. Intended for private deployments.
  - `return_tokens_as_token_ids` boolean, nullable — return tokens as token ids
  - `prompt_cache_key` string, nullable — A key to identify prompt cache for reuse across requests. If provided, the prompt will be cached and can be reused in subsequent requests with the same key.
  - `prompt_cache_options` PromptCacheOptions
    - `mode` 'explicit' | 'implicit', nullable — Prompt caching mode; 'explicit' requests explicit caching.
    - `ttl` '5m' | '1h', nullable — Requested cache retention for this request's prefix.
  - `data` CompletionMultiModalData
    - `image` string[] — List of images as base64 data URIs (e.g. 'data:image/png;base64,...'). Each image must correspond to a placeholder token in the prompt.
    - `video` string[] — List of videos as base64 data URIs (e.g. 'data:video/mp4;base64,...'). Each video must correspond to a placeholder token in the prompt.
  - `ignore_eos` boolean, nullable — Keep generating until max_tokens instead of stopping at the end-of-sequence token. Only honoured on models tagged with the allow_ignore_eos feature flag; ignored otherwise. Intended for benchmarking, where a fixed output length is needed.

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

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