Skip to main content
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": 200,
  "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.
Pricing:
  • $0.0000002 per token (2e-7/token)

Code Examples

const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
const API_KEY = "sk-mai-this_a_test_string_please_use_your_generated_key_during_testing";

const response = await fetch(`${BASE_URL}/embeddings/text`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': API_KEY
  },
  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": 200,
  "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 (200 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 (200 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
  • Important: 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. Make sure your code handles both response keys.
  • 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:

200

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