> ## Documentation Index
> Fetch the complete documentation index at: https://kiosapi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy OpenAI-Compatible Text Completions Endpoint

> POST /v1/completions provides the legacy OpenAI text completions format. For most use cases, prefer POST /v1/chat/completions instead.

The `/v1/completions` endpoint supports the older OpenAI text completion format, which predates the chat completions API. You can use it for backward compatibility with existing tools and integrations that were built against the original completions interface before the chat format became the standard.

<Info>
  For most use cases, prefer the `/v1/chat/completions` endpoint. This endpoint is provided for backward compatibility with older integrations.
</Info>

## Request

**POST** `https://kiosapi.com/v1/completions`

### Headers

| Header          | Required | Description        |
| --------------- | -------- | ------------------ |
| `Content-Type`  | Yes      | `application/json` |
| `Authorization` | Yes      | `Bearer sk-xxx`    |

### Request Body

<ParamField body="model" type="string" required>
  Model name (e.g. `gpt-3.5-turbo-instruct`).
</ParamField>

<ParamField body="prompt" type="string" required>
  Input text prompt to complete.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature between 0 and 2. Higher values produce more random output.
</ParamField>

<ParamField body="top_p" type="number">
  Nucleus sampling probability mass. Use as an alternative to `temperature`.
</ParamField>

<ParamField body="stream" type="boolean">
  Set to `true` to receive a streamed response using server-sent events.
</ParamField>

<ParamField body="max_tokens" type="number">
  Maximum number of tokens to generate in the completion.
</ParamField>

<ParamField body="n" type="number">
  How many completions to generate for each prompt.
</ParamField>

<ParamField body="presence_penalty" type="number">
  Number between -2.0 and 2.0. Positive values penalise new tokens based on whether they appear in the text so far.
</ParamField>

<ParamField body="frequency_penalty" type="number">
  Number between -2.0 and 2.0. Positive values penalise new tokens based on their existing frequency in the text.
</ParamField>

<ParamField body="logprobs" type="number">
  Return log probabilities of the most likely tokens. Pass an integer to specify how many tokens to return.
</ParamField>

<ParamField body="user" type="string">
  A unique identifier for the end-user, which can help with monitoring and abuse detection.
</ParamField>

### Example Request

```bash theme={null}
curl https://kiosapi.com/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxx" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "The weather is very nice today",
    "temperature": 0.7,
    "max_tokens": 100,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0
  }'
```

## Response

```json theme={null}
{
  "id": "cmpl-A1tJLfyQgj1j2GpvhA6QcMCZKwRtw",
  "object": "text_completion",
  "created": 1725014307,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": ", perfect for going out\n\nYes, the weather is very good today, perfect for a trip.",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 25,
    "total_tokens": 31
  }
}
```
