# HTTP payloads streaming and errors

Source: https://usecns.dev/thalamus-topic-http-payloads-streaming-and-errors/

[Start here](https://usecns.dev/manual-thalamus/)
[CLI commands](https://usecns.dev/commands-thalamus/)
[Configuration & integration](https://usecns.dev/thalamus-topics/)

Send the JSON schema expected by the selected model server: chat uses `messages`, completions uses `prompt`, embeddings typically uses `input`, and reranking/verification use that server's own task fields. Thalamus does not normalize those task schemas or turn a decide body into chat messages on fallback. It buffers the incoming body, opportunistically reads string `model`, boolean `stream` and the session fields, and otherwise forwards the bytes (apart from the documented model rewrites). Missing, malformed or non-object JSON is not itself an inference-handler validation error: routing can still happen and upstream decides whether the payload is valid. Registration instead requires an `application/json` body matching its typed fields; extraction failures are framework responses, not the router error envelope.

For a streaming chat request, add `"stream":true` to the guide's request and use `curl -N` to avoid client buffering. A true `stream` field **or** upstream `content-type` containing `text/event-stream` selects byte streaming. Status, content type, SSE event/data lines and upstream completion markers are relayed, not regenerated; no router event schema, heartbeat, `[DONE]` synthesis or Last-Event-ID resume is provided. Other responses are buffered to completion. Response headers omit connection/transfer-encoding/content-length; routing headers are then added. An SSE read failure after headers have been sent ends/errors the body; it cannot become a new JSON 502 response. Closing a stream releases its inflight slot and records completion, but does not prove the model server cancelled computation or that the full answer was delivered.

| Failure origin | Response contract |
| --- | --- |
| Router selection/admission | 503 JSON `{"error":{"message":"...","type":"thalamus_router_error","code":503}}`. |
| Empty registry | Same shape, type `thalamus_no_members_configured`, code 503; checked before inference payload inspection and model listing. |
| Proxy send or buffered response-body read | 502 with router error shape. No automatic reroute. |
| Registration/policy validation; missing drain/remove name | Router envelope with 400 or 404 as listed in the admin table. |
| Upstream HTTP error | Upstream status/body, not converted to the router envelope; decide's documented 404 path fallback is the exception. |
| Unknown path, unsupported method, body extraction/size rejection | Framework response; do not assume the JSON router envelope for every HTTP error. |