curl --request POST \
--url https://api.globalwebindex.com/beta/spark-api/agents/spark \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What is Gen Z car ownership in the UK?",
"dataset_code": "ds-core"
}
'import requests
url = "https://api.globalwebindex.com/beta/spark-api/agents/spark"
payload = {
"prompt": "What is Gen Z car ownership in the UK?",
"dataset_code": "ds-core"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'What is Gen Z car ownership in the UK?', dataset_code: 'ds-core'})
};
fetch('https://api.globalwebindex.com/beta/spark-api/agents/spark', 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://api.globalwebindex.com/beta/spark-api/agents/spark",
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([
'prompt' => 'What is Gen Z car ownership in the UK?',
'dataset_code' => 'ds-core'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.globalwebindex.com/beta/spark-api/agents/spark"
payload := strings.NewReader("{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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://api.globalwebindex.com/beta/spark-api/agents/spark")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/beta/spark-api/agents/spark")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}"
response = http.request(request)
puts response.read_bodyStream an Agent Spark response
Streams a Server-Sent Events response for an Agent Spark turn.
Event order follows wire order on the connection. The loading events expose provisional thinking text that may differ from the final natural_language answer.
Pre-stream validation and upstream failures return JSON error responses. After the stream starts, terminal failures are delivered as an in-band error event.
curl --request POST \
--url https://api.globalwebindex.com/beta/spark-api/agents/spark \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What is Gen Z car ownership in the UK?",
"dataset_code": "ds-core"
}
'import requests
url = "https://api.globalwebindex.com/beta/spark-api/agents/spark"
payload = {
"prompt": "What is Gen Z car ownership in the UK?",
"dataset_code": "ds-core"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'What is Gen Z car ownership in the UK?', dataset_code: 'ds-core'})
};
fetch('https://api.globalwebindex.com/beta/spark-api/agents/spark', 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://api.globalwebindex.com/beta/spark-api/agents/spark",
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([
'prompt' => 'What is Gen Z car ownership in the UK?',
'dataset_code' => 'ds-core'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://api.globalwebindex.com/beta/spark-api/agents/spark"
payload := strings.NewReader("{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<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://api.globalwebindex.com/beta/spark-api/agents/spark")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.globalwebindex.com/beta/spark-api/agents/spark")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What is Gen Z car ownership in the UK?\",\n \"dataset_code\": \"ds-core\"\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Body
Agent Spark request payload.
Request payload for the Agent Spark stream.
The chat prompt.
Optional existing chat session ID.
Optional root dataset code used to scope the chat. When both are provided, a non-empty dataset_codes list takes precedence.
"ds-core"
Dataset codes that must belong to the same dataset tree. Takes precedence over dataset_code when both are provided.
Optional docked audience UUIDs.
Response
Successful Server-Sent Events stream. Each frame is one of the AgentSparkStream event types. Event order follows wire order on the connection.
- chat_init
- loading
- sources
- insights
- natural_language
- end
- error
One Server-Sent Events frame from POST /beta/spark-api/agents/spark. The event field is the SSE event name. data is the JSON object on the corresponding data: line.
Was this page helpful?

