Create engine embeddings
Create embedding vectors for input text using specified engine
Request
POST /engines/{model}/embeddings
Path Parameters
| Parameter | Type | Required | Description |
|---|
| model | string | Yes | Engine model name |
Request Body
| Field | Type | Required | Description |
|---|
| input | string | Yes | Input text to embed, encoded as a string or array of tokens. |
| encoding_format | string (float, base64) | No | The format to return the embeddings in. Can be either “float” or “base64”. |
| dimensions | integer | No | The number of dimensions the resulting output embeddings should have. |
| user | string | No | A 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
| Field | Type | Required | Description |
|---|
| object | string | Yes | The object type, which is always “list”. |
| data | Array<EmbeddingObject> | Yes | The list of embeddings generated by the model. |
| model | string | Yes | The name of the model used to generate the embedding. |
| usage | object | Yes | The 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
| Field | Type | Required | Description |
|---|
| input | string | Yes | Input text to embed, encoded as a string or array of tokens. |
| encoding_format | string (float, base64) | No | The format to return the embeddings in. Can be either “float” or “base64”. |
| dimensions | integer | No | The number of dimensions the resulting output embeddings should have. |
| user | string | No | A unique identifier representing your end-user. |
EmbeddingResponse
| Field | Type | Required | Description |
|---|
| object | string | Yes | The object type, which is always “list”. |
| data | Array<EmbeddingObject> | Yes | The list of embeddings generated by the model. |
| model | string | Yes | The name of the model used to generate the embedding. |
| usage | object | Yes | The usage information for the request. |
EmbeddingObject
| Field | Type | Required | Description |
|---|
| object | string | Yes | The object type, which is always “embedding”. |
| embedding | Array | Yes | The embedding vector, which is a list of floats. The length of vector depends on the model. |
| index | integer | Yes | The index of the embedding in the list of embeddings. |
Related APIs
- 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