Search a namespace
Complete retrieval pipeline for RAG with semantic search, filtering, and reranking
import { Agentset } from "agentset";
const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');
const results = await ns.search("What is machine learning?", {
topK: 20,
rerank: true,
rerankLimit: 10,
});
console.log(results);from agentset import Agentset
with Agentset(
namespace_id="ns_123",
x_tenant_id="<id>",
token="AGENTSET_API_KEY",
) as a_client:
res = a_client.search.execute(query="<value>", top_k=10, rerank=True, rerank_model="zeroentropy:zerank-2", include_relationships=False, include_metadata=True, mode="semantic")
# Handle response
print(res)curl --request POST \
--url https://api.agentset.ai/v1/namespace/{namespaceId}/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"topK": 10,
"rerank": true,
"rerankLimit": 50.5,
"rerankModel": "zeroentropy:zerank-2",
"filter": {},
"minScore": 0.5,
"includeRelationships": false,
"includeMetadata": true,
"keywordFilter": "<string>",
"mode": "semantic"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
topK: 10,
rerank: true,
rerankLimit: 50.5,
rerankModel: 'zeroentropy:zerank-2',
filter: {},
minScore: 0.5,
includeRelationships: false,
includeMetadata: true,
keywordFilter: '<string>',
mode: 'semantic'
})
};
fetch('https://api.agentset.ai/v1/namespace/{namespaceId}/search', 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.agentset.ai/v1/namespace/{namespaceId}/search",
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>',
'topK' => 10,
'rerank' => true,
'rerankLimit' => 50.5,
'rerankModel' => 'zeroentropy:zerank-2',
'filter' => [
],
'minScore' => 0.5,
'includeRelationships' => false,
'includeMetadata' => true,
'keywordFilter' => '<string>',
'mode' => 'semantic'
]),
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.agentset.ai/v1/namespace/{namespaceId}/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\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.agentset.ai/v1/namespace/{namespaceId}/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentset.ai/v1/namespace/{namespaceId}/search")
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\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"score": 0.5,
"text": "<string>",
"relationships": {},
"metadata": {}
}
]
}{
"success": false,
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#bad-request"
}
}{
"success": false,
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unauthorized"
}
}{
"success": false,
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#forbidden"
}
}{
"success": false,
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#not-found"
}
}{
"success": false,
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#conflict"
}
}{
"success": false,
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#invite-expired"
}
}{
"success": false,
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unprocessable-entity"
}
}{
"success": false,
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#rate-limit_exceeded"
}
}{
"success": false,
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#internal-server_error"
}
}Authorizations
Default authentication mechanism
Headers
Optional tenant id to use for the request. If not provided, the namespace will be used directly. Must be alphanumeric and up to 64 characters.
^[A-Za-z0-9]{1,64}$Path Parameters
The id of the namespace (prefixed with ns_)
"ns_123"
Body
The query to search for.
The number of results to fetch from the vector store. Defaults to 10.
1 <= x <= 100Whether to rerank the results. Defaults to true.
The number of results to return after reranking. Defaults to topK.
1 <= x <= 100The reranking model to use.
cohere:rerank-v4.0-pro, cohere:rerank-v4.0-fast, cohere:rerank-v3.5, cohere:rerank-english-v3.0, cohere:rerank-multilingual-v3.0, zeroentropy:zerank-2, zeroentropy:zerank-1, zeroentropy:zerank-1-small A filter to apply to the results.
Show child attributes
Show child attributes
The minimum score to return.
0 <= x <= 1Whether to include relationships in the results. Defaults to false.
Whether to include metadata in the results. Defaults to true.
semantic, keyword import { Agentset } from "agentset";
const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');
const results = await ns.search("What is machine learning?", {
topK: 20,
rerank: true,
rerankLimit: 10,
});
console.log(results);from agentset import Agentset
with Agentset(
namespace_id="ns_123",
x_tenant_id="<id>",
token="AGENTSET_API_KEY",
) as a_client:
res = a_client.search.execute(query="<value>", top_k=10, rerank=True, rerank_model="zeroentropy:zerank-2", include_relationships=False, include_metadata=True, mode="semantic")
# Handle response
print(res)curl --request POST \
--url https://api.agentset.ai/v1/namespace/{namespaceId}/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"topK": 10,
"rerank": true,
"rerankLimit": 50.5,
"rerankModel": "zeroentropy:zerank-2",
"filter": {},
"minScore": 0.5,
"includeRelationships": false,
"includeMetadata": true,
"keywordFilter": "<string>",
"mode": "semantic"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
topK: 10,
rerank: true,
rerankLimit: 50.5,
rerankModel: 'zeroentropy:zerank-2',
filter: {},
minScore: 0.5,
includeRelationships: false,
includeMetadata: true,
keywordFilter: '<string>',
mode: 'semantic'
})
};
fetch('https://api.agentset.ai/v1/namespace/{namespaceId}/search', 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.agentset.ai/v1/namespace/{namespaceId}/search",
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>',
'topK' => 10,
'rerank' => true,
'rerankLimit' => 50.5,
'rerankModel' => 'zeroentropy:zerank-2',
'filter' => [
],
'minScore' => 0.5,
'includeRelationships' => false,
'includeMetadata' => true,
'keywordFilter' => '<string>',
'mode' => 'semantic'
]),
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.agentset.ai/v1/namespace/{namespaceId}/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\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.agentset.ai/v1/namespace/{namespaceId}/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.agentset.ai/v1/namespace/{namespaceId}/search")
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\": \"<string>\",\n \"topK\": 10,\n \"rerank\": true,\n \"rerankLimit\": 50.5,\n \"rerankModel\": \"zeroentropy:zerank-2\",\n \"filter\": {},\n \"minScore\": 0.5,\n \"includeRelationships\": false,\n \"includeMetadata\": true,\n \"keywordFilter\": \"<string>\",\n \"mode\": \"semantic\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": [
{
"id": "<string>",
"score": 0.5,
"text": "<string>",
"relationships": {},
"metadata": {}
}
]
}{
"success": false,
"error": {
"code": "bad_request",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#bad-request"
}
}{
"success": false,
"error": {
"code": "unauthorized",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unauthorized"
}
}{
"success": false,
"error": {
"code": "forbidden",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#forbidden"
}
}{
"success": false,
"error": {
"code": "not_found",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#not-found"
}
}{
"success": false,
"error": {
"code": "conflict",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#conflict"
}
}{
"success": false,
"error": {
"code": "invite_expired",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#invite-expired"
}
}{
"success": false,
"error": {
"code": "unprocessable_entity",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#unprocessable-entity"
}
}{
"success": false,
"error": {
"code": "rate_limit_exceeded",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#rate-limit_exceeded"
}
}{
"success": false,
"error": {
"code": "internal_server_error",
"message": "The requested resource was not found.",
"doc_url": "https://docs.agentset.ai/api-reference/errors#internal-server_error"
}
}