Skip to main content

Stream an AI rewrite of a selected span (ASK-215)

POST 

/study-guides/:study_guide_id/ai/edit

User selects text in the study-guide editor, gives an instruction (e.g. "make this clearer", "add an example"), and the model streams a replacement. The full replacement is captured server-side and persisted to the study_guide_edits audit table; the user's accept/reject decision is recorded later via PATCH on /study-guides/{id}/ai/edits/{edit_id}.

Per the ticket Decision: server returns the FULL replacement, NOT a diff syntax. The frontend computes the diff client-side from original_span (echoed back) and the streamed delta events.

Request

Responses

SSE event stream. Event types: delta (text chunk), usage (final token counts), done (terminator), error (mid-stream failure).