Query Knowledge Engine
curl --request POST \
--url https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"name": "<string>",
"advanced_reasoning": true,
"model": "llama-v3-70b",
"context_id": "<string>"
}
'import requests
url = "https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query"
payload = {
"query": "<string>",
"name": "<string>",
"advanced_reasoning": True,
"model": "llama-v3-70b",
"context_id": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
name: '<string>',
advanced_reasoning: true,
model: 'llama-v3-70b',
context_id: '<string>'
})
};
fetch('https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query', 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.getdecisional.ai/api/v1/knowledge-engines/{id}/query",
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>',
'name' => '<string>',
'advanced_reasoning' => true,
'model' => 'llama-v3-70b',
'context_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.getdecisional.ai/api/v1/knowledge-engines/{id}/query"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.getdecisional.ai/api/v1/knowledge-engines/{id}/query")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body"<string>"Knowledge Engines
Query Knowledge Engine
Streams a response to a natural language query using Server-Sent Events
POST
/
api
/
v1
/
knowledge-engines
/
{id}
/
query
Query Knowledge Engine
curl --request POST \
--url https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"name": "<string>",
"advanced_reasoning": true,
"model": "llama-v3-70b",
"context_id": "<string>"
}
'import requests
url = "https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query"
payload = {
"query": "<string>",
"name": "<string>",
"advanced_reasoning": True,
"model": "llama-v3-70b",
"context_id": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
name: '<string>',
advanced_reasoning: true,
model: 'llama-v3-70b',
context_id: '<string>'
})
};
fetch('https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query', 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.getdecisional.ai/api/v1/knowledge-engines/{id}/query",
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>',
'name' => '<string>',
'advanced_reasoning' => true,
'model' => 'llama-v3-70b',
'context_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.getdecisional.ai/api/v1/knowledge-engines/{id}/query"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.getdecisional.ai/api/v1/knowledge-engines/{id}/query")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getdecisional.ai/api/v1/knowledge-engines/{id}/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"name\": \"<string>\",\n \"advanced_reasoning\": true,\n \"model\": \"llama-v3-70b\",\n \"context_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body"<string>"Query a knowledge engine with a natural language question. This endpoint uses Server-Sent Events (SSE) to stream the response back to the client.
Request Format
string
required
The natural language query to ask the knowledge engine
string
required
A name for this query workflow
string
Context ID used in case of thread mode for chat based workflows
boolean
Flag to enable advanced reasoning for the query
string
The model to use for the query
Example Request
{
"query": "What were the company's revenue figures for 2023?",
"name": "Revenue Analysis",
"advanced_reasoning": true,
"model": "llama-v3-70b"
}
Response Format
The response is streamed using Server-Sent Events (SSE) with the following event types:message: Contains intermediate response chunks as they are generatederror: Contains error messages if something goes wrongdone: Final event containing the complete response with metadata
Example Response Stream
// Intermediate messages
event: message
data: "Based on the available information, "
event: message
data: "the company's revenue in 2023 was "
event: message
data: "$1.2 billion, representing a 15% increase from 2022."
// Final response with complete result
event: done
data: {
"id": "wf_abc123xyz789",
"name": "Revenue Analysis",
"query": "What were the company's revenue figures for 2023?",
"type": "query",
"knowledge_engine_id": "kng_abc123xyz789",
"status": "processed",
"response": "Based on the available information, the company's revenue in 2023 was $1.2 billion, representing a 15% increase from 2022.",
"citations": [
{
"text": "In fiscal year 2023, total revenue reached $1.2B, up 15% YoY",
"source": "Annual Report 2023",
"page": 45
}
],
"created_at": 1679644800
}
Notes
- The streaming response allows for real-time display of the AI’s response as it’s being generated
- The final
doneevent includes the complete response along with metadata and citations - If an error occurs, the stream will emit an
errorevent and close the connection - Clients should handle connection closure appropriately using the
closeevent
The streaming response requires a client that supports Server-Sent Events (SSE). Most modern browsers and HTTP clients support this feature.
Response Object
string
Unique identifier for the workflow
string
Name of the workflow
string
The original query that was asked
string
Type of workflow (always “query”)
string
ID of the knowledge engine that was queried
string
Status of the workflow (“processed” when complete)
string
The complete response text
array
number
Unix timestamp when the workflow was created
Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Path Parameters
Knowledge engine ID
Body
application/json
The natural language query
Name of the workflow
Enable advanced reasoning
LLM to use for the query
Available options:
auto, claude-4.5-sonnet, llama-v3-70b, llama-4-scout, llama-4-maverick, gemini-2.5, gpt-5.4, claude-4.6-haiku, gpt-4.1 Example:
"llama-v3-70b"
Context ID for maintaining conversation history in chat mode
Response
Streaming response using Server-Sent Events
The response is of type string.