Upload Custom Index
curl --request POST \
--url https://api.scale.com/v1/nucleus/indexing/{dataset_id} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"embeddings_urls": [
"<string>"
],
"embedding_dimension": 123
}
'import requests
url = "https://api.scale.com/v1/nucleus/indexing/{dataset_id}"
payload = {
"embeddings_urls": ["<string>"],
"embedding_dimension": 123
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({embeddings_urls: ['<string>'], embedding_dimension: 123})
};
fetch('https://api.scale.com/v1/nucleus/indexing/{dataset_id}', 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.scale.com/v1/nucleus/indexing/{dataset_id}",
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([
'embeddings_urls' => [
'<string>'
],
'embedding_dimension' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.scale.com/v1/nucleus/indexing/{dataset_id}"
payload := strings.NewReader("{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.scale.com/v1/nucleus/indexing/{dataset_id}")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scale.com/v1/nucleus/indexing/{dataset_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}"
response = http.request(request)
puts response.read_body{
"dataset_id": "ds_by0a81gnf6gfy9hw6rpg",
"job_id": "job_c19xcf9mkws46gah00yg",
"job_last_known_status": "Running",
"job_type": "ingestTasks",
"job_creation_time": "2021-07-20T18:07:13.055Z",
"message": "Processing embeddings in the background. You can use the job_id field to asynchronously check the status of this indexing job."
}{}Indexing
Upload Custom Index
POST
/
indexing
/
{dataset_id}
Upload Custom Index
curl --request POST \
--url https://api.scale.com/v1/nucleus/indexing/{dataset_id} \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"embeddings_urls": [
"<string>"
],
"embedding_dimension": 123
}
'import requests
url = "https://api.scale.com/v1/nucleus/indexing/{dataset_id}"
payload = {
"embeddings_urls": ["<string>"],
"embedding_dimension": 123
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({embeddings_urls: ['<string>'], embedding_dimension: 123})
};
fetch('https://api.scale.com/v1/nucleus/indexing/{dataset_id}', 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.scale.com/v1/nucleus/indexing/{dataset_id}",
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([
'embeddings_urls' => [
'<string>'
],
'embedding_dimension' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.scale.com/v1/nucleus/indexing/{dataset_id}"
payload := strings.NewReader("{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.scale.com/v1/nucleus/indexing/{dataset_id}")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scale.com/v1/nucleus/indexing/{dataset_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"embeddings_urls\": [\n \"<string>\"\n ],\n \"embedding_dimension\": 123\n}"
response = http.request(request)
puts response.read_body{
"dataset_id": "ds_by0a81gnf6gfy9hw6rpg",
"job_id": "job_c19xcf9mkws46gah00yg",
"job_last_known_status": "Running",
"job_type": "ingestTasks",
"job_creation_time": "2021-07-20T18:07:13.055Z",
"message": "Processing embeddings in the background. You can use the job_id field to asynchronously check the status of this indexing job."
}{}Click for Python SDK
Dataset.create_custom_index(
embeddings_urls: List[str],
embedding_dim: int
) -> AsyncJob
Formatting an Embedding File
The files must be in JSON format, and each file should contain no more than 5,000 embedding vectors. The JSON objects are expected to have the following format: each key is a stringreference_id uniquely identifying a DatasetItem, and each value is a list of floats. Numpy arrays must be converted to lists in order to serialize the JSON file.
The vectors must all have the same dimension/length.
The entries of the JSON object must be exhaustive, meaning that every Dataset Item in the dataset is represented in the keys. This implies that if your Dataset contains 5,000 images, the JSON object represented across the embedding files are also expected to have length 5,000.Authorizations
Body
application/json
Array of URLs each pointing to a JSON embeddings file. Each JSON provides a mapping from reference_id to the corresponding embedding vector. See Formatting an Embedding File.
Response
200