Research a question, reported as it happens
The same capability as POST /api/research, with progress. Not a second implementation: it runs the same pipeline, and the done event carries exactly what the other route returns.
The response is a server-sent event stream, so it is exempt from the usual {success, result, message} envelope. Each frame is an event: name and a data: payload holding one event object.
Events arrive in this order. started immediately, which exists only to prove the stream is open while the model plans, because that call alone can take ten seconds. planned with the sub-questions. One searched per sub-question, as each lands rather than all together at the end. sources with everything gathered so far. writing once the reading is done. Then delta fragments as the answer is generated, and finally done.
Treat everything before done as a view of the wait. The deltas are raw model output, and the finished answer has had any citation pointing at no source stripped out of it, so the two can differ. A client that rebuilt the report from fragments would also have no way to notice a dropped connection.
POST rather than GET because the question is a body, which the browser EventSource API cannot send. Read it with fetch and parse the frames.
Authorizations
An API key, sent as Authorization: Bearer enc_…. A dashboard session cookie works on the same route.
Body
What to research. query is accepted as an alias.
1000"how do solid state batteries differ from lithium ion in practice"
Rounds of search-and-read. Round one searches what the question obviously needs; each round after asks what is still missing and searches for that. A round may end the report early by finding nothing missing, which is a correct answer rather than a shortcut.
1 <= x <= 3How many pages may be cited.
1 <= x <= 24Restricts every search behind the report.
any, day, week, month, year Response
A server-sent event stream.
One frame of the stream. Which fields are present depends on type.
started, planned, searched, sources, writing, delta, done, error On planned and searched.
On planned: the sub-questions this round will search.
On searched: the sub-question that just finished.
On sources: everything gathered so far, renumbered.
On delta: a fragment of the answer.
On done: the finished report. This one is the authority.
On error: a sentence explaining why there will be no report.