Theme
Completions
Generate text with the OpenAI Legacy Completions–compatible format.
http
POST /v1/completionsLegacy Completions takes a as input. It suits workloads that still use older OpenAI SDKs or simple text completion. For new chat scenarios, prefer Chat Completions.
The default example model is .
Available models
| Model | Description |
|---|---|
| Legacy Completions instruct model |
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Request authentication. Use a Bearer token, for example: | |
| string | Yes | Request content type; must be |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| string | Yes | Model ID; default example . See Available models above | |
| string | array | Yes | Input prompt. May be a string, string array, token array, or array of token arrays; official default generates from the document start marker | |
| string | No | Text that appears after the completion insert point; only supported by | |
| integer | No | Maximum tokens to generate; official default ; prompt tokens plus this value must not exceed the model context length | |
| number | No | Sampling temperature, range –, default ; usually tune either or | |
| number | No | Nucleus sampling, range –, default | |
| integer | No | How many completions to generate per prompt, range –, default | |
| boolean | No | Whether to stream the response, default ; when enabled, pushes SSE and ends with | |
| object | No | Streaming options; only effective when | |
| integer | No | Number of most likely token log probabilities to return, maximum | |
| boolean | No | Whether to echo the prompt in addition to the completion, default | |
| string | array | No | Up to 4 stop sequences; generation stops when encountered | |
| number | No | Range –, default | |
| number | No | Range –, default | |
| integer | No | Server generates multiple candidates and returns the best one, default , maximum ; cannot be used with streaming; when used with , must be greater than | |
| object | No | Bias map for token appearance probabilities; keys are token IDs, values – | |
| integer | No | Random seed; best-effort deterministic sampling | |
| string | No | Unique end-user identifier for abuse monitoring |
stream_options
| Name | Type | Required | Description |
|---|---|---|---|
| boolean | No | Push an extra chunk containing before |
Request example
bash
curl -X POST https://octopusx.ai/v1/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo-instruct",
"prompt": "Rewrite the following sentence more formally: This API is pretty easy to use.",
"max_tokens": 120,
"temperature": 0.3
}'bash
curl -X POST https://octopusx.ai/v1/completions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo-instruct",
"prompt": "Introduce the Completions endpoint in one sentence.",
"max_tokens": 64,
"stream": true,
"stream_options": {
"include_usage": true
}
}'Response example
Non-streaming success
json
{
"id": "cmpl_abc123",
"object": "text_completion",
"created": 1735689600,
"model": "gpt-3.5-turbo-instruct",
"choices": [
{
"index": 0,
"text": "This API offers good usability.",
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 22,
"completion_tokens": 10,
"total_tokens": 32
}
}Streaming chunks (illustrative)
text
data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":"This","finish_reason":null}]}
data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":" API","finish_reason":null}]}
data: [DONE]Response fields
| Name | Type | Description |
|---|---|---|
| string | Completion response ID | |
| string | Object type; always | |
| integer | Response creation timestamp (Unix seconds) | |
| string | Model that generated the response | |
| array | Array of candidate results | |
| integer | Candidate index | |
| string | Text generated by the model | |
| string | Finish reason, e.g. | |
| object | Token usage statistics | |
| integer | Input token count | |
| integer | Output token count | |
| integer | Total token count |