Skip to content

Text Embedding Inference (TEI) Compatibility

model2vec-serve also exposes TEI-compatible endpoints so existing Hugging Face ecosystem clients can reuse it.

POST /embed

Returns embeddings for one or more input strings.

Headers

  • Content-Type: application/json
  • Authorization: Bearer <api_key> (when authentication is enabled)

Query parameters

  • model (string, optional) — loaded model identifier. If omitted, the configured default model is used.

Body

json
{
  "inputs": "Hello world"
}

inputs may be a single string or a list of strings.

Response

Status: 200 OK

json
[
  [0.0123, -0.0456, "..."]
]

When inputs is a list, the response is a list of embedding vectors in the same order.

Validation rules

  • inputs must be non-empty.
  • Batch size must not exceed --max-batch-size.
  • Token arrays are not supported and return 400 Bad Request.
  • If model is supplied, it must match a loaded model id.

GET /info

Returns metadata about the loaded model. Use the model query parameter to select a specific loaded model; otherwise the configured default model is used.

Query parameters

  • model (string, optional) — loaded model identifier. If omitted, the configured default model is used.

Response

Status: 200 OK

json
{
  "model_id": "minishlab/potion-multilingual-128M",
  "max_input_length": 512,
  "embedding_dimension": 384,
  "pooling": "mean"
}

Field descriptions

FieldTypeDescription
model_idstringLoaded model identifier
max_input_lengthnumberMaximum tokens accepted per input
embedding_dimensionnumberSize of each embedding vector
poolingstringPooling method used by the model

Errors

Statuserror codeCause
400invalid_requestInvalid input, unsupported batch size, token-array input
400model_not_foundRequested model is not loaded
401unauthorizedMissing or invalid API key
500internal_errorInference failure

See Errors for the error body shape.

Example with curl

bash
curl -X POST http://localhost:8080/embed \
  -H "Content-Type: application/json" \
  -d '{"inputs":["Hello","World"]}'

curl -X POST 'http://localhost:8080/embed?model=minishlab/potion-code-16M-v2' \
  -H "Content-Type: application/json" \
  -d '{"inputs":"def hello(): pass"}'

curl http://localhost:8080/info
curl 'http://localhost:8080/info?model=minishlab/potion-code-16M-v2'

Powered by model2vec