OpenAI · Completions (Legacy)
Generates a text completion based on the provided prompt.#
/v1/completionsWhen streaming is enabled, the response will be sent as a server-sent event (SSE) stream of CompletionChunkResponse objects; otherwise, a single JSON CompletionResponse is returned.
The endpoint produces two types of responses:
• application/json: A non-streaming response containing a single CompletionResponse object.
• text/event-stream: A streaming response in which each event contains a CompletionChunkResponse object.
This endpoint implements the OpenAI completions API specification. For complete reference, please see the official OpenAI documentation: https://platform.openai.com/docs/api-reference/completions/create
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
model | string | The ID of the model used for the text completion. If not specified, the default model will be used. |
promptrequired | object | The prompt(s) to generate completions for. Can be a string or an array of strings. |
suffix | string | A suffix that comes after a completion of inserted text. This parameter is only supported for gpt-3.5-turbo-instruct. |
max_tokens | object (int32) | The maximum number of tokens that can be generated in the completion. Defaults to 16. |
temperature | object (double) | What sampling temperature to use, between 0 and 2. Defaults to 1. |
top_p | object (double) | An alternative to sampling with temperature using nucleus sampling, where the model considers the tokens with top_p probability mass. Defaults to 1. |
n | object (int32) | How many completions to generate for each prompt. Defaults to 1. |
stream | boolean | Whether to stream back partial progress. Defaults to false. |
stream_options | Options for streaming response. Only set when Stream is true. | |
logprobs | object (int32) | Include the log probabilities on the logprobs most likely tokens, as well as the chosen tokens. Defaults to null. |
echo | boolean | Echo back the prompt in addition to the completion. Defaults to false. |
stop | object | Up to 4 sequences where the API will stop generating further tokens. Can be a string or an array of strings. Defaults to null. |
presence_penalty | object (double) | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far. Defaults to 0. |
frequency_penalty | object (double) | Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far. Defaults to 0. |
best_of | object (int32) | Generates best_of completions server-side and returns the 'best' (the one with the highest log probability per token). Defaults to 1. |
logit_bias | object | Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object mapping token IDs (as strings) to bias values between -100 and 100. Defaults to null. |
user | string | A unique identifier representing your end-user. Defaults to null. |
seed | object (int32) | If specified, attempts to sample deterministically. Defaults to null. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 400 | Bad Request | |
| 500 | application/json | Internal Server Error |
| 404 | Not Found |
curl -X POST "$LMKIT_ONE_URL/v1/completions" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "string",
"prompt": {},
"suffix": "string",
"max_tokens": "string",
"temperature": "string"
}'