Read Segment Context
curl --request GET \
--url https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context', 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://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "6f1c0b2e-1a2b-4c3d-8e9f-0a1b2c3d4e5f.rec_1",
"text": "# Q2 roadmap\nThe Q2 roadmap covers launch dates.",
"prev": null,
"next": "chk_next",
"tokenBudget": {
"returnedTokens": 18
},
"tokenizer": "o200k_base"
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}Context
Read Segment Context
Read the text before and after a passage returned by search.
GET
/
api
/
context
/
projects
/
{projectId}
/
segments
/
{pointer}
/
context
Read Segment Context
curl --request GET \
--url https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context \
--header 'Authorization: Bearer <token>'import requests
url = "https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context', 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://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://agentos.useparagon.com/api/context/projects/{projectId}/segments/{pointer}/context")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "6f1c0b2e-1a2b-4c3d-8e9f-0a1b2c3d4e5f.rec_1",
"text": "# Q2 roadmap\nThe Q2 roadmap covers launch dates.",
"prev": null,
"next": "chk_next",
"tokenBudget": {
"returnedTokens": 18
},
"tokenizer": "o200k_base"
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"hint": "<string>",
"retryable": true,
"requestId": "<string>",
"retryAfterMs": 123,
"details": [
{
"field": "<string>",
"issue": "<string>"
}
]
}
}Use this endpoint when a search result looks relevant and you need more of the surrounding text. Pass the
pointer from a search result passage.
Use direction to choose which side to read: around (default), before, or after. Use maxTokens to limit the size of the response. It defaults to 2000 and cannot exceed 32000. At least one chunk is always returned, even if that chunk alone is larger than maxTokens.
The response includes prev and next pointers for the neighboring chunks, or null at the start or end of the document. Pass either one back to this endpoint to keep reading in that direction.
If the pointer doesn’t exist or the user doesn’t have access to it, the request returns a 404 with the error code RESOURCE_NOT_FOUND. Run a new search to get a fresh pointer.
const response = await fetch(
`https://agentos.useparagon.com/api/context/projects/${projectId}/segments/${pointer}/context?direction=around&maxTokens=2000&identity=${encodeURIComponent("user@example.com")}`,
{
headers: { Authorization: `Bearer ${paragonUserToken}` },
},
);
Authorizations
Your Paragon User Token (JWT), which you can generate using your project's signing keys.
Path Parameters
Query Parameters
Response
The text around the pointer.