LM-Kit OneDocs2026.8.10lm-kit.com
API Compatibility

OpenAI · Completions (Legacy)

Generates a text completion based on the provided prompt.#

POST/v1/completions

When 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 ·

PropertyTypeDescription
modelstring

The ID of the model used for the text completion. If not specified, the default model will be used.

promptrequiredobject

The prompt(s) to generate completions for. Can be a string or an array of strings.

suffixstring

A suffix that comes after a completion of inserted text. This parameter is only supported for gpt-3.5-turbo-instruct.

max_tokensobject (int32)

The maximum number of tokens that can be generated in the completion. Defaults to 16.

temperatureobject (double)

What sampling temperature to use, between 0 and 2. Defaults to 1.

top_pobject (double)

An alternative to sampling with temperature using nucleus sampling, where the model considers the tokens with top_p probability mass. Defaults to 1.

nobject (int32)

How many completions to generate for each prompt. Defaults to 1.

streamboolean

Whether to stream back partial progress. Defaults to false.

stream_options

Options for streaming response. Only set when Stream is true.

logprobsobject (int32)

Include the log probabilities on the logprobs most likely tokens, as well as the chosen tokens. Defaults to null.

echoboolean

Echo back the prompt in addition to the completion. Defaults to false.

stopobject

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_penaltyobject (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_penaltyobject (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_ofobject (int32)

Generates best_of completions server-side and returns the 'best' (the one with the highest log probability per token). Defaults to 1.

logit_biasobject

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.

userstring

A unique identifier representing your end-user. Defaults to null.

seedobject (int32)

If specified, attempts to sample deterministically. Defaults to null.

Responses

StatusTypeDescription
200

OK

400

Bad Request

500application/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"
}'