Skip to content

Embeddings

Generate vector embeddings for text input. Use embeddings for semantic search, clustering, classification, and RAG (Retrieval-Augmented Generation).

Endpoint

POST /v1/embeddings

Request Body

Parameter Type Required Description
model string Embedding model ID (e.g. text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002)
input string/array Text to embed. Can be a single string or array of strings for batch processing.
encoding_format string float (default) or base64
dimensions integer Output dimensions (for models that support it, like text-embedding-3-*)

Example

curl https://ai.moducompia.com/v1/embeddings \
  -H "Authorization: Bearer sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog"
  }'
response = client.embeddings.create(
    model="text-embedding-3-small",
    input="The quick brown fox jumps over the lazy dog"
)
embedding = response.data[0].embedding
print(f"Dimensions: {len(embedding)}")

Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.0091, 0.0152, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

Batch Embedding

Send multiple texts at once for efficiency:

{
  "model": "text-embedding-3-small",
  "input": [
    "First document to embed",
    "Second document to embed",
    "Third document to embed"
  ]
}

Each text gets its own entry in data[], ordered by index.