Search for embeddings
curl --request POST \
--url https://api.example.com/api/v1/embeddings/{indexName}/search \
--header 'Content-Type: application/json' \
--header 'X-Eigen-API-Key: <api-key>' \
--data '
{
"queryVector": [
123
],
"k": 123
}
'import requests
url = "https://api.example.com/api/v1/embeddings/{indexName}/search"
payload = {
"queryVector": [123],
"k": 123
}
headers = {
"X-Eigen-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Eigen-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({queryVector: [123], k: 123})
};
fetch('https://api.example.com/api/v1/embeddings/{indexName}/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.example.com/api/v1/embeddings/{indexName}/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([
'queryVector' => [
123
],
'k' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Eigen-API-Key: <api-key>"
],
]);
$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.example.com/api/v1/embeddings/{indexName}/search"
payload := strings.NewReader("{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Eigen-API-Key", "<api-key>")
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.example.com/api/v1/embeddings/{indexName}/search")
.header("X-Eigen-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/embeddings/{indexName}/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Eigen-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Similarity search successfully performed.",
"data": {
"nearest_neighbors": {
"21": {
"metadata": {
"foo3": "bar4"
},
"rank": 2
},
"45": {
"metadata": {
"foo7": "bar8"
},
"rank": 4
},
"54": {
"metadata": {
"foo": "bar"
},
"rank": 0
},
"63": {
"metadata": {
"foo5": "bar6",
"hello": "world"
},
"rank": 3
},
"98": {
"metadata": {
"foo1": "bar2",
"bar": "baz"
},
"rank": 1
}
}
}
}{
"status": 400,
"message": "An error occured during the similarity search.",
"error": {
"code": "SIMILARITY_SEARCH_ERROR",
"description": "detailed description of the error..."
}
}API Reference
Search for embeddings
Search for embeddings using vector similarity search
POST
/
api
/
v1
/
embeddings
/
{indexName}
/
search
Search for embeddings
curl --request POST \
--url https://api.example.com/api/v1/embeddings/{indexName}/search \
--header 'Content-Type: application/json' \
--header 'X-Eigen-API-Key: <api-key>' \
--data '
{
"queryVector": [
123
],
"k": 123
}
'import requests
url = "https://api.example.com/api/v1/embeddings/{indexName}/search"
payload = {
"queryVector": [123],
"k": 123
}
headers = {
"X-Eigen-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Eigen-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({queryVector: [123], k: 123})
};
fetch('https://api.example.com/api/v1/embeddings/{indexName}/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.example.com/api/v1/embeddings/{indexName}/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([
'queryVector' => [
123
],
'k' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Eigen-API-Key: <api-key>"
],
]);
$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.example.com/api/v1/embeddings/{indexName}/search"
payload := strings.NewReader("{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Eigen-API-Key", "<api-key>")
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.example.com/api/v1/embeddings/{indexName}/search")
.header("X-Eigen-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/embeddings/{indexName}/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Eigen-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"queryVector\": [\n 123\n ],\n \"k\": 123\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"message": "Similarity search successfully performed.",
"data": {
"nearest_neighbors": {
"21": {
"metadata": {
"foo3": "bar4"
},
"rank": 2
},
"45": {
"metadata": {
"foo7": "bar8"
},
"rank": 4
},
"54": {
"metadata": {
"foo": "bar"
},
"rank": 0
},
"63": {
"metadata": {
"foo5": "bar6",
"hello": "world"
},
"rank": 3
},
"98": {
"metadata": {
"foo1": "bar2",
"bar": "baz"
},
"rank": 1
}
}
}
}{
"status": 400,
"message": "An error occured during the similarity search.",
"error": {
"code": "SIMILARITY_SEARCH_ERROR",
"description": "detailed description of the error..."
}
}Authorizations
Path Parameters
Name of the index
Body
application/json
Response
The k-nearest embeddings returned in an array along with their rank (0 is nearest).
⌘I