Skip to main content
POST
/
models
/
embed
Embed
curl --request POST \
  --url https://api.zeroentropy.dev/v1/models/embed \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "input": "<string>",
  "dimensions": 123,
  "encoding_format": "float"
}
'
import requests

url = "https://api.zeroentropy.dev/v1/models/embed"

payload = {
"model": "<string>",
"input": "<string>",
"dimensions": 123,
"encoding_format": "float"
}
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({
model: '<string>',
input: '<string>',
dimensions: 123,
encoding_format: 'float'
})
};

fetch('https://api.zeroentropy.dev/v1/models/embed', 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.zeroentropy.dev/v1/models/embed",
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([
'model' => '<string>',
'input' => '<string>',
'dimensions' => 123,
'encoding_format' => 'float'
]),
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.zeroentropy.dev/v1/models/embed"

payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"dimensions\": 123,\n \"encoding_format\": \"float\"\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.zeroentropy.dev/v1/models/embed")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"dimensions\": 123,\n \"encoding_format\": \"float\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.zeroentropy.dev/v1/models/embed")

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 \"model\": \"<string>\",\n \"input\": \"<string>\",\n \"dimensions\": 123,\n \"encoding_format\": \"float\"\n}"

response = http.request(request)
puts response.read_body
{
  "results": [
    {
      "embedding": [
        123
      ]
    }
  ],
  "usage": {
    "total_bytes": 123,
    "total_tokens": 123
  }
}
{
"detail": "Description of Error"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

The Authorization header must be provided in the format Bearer <your-api-key>.

You can get your API Key at the Dashboard!

Body

application/json
model
string
required

The model ID to use for embedding. Options are: ["zembed-1"]

input_type
enum<string>
required

The input type. For retrieval tasks, either query or document.

Available options:
query,
document
input
required

The string, or list of strings, to embed.

dimensions
integer | null

The output dimensionality of the embedding model. For zembed-1, the available options are: [2560, 1280, 640, 320, 160, 80, 40].

encoding_format
enum<string>
default:float

The output format of the embedding. If float, an array of floats will be returned for each embeddings. If base64, a f32 little endian byte array will be returned, encoded as a base64 string. base64 is significantly more efficient than float. The default is float.

Available options:
float,
base64
latency
enum<string> | null

Whether the call will be inferenced "fast" or "slow". RateLimits for slow API calls are orders of magnitude higher, but you can expect 2-20 second latency. Fast inferences are guaranteed subsecond, but rate limits are lower. If not specified, first a "fast" call will be attempted, but if you have exceeded your fast rate limit, then a slow call will be executed. If explicitly set to "fast", then 429 will be returned if it cannot be executed fast.

Available options:
fast,
slow

Response

Successful Response

results
EmbedResult · object[]
required

The list of embedding results.

usage
EmbedUsage · object
required

Statistics regarding the tokens used by the request.