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

# answer_stream()

> Stream a RAG answer from POST /answer/stream.

## HTTP client - answer\_stream()

`MoorchehEdgeApiClient.answer_stream()` calls **`POST /answer/stream`** and yields raw response bytes (SSE chunks). Use this when you need token-by-token output; for a one-shot answer, use [`answer_text()`](/python-client/answer) or [`answer()`](/python-client/answer) instead.

The high-level **`MoorchehEdge` SDK** does not wrap streaming yet - use `MoorchehEdgeApiClient` directly.

```python theme={null}
from moorcheh_edge import Embedder, MoorchehEdgeApiClient

client = MoorchehEdgeApiClient("http://localhost:8080")
embedder = Embedder()
query = "Who won the football match?"
vector = embedder.embed_query(query)

payload = {
    "query": query,
    "query_vector": vector,
    "top_k": 5,
}

for chunk in client.answer_stream(payload):
    print(chunk.decode("utf-8"), end="")
```

Parse SSE events from the byte stream, or use the internal `_sse.iter_sse_events` helper if you build tooling inside the package.

### Optional prompts and history

Same optional fields as [`answer_text()`](/python-client/answer):

```python theme={null}
payload = {
    "query": "What are your hours?",
    "query_vector": embedder.embed_query("What are your hours?"),
    "top_k": 3,
    "kiosk_mode": True,
    "threshold": 0.3,
    "header_prompt": "You are a helpful store assistant.",
    "footer_prompt": "Answer in one sentence.",
    "chat_history": [
        {"role": "user", "content": "Hi"},
        {"role": "assistant", "content": "Hello! How can I help?"},
    ],
    "temperature": 0.2,
}

for chunk in client.answer_stream(payload):
    ...
```

## SSE events

See [API: Answer stream](/api-references/answer-stream) for the `meta`, `token`, `done`, and `error` event shapes.

When **no passages** are retrieved, you get one `token` event with *I don't have enough information to answer that question.* then `done` with `context_count: 0` - the LLM is not called.

## Requirements

* Store must contain uploaded documents (text or vector mode).
* Ollama must be running with **`qwen2.5:0.5b-instruct`** (use `moorcheh-edge up --with-llm` on Linux).

## Related

* [API: Answer stream](/api-references/answer-stream)
* [Python: answer\_text()](/python-client/answer)
* [Voice server](/api-references/voice-serve) - streams through `/ask/stream` on edge hardware
