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

# Completions (Legacy)

> Use the legacy completions endpoint to generate text from a raw prompt string. For new integrations, use the chat completions endpoint instead.

The legacy completions endpoint generates text from a raw prompt string. For conversational use cases, prefer [Chat Completions](/inference/chat-completions) instead.

<Warning>
  This is a legacy endpoint maintained for backward compatibility. Use `/v1/chat/completions` for new integrations.
</Warning>

## Endpoint

```
POST https://api.getlilac.com/v1/completions
```

## Example

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.getlilac.com/v1",
        api_key="your-lilac-api-key",
    )

    response = client.completions.create(
        model="moonshotai/kimi-k2.6",
        prompt="The capital of France is",
        max_tokens=50,
    )

    print(response.choices[0].text)
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://api.getlilac.com/v1",
      apiKey: "your-lilac-api-key",
    });

    const response = await client.completions.create({
      model: "moonshotai/kimi-k2.6",
      prompt: "The capital of France is",
      max_tokens: 50,
    });

    console.log(response.choices[0].text);
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.getlilac.com/v1/completions \
      -H "Authorization: Bearer your-lilac-api-key" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "moonshotai/kimi-k2.6",
        "prompt": "The capital of France is",
        "max_tokens": 50
      }'
    ```
  </Tab>
</Tabs>

## Request Parameters

### Required

| Parameter | Type                | Description                                                      |
| --------- | ------------------- | ---------------------------------------------------------------- |
| `model`   | `string`            | Model ID (e.g., `moonshotai/kimi-k2.6`).                         |
| `prompt`  | `string` or `array` | The input text to complete. Can be a string or array of strings. |

### Sampling

| Parameter     | Type      | Default | Description                             |
| ------------- | --------- | ------- | --------------------------------------- |
| `temperature` | `float`   | `1.0`   | Sampling temperature (0–2).             |
| `top_p`       | `float`   | `1.0`   | Nucleus sampling threshold.             |
| `top_k`       | `integer` | `-1`    | Limits sampling to the top K tokens.    |
| `min_p`       | `float`   | `0.0`   | Minimum relative probability threshold. |
| `seed`        | `integer` | `null`  | Seed for deterministic sampling.        |

### Output

| Parameter    | Type                | Default | Description                                         |
| ------------ | ------------------- | ------- | --------------------------------------------------- |
| `max_tokens` | `integer`           | `16`    | Maximum tokens to generate.                         |
| `n`          | `integer`           | `1`     | Number of completions per prompt.                   |
| `stop`       | `string` or `array` | `null`  | Up to 4 stop sequences.                             |
| `stream`     | `boolean`           | `false` | Stream partial results via SSE.                     |
| `echo`       | `boolean`           | `false` | Return the prompt concatenated with the completion. |

### Penalties

| Parameter            | Type     | Default | Description                                  |
| -------------------- | -------- | ------- | -------------------------------------------- |
| `frequency_penalty`  | `float`  | `0.0`   | Penalizes tokens by frequency (-2.0 to 2.0). |
| `presence_penalty`   | `float`  | `0.0`   | Penalizes tokens by presence (-2.0 to 2.0).  |
| `repetition_penalty` | `float`  | `1.0`   | Multiplicative penalty on repeated tokens.   |
| `logit_bias`         | `object` | `null`  | Map of token ID → bias value (-100 to 100).  |

### Log Probabilities

| Parameter  | Type      | Default | Description                                           |
| ---------- | --------- | ------- | ----------------------------------------------------- |
| `logprobs` | `integer` | `null`  | Return log probabilities of the top N tokens (max 5). |

## Response Format

```json theme={null}
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1717000000,
  "model": "moonshotai/kimi-k2.6",
  "choices": [
    {
      "index": 0,
      "text": " Paris, which is known for...",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 7,
    "completion_tokens": 15,
    "total_tokens": 22
  }
}
```
