JavaScript
import SambaNova from 'sambanova';
const client = new SambaNova({
apiKey: process.env['SAMBANOVA_API_KEY'], // This is the default and can be omitted
});
const embeddingsResponse = await client.embeddings.create({
input: ['text to embed number 1', 'text to embed number 2'],
model: 'E5-Mistral-7B-Instruct',
});
console.log(embeddingsResponse.data);import os
from sambanova import SambaNova
client = SambaNova(
api_key=os.environ.get("SAMBANOVA_API_KEY"), # This is the default and can be omitted
)
embeddings_response = client.embeddings.create(
input=["text to embed number 1", "text to embed number 2"],
model="E5-Mistral-7B-Instruct",
)
print(embeddings_response.data)curl --request POST \
--url https://api.sambanova.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"text to embed number 1",
"text to embed number 2"
],
"model": "E5-Mistral-7B-Instruct"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sambanova.ai/v1/embeddings",
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([
'input' => [
'text to embed number 1',
'text to embed number 2'
],
'model' => 'E5-Mistral-7B-Instruct'
]),
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.sambanova.ai/v1/embeddings"
payload := strings.NewReader("{\n \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\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.sambanova.ai/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sambanova.ai/v1/embeddings")
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 \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"index": 0,
"object": "embedding",
"embedding": [
0.024864232167601585,
-0.01452154759317636,
0.008880083449184895
]
},
{
"index": 1,
"object": "embedding",
"embedding": [
0.010919672437012196,
0.0016351072117686272,
0.008019134402275085
]
}
],
"model": "E5-Mistral-7B-Instruct",
"object": "list",
"usage": {
"prompt_tokens": 716,
"total_tokens": 716
}
}Embeddings
Create embeddings
POST
/
embeddings
JavaScript
import SambaNova from 'sambanova';
const client = new SambaNova({
apiKey: process.env['SAMBANOVA_API_KEY'], // This is the default and can be omitted
});
const embeddingsResponse = await client.embeddings.create({
input: ['text to embed number 1', 'text to embed number 2'],
model: 'E5-Mistral-7B-Instruct',
});
console.log(embeddingsResponse.data);import os
from sambanova import SambaNova
client = SambaNova(
api_key=os.environ.get("SAMBANOVA_API_KEY"), # This is the default and can be omitted
)
embeddings_response = client.embeddings.create(
input=["text to embed number 1", "text to embed number 2"],
model="E5-Mistral-7B-Instruct",
)
print(embeddings_response.data)curl --request POST \
--url https://api.sambanova.ai/v1/embeddings \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": [
"text to embed number 1",
"text to embed number 2"
],
"model": "E5-Mistral-7B-Instruct"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sambanova.ai/v1/embeddings",
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([
'input' => [
'text to embed number 1',
'text to embed number 2'
],
'model' => 'E5-Mistral-7B-Instruct'
]),
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.sambanova.ai/v1/embeddings"
payload := strings.NewReader("{\n \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\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.sambanova.ai/v1/embeddings")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sambanova.ai/v1/embeddings")
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 \"input\": [\n \"text to embed number 1\",\n \"text to embed number 2\"\n ],\n \"model\": \"E5-Mistral-7B-Instruct\"\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"index": 0,
"object": "embedding",
"embedding": [
0.024864232167601585,
-0.01452154759317636,
0.008880083449184895
]
},
{
"index": 1,
"object": "embedding",
"embedding": [
0.010919672437012196,
0.0016351072117686272,
0.008019134402275085
]
}
],
"model": "E5-Mistral-7B-Instruct",
"object": "list",
"usage": {
"prompt_tokens": 716,
"total_tokens": 716
}
}Authorizations
SambaNova API key, sent as a bearer token in the Authorization header (Authorization: Bearer <key>). Default authentication scheme used by the SambaNova SDK across every OpenAI compatible endpoint.
Body
application/json
Texts to embed and parameters
embeddings request object
The string that will be turned into an embedding.
The format to return the embeddings in. Can be either float or base64. Omitted from the request when not set.
Available options:
float, base64 Response
Successful response
Embeddings response returned by the model
The object type, which is always "list".
Available options:
list The name of the model used to generate the embedding.
Usage metrics for the completion, embeddings,transcription or translation request
Show child attributes
Show child attributes
Examples:
{
"completion_tokens": 260,
"completion_tokens_after_first_per_sec": 422.79282728043336,
"completion_tokens_after_first_per_sec_first_ten": 423.6108998455803,
"completion_tokens_after_first_per_sec_graph": 423.6108998455803,
"completion_tokens_per_sec": 314.53312043711406,
"completion_tokens_details": { "reasoning_tokens": 55 },
"end_time": 1776189309.02061,
"is_last_response": true,
"prompt_tokens": 90,
"prompt_tokens_details": { "cached_tokens": 0 },
"start_time": 1776189308.193988,
"stop_reason": "stop",
"time_to_first_token": 0.21402883529663086,
"time_to_first_token_graph": 0.2102978229522705,
"total_latency": 0.8266220092773438,
"total_tokens": 350,
"total_tokens_per_sec": 423.40996981919204
}
{ "prompt_tokens": 43, "total_tokens": 393 }
The list of embeddings generated by the model.
Show child attributes
Show child attributes
⌘I

