> ## Documentation Index
> Fetch the complete documentation index at: https://docs.genow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit chat query

> Streams an answer for a **document chat**: the model uses files already linked to `chat_id` in Genow (and conversation history for that chat). Responses are **Server-Sent Events** (`text/event-stream`).

**Authentication:** send a valid Bearer JWT (same as other Genow APIs).

**Event format:** each SSE message is one line starting with `data: ` followed by JSON: `{"type": "<TokenType>", "data": ...}`. Parse lines that begin with `data: `; ignore heartbeats or empty lines as needed.

**Token types (`type` field):** the same vocabulary is shared across Genow streaming chat endpoints. For **this** endpoint (`POST /api/chat/ask`) you should rely on:

- **`ANSWER`** — `data` is a **string** fragment of the model reply. Many events are emitted; concatenate `data` in order to rebuild the full answer.
- **`FINISHED`** — stream is complete. `data` is **`null`**. No further answer tokens follow.

Other token types appear on **knowledge-asset / search** streaming routes, not on document chat ask. Clients should still handle unknown `type` values defensively:

- **`SPLIT_SUBTASKS`** — `data` is typically a **list of strings** (sub-questions or pipeline steps) when the router splits work.
- **`RERANKED_DOCUMENTS`** — `data` is typically structured retrieval metadata (e.g. list of document-like objects) after reranking.
- **`REASONING`** — `data` may contain **reasoning** or intermediate model output when the deployment exposes it.
- **`FULL_ANSWER`** — `data` may carry a **full answer** payload in one shot on some pipelines (contrast with streamed `ANSWER` chunks).
- **`images`** — `data` relates to **image** results when the pipeline returns them (shape depends on caller).

**Example SSE fragment** (document chat; illustrative):

```
data: {"type": "ANSWER", "data": "The "}
data: {"type": "ANSWER", "data": "key date is "}
data: {"type": "ANSWER", "data": "2030-01-01."}
data: {"type": "FINISHED", "data": null}
```

**Examples**

`curl` (disable buffering with `-N`). The `llm` value must match a `chat_model_name` from your deployment (below uses **Gemini Pro** as `gemini-2.5-pro`, a common LiteLLM id):

```bash
curl -N -X POST 'https://<your-genow-host>/api/chat/ask' \
  -H 'Authorization: Bearer <jwt>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "What are the key dates in these documents?",
    "llm": "gemini-2.5-pro",
    "chat_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "entry_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
  }'
```

Use the **models** endpoint to list valid `llm` values for your environment. Request body examples are also attached to the `DocumentChatRequest` schema in the OpenAPI document.



## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.genow.ai/llms.txt).
