---
title: "Chat completions"
method: POST
path: "/llm/v1/chat/completions"
tags: ["LLMs"]
---

# Chat completions

`POST /llm/v1/chat/completions`

Create a completion for the provided prompt and parameters. Compatible with OpenAI's chat completions API. Supports 40+ models including GPT-4, Claude, Gemini, and CaseMark legal AI models. Includes streaming support, token counting, and usage tracking.

## Request body

- object
  - `model` string — Model to use for completion. Defaults to casemark/core-large if not specified
  - `messages` object[], required — List of messages comprising the conversation
    - `role` 'system' | 'user' | 'assistant' — The role of the message author
    - `content` string — The contents of the message
  - `max_tokens` integer — Maximum number of tokens to generate
  - `temperature` number — Sampling temperature between 0 and 2
  - `stream` boolean — Whether to stream back partial progress
  - `casemark_show_reasoning` boolean — CaseMark-only: when true, allows reasoning fields in responses. Defaults to false (reasoning is suppressed).
  - `top_p` number — Nucleus sampling parameter
  - `frequency_penalty` number — Frequency penalty parameter
  - `presence_penalty` number — Presence penalty parameter

## Response `200`

Successful completion response

- object
  - `id` string — Unique identifier for the completion
  - `object` string
  - `created` integer — Unix timestamp of completion creation
  - `model` string — Model used for completion
  - `choices` object[]
    - `index` integer
    - `message` object
      - `role` string
      - `content` string
    - `finish_reason` string
  - `usage` object
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer
    - `cost` number — Cost in USD

## Other responses

- `400` — Invalid request parameters
- `401` — Invalid or missing API key
- `403` — API key does not have access to LLM service

---

[API](https://skmtc.net/casemark/apis/case-dev-api.md) · [All operations](https://skmtc.net/casemark/apis/case-dev-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/casemark/case-dev-api/revisions/5b7e64e6d6f9/schema)
