What is an embeddings API?

An embeddings API turns text, and on some models images or video, into vectors of numbers that place similar meanings close together. With a reranker to rescore the best matches, it forms the retrieval step of semantic search and retrieval-augmented generation.

Model types

What an embedding is

An embedding is a list of numbers, called a vector, that represents the meaning of an input. An embedding model reads a piece of text and returns a vector of fixed length. Inputs with similar meaning produce vectors that point in similar directions, even when they share no words: reset my password and I cannot sign in to my account end up close together, while update my billing address ends up further away.

You compare two vectors with a similarity measure, most often cosine similarity. A higher score means the inputs are closer in meaning. That one operation supports semantic search, retrieval for language models, clustering, duplicate detection, recommendations and classification by nearest example.

How an embeddings API works

On EmpirioLabs AI you send model and input to POST /v1/embeddings. The input is a string or a list of strings, and the response holds one vector per input in data, plus a usage object with the tokens billed. Embedding models bill input tokens only, because they generate no text.

  • Vector size. On models that offer more than one size, dimensions sets the length of each vector. Larger vectors keep more detail; smaller ones cost less to store and search.
  • Encoding. encoding_format returns vectors as float arrays or as compact base64 strings.
  • Images and video. Multimodal embedding models also take image and video parts, so a text query can retrieve matching images.
  • Search options. Some models return sparse vectors through output_type, and accept an instruct that describes the search task when you embed queries.

Two rules keep results meaningful. Embed documents and queries with the same model and the same vector size, since vectors from different models are not comparable. Split long documents into passages that fit the model's maximum input length, and store each vector with the passage it came from. The embeddings API reference lists every field.

What a reranker adds

Vector search is fast because each document is embedded once, in advance, and a query needs only one new vector. The tradeoff is precision: the query and each document are encoded separately, so the closest vectors make a good shortlist rather than a final ranking.

A reranker reads the query and each candidate together and scores how well that candidate answers the query. That comparison is more accurate and takes more work per document, so you run it on a shortlist, such as the top 50 results from vector search, rather than on a whole collection.

On EmpirioLabs AI you send a query and a list of documents to POST /v1/reranks. The response lists each document's original index with a relevance_score from 0 to 1, most relevant first. Set top_n to return only the best few, and return_documents to include their text. Scores are relative to one request, so use them to order results rather than as a fixed cutoff across different queries. See the reranks API reference for the full request.

Embeddings and reranking in retrieval-augmented generation

Retrieval-augmented generation (RAG) answers questions from your own content by placing the most relevant passages in a language model's prompt. Embeddings and a reranker form its retrieval step:

  1. Split your documents into passages, embed each one, and store the vectors in a vector index.
  2. When a question arrives, embed it with the same model and retrieve the nearest passages.
  3. Send those candidates to a reranker and keep the few with the highest scores.
  4. Pass the question and those passages to a text model, which answers from them.

Reranking keeps the prompt short and relevant: fewer, better passages use fewer input tokens and leave more of the context window for the answer. Browse embedding models and rerankers, or try both in the Playground.

Embeddings models on EmpirioLabs AI

4 models, cheapest first where they share a billing unit. Each model's page has its full rate card, parameters and code.

Endpoints

POST /v1/embeddings

Per 1M tokens, by input rate

ModelInputOutput
Text Embedding v4 Alibaba Cloud$0.07-
Tongyi Embedding Vision Flash Alibaba Cloud$0.09-
Tongyi Embedding Vision Plus Alibaba Cloud$0.09-
Skylark Embedding Vision ByteDance$0.25-

Rerankers models on EmpirioLabs AI

1 models. Each model's page has its rate card, parameters and code.

Endpoints

POST /v1/reranks

Frequently asked questions

What is the difference between an embedding model and a reranker?

An embedding model turns each input into a vector on its own, so you can compare a query against a large collection quickly. A reranker reads a query and a candidate document together and scores their relevance more precisely, so it is used on a short list of results.

Can I compare embeddings from two different models?

No. Each model places meaning in its own vector space, so embed your documents and your queries with the same model and the same vector size.

How are embedding and rerank requests billed?

Embedding and rerank models bill the input tokens you send. They generate no text, so there are no output tokens to bill.

What does a rerank relevance score mean?

It is a number from 0 to 1 that ranks documents for one query, with higher meaning more relevant. Scores are not comparable across requests, so use them to order results within a request.

Can embeddings search images and video?

Yes, with multimodal embedding models. They accept text, image and video inputs, so a text query can retrieve matching images or clips.

Which Embeddings model costs the least on EmpirioLabs AI?

Text Embedding v4 lists the lowest input rate of the 4 Embeddings models priced that way, followed by Tongyi Embedding Vision Flash, Tongyi Embedding Vision Plus. The price table on this page shows each model's lowest rate and what it applies to.

Ready to use better endpoints?

Check out our pricing or reach out if you want your own model deployed on our stack.