AI

Create a chat completion

Changed on

Runs one chat completion against the model the resolved site has configured, in the OpenAI-compatible request and response shape. Set "stream": true to receive the answer as server-sent events, each frame a chat.completion.chunk, closing with data: [DONE] — a stream that failed ends on an error frame and never carries that marker. The model field is required and must be one the site has configured; there is no implicit default. Every response reports the serving site in the X-dotCMS-Resolved-Site header.

post/api/inference/v1/chat/completions

Request

Query parameters

siteIdstring

Request body

modelstring

Model id, as listed by GET /models

tool_choiceJsonNode
response_formatJsonNode
streamboolean

Stream the answer as server-sent events

temperaturenumber double

Sampling temperature

max_tokensinteger

Maximum tokens to generate

top_pnumber double

Nucleus sampling

stopstring[]

Stop sequences

ninteger

Number of choices; not supported

Example request

{
  "model": "gpt-4o"
}

Response

The completion, or the event stream when stream was requested

idstring

Completion id

objectstring

Object type

createdinteger

Epoch seconds

modelstring

Model that served the request

Example response

{
  "id": "chatcmpl-8f3a",
  "object": "chat.completion",
  "model": "gpt-4o"
}

Changes