MorphogenDocs
API

Embeddings

POST /v1/embeddings: vectors for text.

POST/v1/embeddings

Returns 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

HeaderValue
AuthorizationBearer <key>. Required. x-api-key: <key> is accepted instead
Content-Typeapplication/json
X-Morphogen-Spacespc_…: the spending space. Optional

Request body

modelstringrequired

An embeddings model from GET /v1/models. A text model gives 400 model_category_mismatch.

inputstring | arrayrequired

A string or an array of strings.

encoding_formatstring

float (default) or base64.

dimensionsinteger

The 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

400model_category_mismatchThe model is not in the embeddings category.
400pii_masking_unsupported_endpointThe request has X-PII-Masking: on.
401invalid_api_keyThe key is missing, invalid, revoked or expired.
402insufficient_fundsThe balance does not cover the request reserve.
403model_not_allowedThe model is not in the key's list.
404model_not_foundThere is no such model in the catalog.
413request_too_largeThe request body is larger than 32 MiB.
429rate_limit_exceededThe request or token limit per minute is exceeded.

Other codes: Errors.

On this page