Documentation Index
Fetch the complete documentation index at: https://mintlify.com/IconDean/research-agent/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/research/stream runs the same full research pipeline as POST /api/research but delivers results progressively over a Server-Sent Events (SSE) connection. Instead of waiting for a single blocking response, your client receives a real-time stream of typed event messages as the agent plans its strategy, performs web searches, fetches pages, detects gaps, and ultimately assembles the final report. This is the endpoint used by the built-in web UI and is the recommended choice for any user-facing integration.
Request
POST /api/research/stream
| Header | Value |
|---|---|
Content-Type | application/json |
Body fields
The natural-language research question to investigate. Must be between 3 and 2000 characters. Whitespace-only strings are rejected with a
400 error before the stream opens.Response
Content-Type: text/event-stream
The response body is a continuous stream of SSE messages. Each message follows the standard SSE wire format:
type— a fixed string identifying the event category (see the table below)detail— a string whose content varies by event type
end event. The report or error event always arrives immediately before end.
Event types
The
end event is always the final message in the stream, regardless of whether the research succeeded or failed. Always listen for end to know when it is safe to close the connection.| Type | When it fires | detail content |
|---|---|---|
start | Research pipeline begins | The research question as submitted |
plan | After the agent produces its research plan | "Type: X, Strategy: Y, Queries: Q1, Q2, …" |
thinking | At each internal agent iteration | "Iteration N" or a short description of the current reasoning step |
search | Each time the agent issues a web search | The query string sent to the search engine |
fetch | Each time the agent fetches a web page | The URL being retrieved |
block | A source is rejected during quality evaluation | "<URL> (score: X.XX)" |
gaps | After gap-detection analysis completes | "Gaps found: N, Follow-up queries: Q1, Q2, …" |
report | Research complete — final output | The full markdown report string |
error | Fatal error during research | Human-readable error message |
end | Always the last event | No meaningful detail (may be an empty string) |
Error responses (before stream opens)
| Status | Condition |
|---|---|
400 | question is empty or whitespace-only |
422 | Malformed body or question fails length validation |
error event followed by an end event — the HTTP status remains 200 at that point.
Examples
Example SSE output
Client-side cancellation
To cancel an in-flight stream from the browser or Node.js, pass anAbortController signal to fetch and call abort() when needed:
api.ts) exposes this pattern via the abort() function returned alongside the done promise.