Skip to content

Embeddings

Embeddings convert text into vectors whose distance reflects similarity. They are the basis of semantic search and retrieval-augmented generation.

Use an embedding model — one carrying the embedding category in the catalog. Chat models cannot serve this endpoint.

Terminal window
curl https://api.resetdata.ai/api/v1/embeddings \
-H "Authorization: Bearer $RESETDATA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "EMBEDDING_MODEL",
"input": "Sovereign AI infrastructure in Australia."
}'

Replace EMBEDDING_MODEL with an embedding model slug from the catalog.

input accepts an array, and batching is markedly more efficient than one request per string — fewer round trips, and one admission through the queue instead of many.

resp = client.embeddings.create(
model="EMBEDDING_MODEL",
input=["First document.", "Second document.", "Third document."],
)
vectors = [d.embedding for d in resp.data]

Results come back in data, each with an index matching your input order. Match on index rather than assuming ordering.

  • Use the same model for both sides. Vectors from different models are not comparable. If you re-embed your corpus with a new model, you must re-embed your queries too.
  • Chunk before embedding. Embedding models have short context windows relative to chat models, and a vector over a whole document is too diffuse to retrieve well. Paragraph-to-page sized chunks with slight overlap is a reasonable default.
  • Check for asymmetric models. Some embedding models expect queries and documents to be embedded differently, via a parameter such as input_type. Check supported_parameters — see Model parameters.
  • Store the model and dimension alongside your vectors, so a future migration is a known quantity.

Embeddings are charged on input tokens only — there is no generated output — and are typically far cheaper per token than chat models. Embedding a large corpus is still a bulk operation worth estimating before you start; see Usage and costs.

Embedding similarity alone is often not precise enough at the top of the ranking. The usual fix is to retrieve generously with embeddings, then reorder with a reranker before passing results to a model.