Embeddings
POST /v1/embeddings: vectors for text.
/v1/embeddingsReturns a vector representation of text. The format is compatible with OpenAI Embeddings: client.embeddings.create(...) works. You need a model of the "Embeddings" category: text-embedding-3-small, text-embedding-3-large or bge-m3. This endpoint has no PII masking and no streaming.
Headers
| Header | Value |
|---|---|
Authorization | Bearer <key>. Required. x-api-key: <key> is accepted instead |
Content-Type | application/json |
X-Morphogen-Space | spc_…: the spending space. Optional |
Request body
modelstringrequiredAn embeddings model from GET /v1/models. A text model gives 400 model_category_mismatch.
inputstring | arrayrequiredA string or an array of strings.
encoding_formatstringfloat (default) or base64.
dimensionsintegerThe vector size. Not all models support it.
Default dimensions: 1536 for text-embedding-3-small, 3072 for text-embedding-3-large, 1024 for bge-m3. For Russian text, bge-m3 is a good fit.
Request example
curl https://api.morphogen.ru/v1/embeddings \
-H "Authorization: Bearer $MORPHOGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "bge-m3",
"input": ["Как вернуть товар?", "Условия возврата"]
}'Response example
{
"object": "list",
"model": "baai/bge-m3",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] },
{ "object": "embedding", "index": 1, "embedding": [0.0101, -0.0399, 0.0812] }
],
"usage": { "prompt_tokens": 12, "total_tokens": 12 }
}In the example the vector is cut to three numbers, and a real one has 1024 values. Spending is counted by usage.prompt_tokens.
Errors
model_category_mismatchThe model is not in the embeddings category.pii_masking_unsupported_endpointThe request has X-PII-Masking: on.invalid_api_keyThe key is missing, invalid, revoked or expired.insufficient_fundsThe balance does not cover the request reserve.model_not_allowedThe model is not in the key's list.model_not_foundThere is no such model in the catalog.request_too_largeThe request body is larger than 32 MiB.rate_limit_exceededThe request or token limit per minute is exceeded.Other codes: Errors.