Run Query
Runs the query that Create Query Token issued a token for and streams the answer as Server-Sent Events. The credential is the query token, not the knowledge base API key. The token is checked when the request is accepted.
For the two-call flow and how to read the stream, see Query the Knowledge Base.
For which errors to retry and what the error details mean, see Handle Errors.
A successful query saves its query record before sending answer.done. Repeating the call runs the query again.
1 min read
post/knowledge-fs/query-stream
Request example
Response
post/knowledge-fs/query-stream
Authorization
Headers
The
trace_id from the Create Query Token response, the same value as the token's trace_id claim. A value that does not match the token is rejected with 403. See Query the Knowledge Base.Body
application/jsonCopied from the returned
request object. These IDs do not filter or rank retrieved content.Items: max 100
Copied from the returned
request object. These IDs do not filter or rank retrieved content.Items: max 100
Internal ID of the knowledge base, copied from the
request object of Create Query Token. Must match the token. A mismatch is rejected with 403.Length: min 1
Retrieval depth, copied from the
request object of Create Query Token. null is accepted and means the knowledge base's default depth.Options:
fastdeepresearchnullThe question. Use a nonblank query. Also limited to 16,384 UTF-8 bytes.
Length: max 16000Pattern: \S
Session ID, copied from the
request object of Create Query Token.Responses
text/event-stream
The stream opened. Events follow as
text/event-stream, whatever Accept the request sends. Before the stream opens, handle failures as HTTP errors. After it opens, handle an answer.error event as failure even though the HTTP status is 200.