POST
/
embeddings
/
text
Generate Text Embedding
curl --request POST \
  --url https://mavi-backend.memories.ai/serve/api/v2/embeddings/text \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "input": [
    "Sample text to embed",
    "Another text string"
  ],
  "model": "gemini-embedding-001",
  "dimensionality": 512
}
'
{
  "code": "0000",
  "msg": "success",
  "data": {
    "embedding": [
      0.0234375,
      -0.0156250,
      0.0390625,
      0.0078125,
      "... (continues for dimensionality length)"
    ]
  },
  "success": true,
  "failed": false
}
This endpoint generates vector embeddings for text strings. You can embed single or multiple text inputs in one request, and optionally specify the output dimensionality.

Code Examples

const response = await fetch('/embeddings/text', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'sk-8483027fe3abfe535f6ae01a9979b4f7'
  },
  body: JSON.stringify({
    input: ['Sample text to embed', 'Another text string'],
    model: 'gemini-embedding-001',
    dimensionality: 512
  })
});

const data = await response.json();
console.log(data);

Request Body

FieldTypeRequiredDescription
inputarray[string]YesList of text strings to embed (can be a single string or multiple strings)
modelstringYesEmbedding model name
dimensionalityintegerNoOutput embedding dimension size (e.g., 256, 512, 768). Model-dependent.
Supported Models:
  • gemini-embedding-001 - Google’s Gemini text embedding model

Response

Returns embedding vectors for each input text.
{
  "code": "0000",
  "msg": "success",
  "data": {
    "embedding": [
      0.0234375,
      -0.0156250,
      0.0390625,
      0.0078125,
      "... (continues for dimensionality length)"
    ]
  },
  "success": true,
  "failed": false
}

Response Parameters

Single Input Response:
ParameterTypeDescription
codestringResponse code indicating the result status (“0000” indicates success)
msgstringResponse message describing the operation result
dataobjectResponse data object containing the embedding
data.embeddingarray[number]Vector embedding array for the input text
successbooleanIndicates whether the operation was successful
failedbooleanIndicates whether the operation failed
Multiple Inputs Response:
ParameterTypeDescription
codestringResponse code indicating the result status (“0000” indicates success)
msgstringResponse message describing the operation result
dataobjectResponse data object containing the embeddings
data.embeddingsarray[array[number]]Array of embedding vectors, one for each input text
successbooleanIndicates whether the operation was successful
failedbooleanIndicates whether the operation failed

Notes

  • Text embeddings are returned synchronously in the response
  • When providing a single text in the input array, the response contains data.embedding (singular)
  • When providing multiple texts, the response contains data.embeddings (plural) as an array of vectors
  • The dimensionality parameter allows you to control the output vector size
  • Supported dimensionality depends on the model (common values: 256, 512, 768, 1024)
  • Lower dimensionality results in faster processing and reduced storage, but may have lower accuracy
  • Use text embeddings for:
    • Semantic search and similarity matching
    • Text classification and clustering
    • Question answering and information retrieval
    • Recommendation systems
    • Duplicate detection

Authorizations

Authorization
string
header
required

Body

application/json
input
string[]
required

List of text strings to embed

Example:
[
"Sample text to embed",
"Another text string"
]
model
enum<string>
required

Embedding model name

Available options:
gemini-embedding-001
Example:

"gemini-embedding-001"

dimensionality
integer

Output embedding dimension size

Example:

512

Response

200 - application/json

Embeddings generated successfully

Response for single input

code
string

Response code indicating the result status

Example:

"0000"

msg
string

Response message describing the operation result

Example:

"success"

data
object

Response data object containing the embedding

success
boolean

Indicates whether the operation was successful

Example:

true

failed
boolean

Indicates whether the operation failed

Example:

false