# Text completions

> POST /v1/completions for the legacy prompt-in, text-out format.


The legacy prompt endpoint, for tools that still speak it. It runs the prompt as one user message on the same models. For anything new, use [chat completions](/en/api/chat-completions).

```endpoint
POST https://api.notholy.com/v1/completions
```

## Request

| Field | Type | Required | Notes |
|---|---|---|---|
| `model` | string | Yes | A model ID |
| `prompt` | string or array | Yes | A string, or an array with exactly one string |
| `max_tokens` | number | No | Defaults to 16. Capped at the model's maximum output |
| `stream` | boolean | No | `true` returns `text_completion` chunks and `data: [DONE]` |
| `temperature`, `top_p`, `stop` | | No | Passed to the model |
| `n` | number | No | Only `1` |

There are no tools and no reasoning effort here. `echo`, `logprobs` and `suffix` are ignored.

## Response

```json
{
  "id": "cmpl-4Qz7",
  "object": "text_completion",
  "created": 1793836800,
  "model": "notholy-specter",
  "choices": [{ "index": 0, "text": " ../../etc/passwd encoded as %2e%2e%2f…", "finish_reason": "length", "logprobs": null }],
  "usage": { "prompt_tokens": 14, "completion_tokens": 60, "total_tokens": 74 }
}
```

- In a stream, each chunk carries `choices[0].text`. The last chunk has `finish_reason` and `usage`.

## Example

```bash test
curl https://api.notholy.com/v1/completions \
  -H "Authorization: Bearer $NOTHOLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "notholy-specter", "prompt": "A path traversal payload in a file download parameter looks like", "max_tokens": 60}'
```

```python test
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.notholy.com/v1", api_key=os.environ["NOTHOLY_API_KEY"])

r = client.completions.create(model="notholy-specter", prompt="The OWASP category for SSRF is", max_tokens=30)
print(r.choices[0].text)
```

## Errors

`400` missing `prompt`, more than one prompt or `n` above 1 · `401` bad key · `402` out of credits · `404` unknown model · `429` busy · `503` model unavailable. See [Errors](/en/guides/errors).
