Build a SIP
curl --request POST \
--url https://api.tensorpro.ai/api/v1/sip/build \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "Who manages the website project?",
"session_id": "chat-42",
"include_global": false,
"project_id": "<string>"
}
'import requests
url = "https://api.tensorpro.ai/api/v1/sip/build"
payload = {
"query": "Who manages the website project?",
"session_id": "chat-42",
"include_global": False,
"project_id": "<string>"
}
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({
query: 'Who manages the website project?',
session_id: 'chat-42',
include_global: false,
project_id: '<string>'
})
};
fetch('https://api.tensorpro.ai/api/v1/sip/build', 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.tensorpro.ai/api/v1/sip/build",
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' => 'Who manages the website project?',
'session_id' => 'chat-42',
'include_global' => false,
'project_id' => '<string>'
]),
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://api.tensorpro.ai/api/v1/sip/build"
payload := strings.NewReader("{\n \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\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://api.tensorpro.ai/api/v1/sip/build")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/sip/build")
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 \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"sip": "[MEMORY CONTEXT]\n- Sara manages the website project. (USER_STATED)\n- The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END MEMORY CONTEXT]",
"records_used": 2,
"grounded": false,
"abstain": false,
"citations": []
}
{
"sip": "[GROUNDED MEMORY]\n[1] The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END GROUNDED MEMORY]",
"records_used": 1,
"grounded": true,
"abstain": false,
"citations": [
{
"index": 1,
"record_id": "9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e",
"summary": "The website relaunch is planned for March.",
"provenance": "DOCUMENT_VERIFIED",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e",
"source_title": "launch-plan.pdf",
"supporting_record_ids": [
"9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e"
]
}
]
}
Retrieve
Build a SIP
Get the memory context for the user’s next message. Call it before each model call and put sip in your model’s prompt. EDN selects the memories most relevant to query; replaced, deleted and unconfirmed AI memories are never included. With project_id, the SIP uses the project’s documents and numbers each item for citations. Counts against your daily SIP quota.
POST
/
api
/
v1
/
sip
/
build
Build a SIP
curl --request POST \
--url https://api.tensorpro.ai/api/v1/sip/build \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "Who manages the website project?",
"session_id": "chat-42",
"include_global": false,
"project_id": "<string>"
}
'import requests
url = "https://api.tensorpro.ai/api/v1/sip/build"
payload = {
"query": "Who manages the website project?",
"session_id": "chat-42",
"include_global": False,
"project_id": "<string>"
}
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({
query: 'Who manages the website project?',
session_id: 'chat-42',
include_global: false,
project_id: '<string>'
})
};
fetch('https://api.tensorpro.ai/api/v1/sip/build', 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.tensorpro.ai/api/v1/sip/build",
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' => 'Who manages the website project?',
'session_id' => 'chat-42',
'include_global' => false,
'project_id' => '<string>'
]),
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://api.tensorpro.ai/api/v1/sip/build"
payload := strings.NewReader("{\n \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\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://api.tensorpro.ai/api/v1/sip/build")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tensorpro.ai/api/v1/sip/build")
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 \"query\": \"Who manages the website project?\",\n \"session_id\": \"chat-42\",\n \"include_global\": false,\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"sip": "[MEMORY CONTEXT]\n- Sara manages the website project. (USER_STATED)\n- The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END MEMORY CONTEXT]",
"records_used": 2,
"grounded": false,
"abstain": false,
"citations": []
}
{
"sip": "[GROUNDED MEMORY]\n[1] The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END GROUNDED MEMORY]",
"records_used": 1,
"grounded": true,
"abstain": false,
"citations": [
{
"index": 1,
"record_id": "9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e",
"summary": "The website relaunch is planned for March.",
"provenance": "DOCUMENT_VERIFIED",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e",
"source_title": "launch-plan.pdf",
"supporting_record_ids": [
"9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e"
]
}
]
}
Use this endpoint before each model call to get the memory that matters for the user’s message. EDN returns it as a SIP (Session Initialisation Package): a block of text you put in your model’s system prompt.
A typical chat turn uses two calls: this one before your model replies, and Save a conversation turn after.
See Error handling.
What EDN does
- Finds the memories most relevant to
query. - Leaves out unconfirmed AI memories, replaced memories and deleted memories.
- With
project_id, uses the project’s memory and numbers each item[1],[2]and so on, for citations. - Returns the SIP text, ready to put in your prompt.
Required headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | Your EDN API key. Create keys in the Console. See Authentication |
Content-Type | application/json | The request body is JSON |
Request
| Field | Type | Required | Description |
|---|---|---|---|
query | string | Yes | What the user just asked. EDN selects the memories most relevant to it. Must not be empty |
session_id | string | Yes | Identifier for the conversation. Use the same value for every turn in the same conversation. If EDN hasn’t seen this value before, it creates a new session. Format: 1 to 128 characters, using only letters, digits, period (.), underscore (_), colon (:) and hyphen (-). EDN uses recent user messages stored in this session to help with short follow-up questions |
project_id | string | No | Build from this project’s memory instead of general memory. Must be one of your projects |
include_global | boolean | No | With project_id, also use your general memory. Ignored without project_id. Default: false |
curl -X POST "https://api.tensorpro.ai/api/v1/sip/build" \
-H "Authorization: Bearer $EDN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "Who manages the website project?",
"session_id": "chat-42"
}'
import os
import requests
resp = requests.post(
"https://api.tensorpro.ai/api/v1/sip/build",
headers={"Authorization": f"Bearer {os.environ['EDN_API_KEY']}"},
json={
"query": "Who manages the website project?",
"session_id": "chat-42"
},
)
resp.raise_for_status()
print(resp.json())
const resp = await fetch("https://api.tensorpro.ai/api/v1/sip/build", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EDN_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"query": "Who manages the website project?",
"session_id": "chat-42"
}),
});
console.log(await resp.json());
Response
200 OK
{
"sip": "[MEMORY CONTEXT]\n- Sara manages the website project. (USER_STATED)\n- The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END MEMORY CONTEXT]",
"records_used": 2,
"grounded": false,
"abstain": false,
"citations": []
}
| Field | Type | Description |
|---|---|---|
sip | string | The memory context to put in your model’s system prompt |
records_used | integer | How many memories the SIP contains |
grounded | boolean | true when you sent project_id. The SIP then tells the model to answer only from the project’s sources |
abstain | boolean | true when a project build found nothing relevant. The SIP then tells the model to say it doesn’t know |
citations | array | One entry per numbered item in a project SIP. Empty without project_id |
citations[].index | integer | The number n of the [n] marker in the SIP |
citations[].record_id | string | Identifier for the memory that best represents this source |
citations[].summary | string | What that memory says |
citations[].provenance | string | Where the memory came from |
citations[].source_id | string or null | The project document it came from, or null |
citations[].source_title | string or null | That document’s title, or null |
citations[].supporting_record_ids | array of string | Every memory from this source that was used |
Important behavior
-
Without
project_id, EDN builds from your general memory. -
With
project_id, EDN builds only from that project (plus general memory ifinclude_globalistrue). Your model can cite items as[n], andcitationstells you the source behind each number. -
abstain: truemeans the project has nothing relevant. The SIP tells the model to say so instead of guessing. - Each call counts toward your daily limit on building SIPs.
Errors
| Status | Code | When |
|---|---|---|
401 | UNAUTHORIZED | The API key is missing, invalid or revoked |
404 | NOT_FOUND | project_id isn’t one of your projects |
422 | VALIDATION_ERROR | query or session_id is missing or empty, or session_id has invalid characters |
429 | RATE_LIMITED | Per-minute or daily limit on building SIPs reached. Retry after Retry-After seconds |
500 | INTERNAL_ERROR | Something failed on EDN’s side. Retry later |
{
"sip": "[MEMORY CONTEXT]\n- Sara manages the website project. (USER_STATED)\n- The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END MEMORY CONTEXT]",
"records_used": 2,
"grounded": false,
"abstain": false,
"citations": []
}
{
"sip": "[GROUNDED MEMORY]\n[1] The website relaunch is planned for March. (DOCUMENT_VERIFIED)\n[END GROUNDED MEMORY]",
"records_used": 1,
"grounded": true,
"abstain": false,
"citations": [
{
"index": 1,
"record_id": "9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e",
"summary": "The website relaunch is planned for March.",
"provenance": "DOCUMENT_VERIFIED",
"source_id": "9a1c3e5f-7b2d-4f6a-8c0e-3b5d7f9a1c2e",
"source_title": "launch-plan.pdf",
"supporting_record_ids": [
"9c2e4a6b-8d0f-4e1a-b3c5-7d9f1a3b5c7e"
]
}
]
}
Authorizations
Body
application/json
Response
Successful Response
