Skip to content

Embeddings API

An embedding is a vector representation of a piece of data. Text embeddings are often used to capture the semantic meaning of a piece of text, where the distance between text embedding vectors is used to measure their relatedness.

Create Embeddings

Endpoint to create an embedding vector representation of a text input.

POST https://api.relax.ai/v1/embeddings

Example Request

Terminal window
curl https://api.relax.ai/v1/embeddings \
-H "Authorization: Bearer $RELAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "The capital city of the UK is London",
"model": "Mistral-7b-embedding",
"encoding_format": "float"
}'

Response

Returns an embedding object, which contains the embedding vector of the text input.

Embedding Response
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
-0.002363205,
0.005371202,
...
],
"index": 0
}
],
"model": "Mistral-7b-embedding",
"usage": {
"prompt_tokens": 10,
"completion_tokens": 0,
"total_tokens": 10,
"prompt_tokens_details": null,
"completion_tokens_details": null
}
}

Request Body

The following parameters can be included in the request body:


Create Embeddings Request Body

model

  • Type: string
  • Required: Yes
  • Description: The model name to use for generating the completion.

input

  • Type: string or array
  • Required: Yes
  • Description: Input text to embed. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max token length of the model (4096 tokens for the Mistral-7b-embedding model) and cannot be an empty string.

encoding_format

  • Type: string
  • Required: No
  • Description: Embeddings vector format. Either float or base64.