API Reference
Completions (Legacy)
POST /v1/completions — legacy text completion endpoint
Completions (Legacy)
POST /v1/completions
The legacy text completion endpoint. This endpoint takes a prompt string and returns a completion. Most modern models are optimized for chat format — use Chat Completions for new applications.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID. The gateway accepts any chat model here; the legacy prompt/completion shape is transformed internally. |
prompt | string or array | Yes | Input prompt(s) |
max_tokens | integer | No | Maximum tokens to generate. Default: 16 |
temperature | number | No | Sampling temperature 0–2. Default: 1 |
top_p | number | No | Nucleus sampling probability |
n | integer | No | Number of completions per prompt |
stream | boolean | No | Stream tokens via SSE |
stop | string or array | No | Stop sequences |
echo | boolean | No | Echo the prompt in the response |
suffix | string | No | Suffix appended after the completion |
Example Request
curl https://api.soxai.io/v1/completions \
-H "Authorization: Bearer $SOXAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-nano",
"prompt": "Write a haiku about the ocean:",
"max_tokens": 60,
"temperature": 0.8
}'Example Response
{
"id": "cmpl-01jq4xyz",
"object": "text_completion",
"created": 1743350400,
"model": "gpt-5.4-nano",
"choices": [
{
"text": "\nWaves crash on the shore,\nSalt and foam rise and recede,\nOcean breathes in peace.",
"index": 0,
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 22,
"total_tokens": 31
}
}Migration to Chat Completions
The completions endpoint is maintained for backward compatibility. For equivalent functionality using Chat Completions:
{
"model": "gpt-5.4-mini",
"messages": [
{"role": "user", "content": "Write a haiku about the ocean:"}
]
}