On this page

Embeddings

POST /v1/embeddings changes text into vectors. Similar texts get vectors that are near each other. Use them for search, clustering and recommendations.

Send a request#

curl "$EMBER_API_URL/v1/embeddings" \
  -H "Authorization: Bearer $EMBER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "<embedding model ID>", "input": ["first text", "second text"]}'

The response has one vector for each input, in the same order.

Parameters#

ParameterValue
modelAn embedding model. Send GET /v1/models to find one.
inputOne string, or a list of up to 2,048 strings. Each string has at most 200,000 characters.
encoding_formatfloat (the default) or base64.
dimensions1 to 8,192, if the model can make shorter vectors.

Good practice#

  1. Send many inputs in one request. This is faster than one request for each input.
  2. Use the same model for your documents and for your queries.
  3. Keep each input below the context length of the model. Split long documents into parts.