Stream agent response
curl --request POST \
--url https://rest-api.captide.co/api/v2/rag/agent-response-stream \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"query": "<string>",
"documentIds": "<string>"
}
'import requests
url = "https://rest-api.captide.co/api/v2/rag/agent-response-stream"
payload = {
"query": "<string>",
"documentIds": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', documentIds: '<string>'})
};
fetch('https://rest-api.captide.co/api/v2/rag/agent-response-stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://rest-api.captide.co/api/v2/rag/agent-response-stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'documentIds' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://rest-api.captide.co/api/v2/rag/agent-response-stream"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://rest-api.captide.co/api/v2/rag/agent-response-stream")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rest-api.captide.co/api/v2/rag/agent-response-stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodydata: {"type": "thinking", "role": "assistant", "content": "Identifying companies from your query...", "stage": "search"}
data: {"type": "thinking", "role": "assistant", "content": "Selecting documents for Zscaler, Inc....", "stage": "document_selection"}
data: {"type": "thinking", "role": "assistant", "content": "Found 5 relevant pages.", "stage": "analyzing"}
data: {"type": "message", "role": "assistant", "content": "Z"}
data: {"type": "message", "role": "assistant", "content": "scaler"}
...
data: {"type": "content_final", "role": "assistant", "content": "Zscaler’s net dollar retention was **115%** in Q4 FY2026 [#43c00004]. …"}
data: {"type": "sources", "content": {"#43c00004": {"content": "…", "pageNumber": 5, "excerpt": "115%", "documentMetadata": {"id": "a0dcd3e7-7985-4fbc-9c77-371b4232e242", "title": "Zscaler, Inc. Earnings Call Transcript Q4 2026 (2026-09-03)", …}}}}
data: {"type": "done"}
Agentic RAG
Agent Response (Stream)
Answer a natural-language question from corporate disclosures, streamed as Server-Sent Events, so you can show progress and the answer as it is written.
Each event is a data: line holding a JSON object. Its type is one of:
thinking: a progress update, with astagemessage: the next piece of the answercontent_final: the complete answer; when present, it replaces the text built frommessageeventssources: thesourceMap, mapping each citation to its passage, page and excerptwarning: a non-fatal issue, such as no relevant documents being founddone: the end of the stream
POST
/
api
/
v2
/
rag
/
agent-response-stream
Stream agent response
curl --request POST \
--url https://rest-api.captide.co/api/v2/rag/agent-response-stream \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"query": "<string>",
"documentIds": "<string>"
}
'import requests
url = "https://rest-api.captide.co/api/v2/rag/agent-response-stream"
payload = {
"query": "<string>",
"documentIds": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: '<string>', documentIds: '<string>'})
};
fetch('https://rest-api.captide.co/api/v2/rag/agent-response-stream', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://rest-api.captide.co/api/v2/rag/agent-response-stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'documentIds' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://rest-api.captide.co/api/v2/rag/agent-response-stream"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://rest-api.captide.co/api/v2/rag/agent-response-stream")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://rest-api.captide.co/api/v2/rag/agent-response-stream")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"documentIds\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodydata: {"type": "thinking", "role": "assistant", "content": "Identifying companies from your query...", "stage": "search"}
data: {"type": "thinking", "role": "assistant", "content": "Selecting documents for Zscaler, Inc....", "stage": "document_selection"}
data: {"type": "thinking", "role": "assistant", "content": "Found 5 relevant pages.", "stage": "analyzing"}
data: {"type": "message", "role": "assistant", "content": "Z"}
data: {"type": "message", "role": "assistant", "content": "scaler"}
...
data: {"type": "content_final", "role": "assistant", "content": "Zscaler’s net dollar retention was **115%** in Q4 FY2026 [#43c00004]. …"}
data: {"type": "sources", "content": {"#43c00004": {"content": "…", "pageNumber": 5, "excerpt": "115%", "documentMetadata": {"id": "a0dcd3e7-7985-4fbc-9c77-371b4232e242", "title": "Zscaler, Inc. Earnings Call Transcript Q4 2026 (2026-09-03)", …}}}}
data: {"type": "done"}
Body
application/json
Response
Server-Sent Events: thinking, message, content_final, sources, warning, done
Was this page helpful?