---
title: "Chat (POST)"
method: POST
path: "/v1/chat/completions"
tags: ["Chat"]
---

# Chat (POST)

`POST /v1/chat/completions`

Primary endpoint. OpenAI-compatible — works with any OpenAI SDK client.

- Last user message is used as the search query
- Earlier messages provide conversation context
- `stream` defaults to `false`
- `session_id` is optional (omit for stateless usage)

## Request body

- ChatRequest
  - `messages` ChatMessage[], required — Conversation messages. Last user message = search query.
    - `role` 'system' | 'user' | 'assistant', required
    - `content` union, required
      - string
      - ContentPart[] — Vision format: array of text and image_url parts
        - `type` 'text' | 'image_url', required
        - `text` string — Text content (when type is "text")
        - `image_url` object — Image reference (when type is "image_url")
          - `url` string — HTTPS URL or base64 data URI (`data:image/jpeg;base64,...`). Base64 images are auto-hosted before processing.
  - `model` string — Ignored — always uses lixsearch
  - `stream` boolean — Enable SSE streaming
  - `session_id` string — Session ID for multi-turn context persistence. Omit for stateless (ephemeral) requests.
  - `temperature` number — Accepted for compatibility, not used
  - `max_tokens` integer — Accepted for compatibility, not used

## Response `200`

Chat response

- ChatResponse
  - `id` string
  - `object` 'chat.completion'
  - `created` integer
  - `model` string
  - `choices` object[]
    - `index` integer
    - `message` object
      - `role` 'assistant'
      - `content` string
    - `finish_reason` 'stop'
  - `usage` object
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `total_tokens` integer

## Other responses

- `400` — Invalid request
- `401` — API key required
- `403` — Invalid API key
- `503` — Server not ready

---

[API](https://skmtc.net/elixpo/apis/lixsearch-api.md) · [All operations](https://skmtc.net/elixpo/apis/lixsearch-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elixpo/lixsearch-api/versions/1b4365f47b75/schema)
