curl --request POST \
--url https://aigmented.io/api/v1/collections/{id}/ask \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"question": "What does the agreement say about liability?",
"model": "gpt-4o-mini",
"mode": "fast",
"stream": false,
"top_k": 10,
"current_only": true
}
'import requests
url = "https://aigmented.io/api/v1/collections/{id}/ask"
payload = {
"question": "What does the agreement say about liability?",
"model": "gpt-4o-mini",
"mode": "fast",
"stream": False,
"top_k": 10,
"current_only": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
question: 'What does the agreement say about liability?',
model: 'gpt-4o-mini',
mode: 'fast',
stream: false,
top_k: 10,
current_only: true
})
};
fetch('https://aigmented.io/api/v1/collections/{id}/ask', 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://aigmented.io/api/v1/collections/{id}/ask",
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([
'question' => 'What does the agreement say about liability?',
'model' => 'gpt-4o-mini',
'mode' => 'fast',
'stream' => false,
'top_k' => 10,
'current_only' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://aigmented.io/api/v1/collections/{id}/ask"
payload := strings.NewReader("{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://aigmented.io/api/v1/collections/{id}/ask")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigmented.io/api/v1/collections/{id}/ask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}"
response = http.request(request)
puts response.read_body{
"answer": "<string>",
"sources": [
{
"document_id": "<string>",
"file_name": "<string>",
"page": 123,
"chunk_index": 123,
"score": 123,
"content_preview": "<string>"
}
],
"model": "<string>",
"tokens_used": {
"llm_prompt": 123,
"llm_completion": 123,
"embedding": 123,
"model_id": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "Token limit exceeded",
"remaining": 123,
"reason": "<string>"
}{
"error": "<string>"
}Ask a question (RAG)
Retrieves relevant knowledge chunks from the collection and uses an LLM to generate a grounded answer. Supports both synchronous JSON responses and streaming via SSE (stream: true). Token usage is tracked and counted against the team’s quota.
curl --request POST \
--url https://aigmented.io/api/v1/collections/{id}/ask \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"question": "What does the agreement say about liability?",
"model": "gpt-4o-mini",
"mode": "fast",
"stream": false,
"top_k": 10,
"current_only": true
}
'import requests
url = "https://aigmented.io/api/v1/collections/{id}/ask"
payload = {
"question": "What does the agreement say about liability?",
"model": "gpt-4o-mini",
"mode": "fast",
"stream": False,
"top_k": 10,
"current_only": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
question: 'What does the agreement say about liability?',
model: 'gpt-4o-mini',
mode: 'fast',
stream: false,
top_k: 10,
current_only: true
})
};
fetch('https://aigmented.io/api/v1/collections/{id}/ask', 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://aigmented.io/api/v1/collections/{id}/ask",
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([
'question' => 'What does the agreement say about liability?',
'model' => 'gpt-4o-mini',
'mode' => 'fast',
'stream' => false,
'top_k' => 10,
'current_only' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://aigmented.io/api/v1/collections/{id}/ask"
payload := strings.NewReader("{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://aigmented.io/api/v1/collections/{id}/ask")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aigmented.io/api/v1/collections/{id}/ask")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"What does the agreement say about liability?\",\n \"model\": \"gpt-4o-mini\",\n \"mode\": \"fast\",\n \"stream\": false,\n \"top_k\": 10,\n \"current_only\": true\n}"
response = http.request(request)
puts response.read_body{
"answer": "<string>",
"sources": [
{
"document_id": "<string>",
"file_name": "<string>",
"page": 123,
"chunk_index": 123,
"score": 123,
"content_preview": "<string>"
}
],
"model": "<string>",
"tokens_used": {
"llm_prompt": 123,
"llm_completion": 123,
"embedding": 123,
"model_id": "<string>"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "Token limit exceeded",
"remaining": 123,
"reason": "<string>"
}{
"error": "<string>"
}Authorizations
Pass your API key as a Bearer token. Example: Authorization: Bearer sk-xxxxxxxxxxxx
Path Parameters
Collection ID
Body
The question to answer
"What does the document say about data retention?"
LLM model identifier to use for answering
"gpt-4o"
Answer mode. fast uses fewer retrieved chunks for a quicker response; full retrieves more context for a thorough answer.
fast, full If true, the response is streamed as Server-Sent Events (SSE). Each event has a type field: delta (text chunk), done (final metadata), or error.
Number of knowledge chunks to retrieve before generating the answer
1 <= x <= 50Restrict retrieval to the most current document versions only
Optional prior conversation turns for multi-turn context
Show child attributes
Show child attributes
[
{
"role": "user",
"content": "Summarise the document."
},
{
"role": "assistant",
"content": "The document covers..."
}
]
Optional metadata filters to scope retrieval
Response
Answer generated successfully. When stream=false, returns a JSON body. When stream=true, returns an SSE stream (Content-Type: text/event-stream).