Skip to content

engine-embeddings

Create engine embeddings

Create embedding vectors for input text using specified engine

Request

POST /engines/{model}/embeddings

Path Parameters

ParameterTypeRequiredDescription
modelstringYesEngine model name

Request Body

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.

Request Examples

Create embedding using engine

{
  "input": "The quick brown fox jumps over the lazy dog"
}

Batch create embeddings

{
  "input": [
    "First text",
    "Second text"
  ],
  "encoding_format": "float"
}

Specify dimensions and encoding format

{
  "input": [
    "Customer feedback: great service!"
  ],
  "encoding_format": "base64",
  "dimensions": 512
}

Successful response

Response Schema

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.

Code Examples

JavaScript (Fetch)

const response = await fetch('https://api.uuroute.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);

Python (requests)

import requests

url = "https://api.uuroute.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)

cURL

curl -X POST "https://api.uuroute.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"}'

Schema Reference

EngineEmbeddingRequest

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.

EmbeddingResponse

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.

EmbeddingObject

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