---
title: "Create a chat completion"
method: POST
path: "/api/inference/v1/chat/completions"
tags: ["AI"]
---

# Create a chat completion

`POST /api/inference/v1/chat/completions`

## Request

- Base URL: `https://docs.anzworldline-solutions.com.au`
- URL: `https://docs.anzworldline-solutions.com.au/api/inference/v1/chat/completions`
- Auth: none declared
- TypeScript: <https://skmtc.dev/anzworldline-solutions/apis/dotcms-rest-api/docs/api/inference/v1/chat/completions/post.ts> (a function with typed inputs; its response is checked against the schema)

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.

## Query parameters

- `siteId` string

## Request body

- ChatCompletionRequestView: Chat completion request in the OpenAI-compatible shape
  - `model` string: Model id, as listed by GET /models
  - `messages` MessageView[]: The conversation, oldest first
    - `role` string
    - `content` JsonNode
    - `tool_calls` ToolCallView[]
      - `id` string
      - `type` string
      - `function` FunctionCallView
        - `name` string
        - `arguments` string
    - `tool_call_id` string
    - `name` string
  - `tools` ToolView[]: Tools the model may call
    - `type` string
    - `function` FunctionDefView
      - `name` string
      - `description` string
      - `parameters` JsonNode
  - `tool_choice` JsonNode
  - `response_format` JsonNode
  - `stream` boolean: Stream the answer as server-sent events
  - `stream_options` StreamOptionsView: Streaming options
    - `include_usage` boolean
  - `temperature` number, double: Sampling temperature
  - `max_tokens` integer: Maximum tokens to generate
  - `top_p` number, double: Nucleus sampling
  - `stop` string[]: Stop sequences
  - `n` integer: Number of choices; not supported

## Response `200`

The completion, or the event stream when stream was requested

- ChatCompletionView: Chat completion response in the OpenAI-compatible shape
  - `id` string: Completion id
  - `object` string: Object type
  - `created` integer: Epoch seconds
  - `model` string: Model that served the request
  - `choices` ChoiceView[]: The answers
    - `index` integer
    - `message` MessageView: The conversation, oldest first
      - `role` string
      - `content` JsonNode
      - `tool_calls` ToolCallView[]
        - `id` string
        - `type` string
        - `function` FunctionCallView
          - `name` string
          - `arguments` string
      - `tool_call_id` string
      - `name` string
    - `finish_reason` string
  - `usage` UsageView: Tokens consumed
    - `prompt_tokens` integer: Tokens across every input
    - `total_tokens` integer: Total tokens

## Other responses

- `400`: Malformed request, or one asking for something unsupported
- `401`: Unauthorized - authentication required
- `403`: Forbidden - the caller cannot read the requested site
- `404`: The requested model is not configured for the resolved site
- `429`: Too many streamed completions are already in flight on this node
- `502`: The model provider failed to complete the request

## Changes

- **2026-10-30** `4fd8e917d458`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/anzworldline-solutions/apis/dotcms-rest-api/changes/api/inference/v1/chat/completions/post.md)

---

[API](https://skmtc.dev/anzworldline-solutions/apis/dotcms-rest-api.md) - [All operations](https://skmtc.dev/anzworldline-solutions/apis/dotcms-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/anzworldline-solutions/apis/dotcms-rest-api/revisions/4fd8e917d458?raw)
