---
title: "Stream a knowledge-graph query response (SSE)."
method: POST
path: "/v1/query/stream"
tags: ["query"]
---

# Stream a knowledge-graph query response (SSE).

`POST /v1/query/stream`

## Request

- Base URL: `https://api.andish.ru` (the document declares no server; this is the origin it was published from)
- URL: `https://api.andish.ru/v1/query/stream`
- Auth: none declared

Stream a natural-language query response via Server-Sent Events (ADR-015 SSE framing protocol v1).

**Pre-flight cost cap:** If the tenant's daily cost cap is already exceeded, the server returns HTTP 402 **before** opening the SSE stream (ADR-015 §Cost-cap behaviour). Body: ``{"error": "cost_cap_exceeded", "current_spend": "<decimal>", "cap": "<decimal>"}``. The same pre-flight gate also returns 402 ``{"error": "platform_budget_paused"}`` when the platform-wide daily spend cap is reached and this tenant is billed on the platform key (ADR-066); a tenant on their own key is unaffected.

**Chunk ordering (normative):** ``token*`` → ``source*`` → ``done``.

**Stage 1 stub:** emits 2 hard-coded token chunks + 1 done chunk.

**Versioning:** Response header ``X-Andish-Stream-Version: 1`` on every SSE response.  Send ``X-Andish-Stream-Version-Accepted: 1`` for v2 upgrade negotiation (ADR-015 §Versioning).

## Request body

- StreamQueryRequest: Request body for POST /v1/query/stream. Mirrors QueryRequest from query.py; stream: true is implicit — this endpoint always streams.
  - `query` string, required: Natural-language question to ask the knowledge graph.
  - `mode` 'mix' | 'local' | 'global' | 'naive': Retrieval mode. ``mix`` (default) is recommended for production. ``local`` / ``global`` / ``naive`` are x-experimental.
  - `include_sources` boolean: When true, source chunks are emitted after the last token.

## Response `200`

Successful Response

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/andish/apis/mnemo-api.md) · [All operations](https://skmtc.dev/andish/apis/mnemo-api/llms.txt) · [OpenAPI document](https://skmtc.dev/andish/apis/mnemo-api/revisions/d5449f23414c?raw)
