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

OpenAI · Chat

Generates a chat completion based on the provided conversation history.#

POST/v1/chat/completions

When streaming is enabled, the response will be sent as a server-sent event (SSE) stream of ChatCompletionChunkResponse objects; otherwise, a single JSON ChatCompletionResponse is returned. The endpoint produces two types of responses:

• application/json: A non-streaming response containing a single ChatCompletionResponse object.

• text/event-stream: A streaming response in which each event contains a ChatCompletionChunkResponse object.

This endpoint implements the OpenAI chat completion API specification, including tool/function calling support. For complete reference, please see the official OpenAI documentation: https://platform.openai.com/docs/api-reference/chat/create

Structured output: response_format with type json_object or json_schema is enforced through grammar-constrained decoding, so the completion is guaranteed to match the requested shape. Usage: every non-streaming response carries a usage block (with a reasoning-token breakdown on reasoning models); streaming requests receive it in a final pre-[DONE] chunk when stream_options.include_usage is set.

LM-Kit extensions: the request also accepts 'agent', 'skill', 'skill_inputs', 'server_tools', 'memory' and 'memory_store', adopting the server-defined assets the admin panel manages with the same semantics as the native lmkit/v1/chat contract. OpenAI SDKs pass them through extra_body; requests that omit them behave exactly as the plain OpenAI specification.

Request body

application/json ·

PropertyTypeDescription
messagesrequired[]

A list of messages comprising the conversation so far.

modelstring

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

agentstring

LM-Kit extension. Name of a server-defined agent: a reusable bundle (system prompt, skill, server tools, memory intent, model pin) this completion adopts. The bundle supplies defaults; any field the request states explicitly wins. An unknown name is a named 400.

skillstring

LM-Kit extension. Name of a server skill pinned for this completion: its instructions ride the system turn, built server-side.

skill_inputsobject

LM-Kit extension. Answers to the pinned skill's activation questions, keyed by each question's slug; unanswered questions fall back to their declared defaults.

server_toolsstring[]

LM-Kit extension. Server-executed built-in tools the model may use, by name (e.g. web_search, calc_arithmetic, document_convert_to_markdown): the server runs each call and the completion continues with its result. Only tools the server's Tools policy enables actually run.

memorystring

LM-Kit extension. Agent-memory id: facts extracted from this completion persist on the server under this id, and facts stored earlier under it are recalled as hidden context. Requires the server's Memory feature; when it is off the completion proceeds without memory.

memory_storestring

LM-Kit extension. Name of the memory STORE the memory id lives under, a server-defined policy bundle. Absent uses the agent's store when an agent rides the request, else the default store.

storeboolean

Whether or not to store the output of this chat completion request for use in model distillation or evals. Defaults to false.

reasoning_effortstring

Constrains effort on reasoning for reasoning models. Supported values: "none", "low", "medium", "high", "xhigh". Defaults to "medium". Note: "none" is default for gpt-5.1, "xhigh" is only supported on gpt-5.1-codex-max.

metadataobject

Set of up to 16 key-value pairs attached as metadata. Keys: max 64 characters; Values: max 512 characters.

frequency_penaltyobject (double)

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency. Defaults to 0.

logit_biasobject

Modify the likelihood of specified tokens appearing in the completion. Map of token ID (string) to bias value (-100 to 100).

logprobsboolean

Whether to return log probabilities of the output tokens. Defaults to false.

top_logprobsobject (int32)

An integer between 0 and 20 specifying the number of most likely tokens to return at each token position. Must be set to true for logprobs if used.

max_tokensobject (int32)

(Deprecated) The maximum number of tokens that can be generated in the chat completion. Use MaxCompletionTokens instead.

max_completion_tokensobject (int32)

An upper bound for the number of tokens that can be generated for a completion, including both visible output tokens and reasoning tokens.

nobject (int32)

How many chat completion choices to generate for each input message. Defaults to 1.

modalitiesstring[]

Output types that you would like the model to generate. For text-only output, the default is ["text"].

predictionobject

Configuration for a Predicted Output, which can improve response times when large parts of the model response are known ahead of time. This property can be provided in one of three forms: as a PredictionStaticContent object (for static predicted output), as a simple string (for text content), or as an array of ContentPart objects (for multiple content parts).

audio

Parameters for audio output. Required when audio output is requested with modalities: ["audio"].

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.

response_format

An object specifying the format that the model must output. For example: { "type": "json_schema", "json_schema": } enables Structured Outputs, { "type": "json_object" } enables JSON mode.

seedobject (int32)

If specified, attempts to sample deterministically.

service_tierstring

Specifies the latency tier to use for processing the request. Defaults to "auto".

stopobject

Up to 4 sequences where the API will stop generating further tokens. Can be a string or an array of strings.

streamboolean

If set, partial message deltas will be sent as server-sent events (streaming). Defaults to false.

stream_options

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

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 tokens with top_p probability mass. Defaults to 1.

tools[]

A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.

tool_choiceobject

Controls which (if any) tool is called by the model. This can be either: a string ("none", "auto", or "required") or an object of type ToolChoiceObject to force a specific tool call.

parallel_tool_callsboolean

Whether to enable parallel function calling during tool use. Defaults to true.

userstring

A unique identifier representing your end-user.

function_callobject

(Deprecated) Controls which (if any) function is called by the model. This can be either: a string ("none" means the model will not call a function and instead generates a message; "auto" means the model can pick between generating a message or calling a function) or an object of type FunctionCallObject to force a specific function call.

functions[]

(Deprecated) A list of functions the model may generate JSON inputs for. Deprecated in favor of Tools.

web_search_options

Configuration for web search tool. This feature allows models to search the web for up-to-date information. Only applicable to search-enabled models (e.g., gpt-4o-search-preview, gpt-5-search-api).

thinking

Configuration for extended thinking. Enables the model to perform deeper reasoning before responding. Includes budget_tokens to limit thinking tokens and summary mode for reasoning output.

includestring[]

Specify additional output data to include in the response. Possible values include: "usage.prompt_tokens_details", "usage.completion_tokens_details".

instructionsstring

A system-level instruction that guides the model's behavior. This is an alternative way to provide system context, similar to using a system or developer message.

truncation_strategy

Controls how the conversation is truncated if it exceeds the context window. Specify the strategy type and optionally the number of messages to keep.

text

Configuration for structured text output format.

Responses

StatusTypeDescription
200

OK

400

Bad Request

500application/json

Internal Server Error

404

Not Found

curl -X POST "$LMKIT_ONE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $LMKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "messages": [
    {
      "role": "string",
      "content": {},
      "name": "string",
      "tool_calls": [
        {}
      ]
    }
  ],
  "model": "string",
  "agent": "string",
  "skill": "string",
  "skill_inputs": {}
}'