---
title: "Chatbot Stream Endpoint"
method: POST
path: "/api/chatbot/stream"
tags: ["chatbot"]
---

# Chatbot Stream Endpoint

`POST /api/chatbot/stream`

Streamed variant of /chatbot: emits the reply as SSE paragraph events so
the first bubble renders as soon as the first paragraph is generated. The
buffered /chatbot endpoint is unchanged and remains the fallback for old
app versions and for client-side retry.

Events: meta {conversation_id, protocol} → paragraph {index, text}* →
done {conversation_id, paragraphs, sources, bible_verses} | error {code,
message, paragraphs_emitted}. Comment lines (": ping") are heartbeats.

Mid-stream provider failure emits an error event and persists nothing —
the client discards the partial bubbles and retries fresh.

request.sendAudio is deliberately ignored here: voiceover for streamed
replies is fetched separately by the client (/tts), since audio for a
reply that is still generating can't be inlined into the SSE stream.

## Headers

- `x-user-id` string, nullable

## Request body

- ChatRequest
  - `message` string
  - `conversation_id` string, nullable
  - `sendAudio` boolean, nullable
  - `newUser` boolean, nullable
  - `promptKey` string, nullable — Used alongside daily topic quest
  - `image_ids` string[], nullable
  - `retriedFromStream` boolean, nullable — Set by the client when re-sending a message whose streamed attempt failed. The stream route already saved the user message and counted the quota, so the buffered route must not do either again. Contract: the client sets this ONLY after receiving the stream's meta event — meta is emitted after the save/increment phase, so it is the signal that both actually happened. A stream that failed before meta (HTTP error, dropped connection) persisted nothing and must be retried WITHOUT this flag.

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/usecreed/apis/creed-api.md) · [All operations](https://skmtc.net/usecreed/apis/creed-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/usecreed/creed-api/revisions/ec6a7aef1f3e/schema)
