Skip to content

engine-embeddings

Create embedding vectors for input text using specified engine

POST /engines/{model}/embeddings
ParameterTypeRequiredDescription
modelstringYesEngine model name
FieldTypeRequiredDescription
inputstringYesInput text to embed, encoded as a string or array of tokens.
encoding_formatstring (float, base64)NoThe format to return the embeddings in. Can be either “float” or “base64”.
dimensionsintegerNoThe number of dimensions the resulting output embeddings should have.
userstringNoA unique identifier representing your end-user.
{
"input": "The quick brown fox jumps over the lazy dog"
}
{
"input": [
"First text",
"Second text"
],
"encoding_format": "float"
}
{
"input": [
"Customer feedback: great service!"
],
"encoding_format": "base64",
"dimensions": 512
}

Successful response

FieldTypeRequiredDescription
objectstringYesThe object type, which is always “list”.
dataArray<EmbeddingObject>YesThe list of embeddings generated by the model.
modelstringYesThe name of the model used to generate the embedding.
usageobjectYesThe usage information for the request.
const response = await fetch('https://api.r9s.ai/v1/engines/{model}/embeddings', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"input": "The quick brown fox jumps over the lazy dog"
})
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.r9s.ai/v1/engines/{model}/embeddings"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.post(url, json={
"input": "The quick brown fox jumps over the lazy dog"
}, headers=headers)
data = response.json()
print(data)
Terminal window
curl -X POST "https://api.r9s.ai/v1/engines/{model}/embeddings" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"The quick brown fox jumps over the lazy dog"}'
FieldTypeRequiredDescription
inputstringYesInput text to embed, encoded as a string or array of tokens.
encoding_formatstring (float, base64)NoThe format to return the embeddings in. Can be either “float” or “base64”.
dimensionsintegerNoThe number of dimensions the resulting output embeddings should have.
userstringNoA unique identifier representing your end-user.
FieldTypeRequiredDescription
objectstringYesThe object type, which is always “list”.
dataArray<EmbeddingObject>YesThe list of embeddings generated by the model.
modelstringYesThe name of the model used to generate the embedding.
usageobjectYesThe usage information for the request.
FieldTypeRequiredDescription
objectstringYesThe object type, which is always “embedding”.
embeddingArrayYesThe embedding vector, which is a list of floats. The length of vector depends on the model.
indexintegerYesThe index of the embedding in the list of embeddings.
  • API Overview - Learn about authentication and basic information
  • models - View models related APIs
  • chat - View chat related APIs
  • responses - View responses related APIs
  • messages - View messages related APIs
  • completions - View completions related APIs
  • edits - View edits related APIs
  • images - View images related APIs
  • embeddings - View embeddings related APIs
  • moderations - View moderations related APIs
  • audio - View audio related APIs
  • search - View search related APIs
  • proxy - View proxy related APIs