Text Completions
Generate a text continuation from a prompt. This is the classic completion endpoint that predates Chat Completions, compatible with the OpenAI Completions protocol.
Basics
MethodPOST
Endpointhttps://koprouter.kopglobal.com/v1/completions
AuthenticationAuthorization: Bearer sk-...
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Model ID |
prompt |
string/array | Yes | Prompt, a string or token array |
max_tokens |
number | No | Maximum tokens to generate |
temperature |
number | No | Sampling temperature, range 0-2 |
top_p |
number | No | Nucleus sampling probability |
n |
number | No | Number of candidates |
stream |
boolean | No | Stream the response |
stop |
string/array | No | Stop sequences |
Example Request
curl https://koprouter.kopglobal.com/v1/completions \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"prompt": "Once upon a time",
"max_tokens": 64
}'
Example Response
{
"id": "cmpl-abc123",
"object": "text_completion",
"created": 1720000000,
"model": "MODEL_ID",
"choices": [
{
"text": " there was a small village.",
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 4,
"completion_tokens": 6,
"total_tokens": 10
}
}