# Completions

> Generate text from a plain prompt using the legacy OpenAI completions format.

Source: https://i14.ai/docs/api-reference/completions/

`POST https://api.i14.ai/v1/completions`

Use this endpoint for clients that send plain prompts, not a conversation. For messages, reasoning output or tools, use [Chat Completions](https://i14.ai/docs/api-reference/chat-completions/).

Send your i14 key as a Bearer token and use `Content-Type: application/json`.

| Field                          | Type                             | Meaning                                                                                          |
| ------------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------ |
| `model`                        | string, required                 | An ID returned by [Models](https://i14.ai/docs/api-reference/models/) that supports Completions. |
| `prompt`                       | string, required in this example | Text to complete.                                                                                |
| `max_tokens`                   | integer                          | Maximum number of tokens to generate. Set this explicitly for predictable truncation.            |
| `temperature`, `top_p`         | number                           | Sampling controls.                                                                               |
| `stop`                         | string or array                  | Text that stops generation.                                                                      |
| `stream`                       | boolean                          | Stream text chunks as server-sent events.                                                        |
| `stream_options.include_usage` | boolean                          | Request a final usage chunk when streaming.                                                      |
| `n`                            | integer                          | Number of choices. Use one for models that only support a single choice.                         |

Set `I14_MODEL` to a compatible model and `I14_API_KEY` to your key. This cURL example uses `jq`.

```bash
curl --fail-with-body --silent --show-error https://api.i14.ai/v1/completions \
  -H "Authorization: Bearer $I14_API_KEY" \
  -H "Content-Type: application/json" \
  --data "$(jq -n --arg model "$I14_MODEL" '{model: $model, prompt: "The capital of France is", max_tokens: 32}')"
```

Example response (selected fields):

```json
{
  "id": "cmpl-example",
  "object": "text_completion",
  "model": "your-model-id",
  "choices": [{"text": " Paris.", "index": 0, "finish_reason": "stop"}],
  "usage": {"prompt_tokens": 5, "completion_tokens": 2, "total_tokens": 7}
}
```

Read `choices[].text` for generated text, `finish_reason` for why the choice stopped, and `usage` for token counts when present. In a stream, append each choice’s text by index. Do not confuse a Completions text chunk with the `choices[].delta` objects on Chat Completions or the typed events on Responses.
