Skip to main content
Embeddings turn text into numerical vectors that capture meaning. They are the foundation for RAG pipelines, semantic search, recommendations, and clustering. Eden AI exposes an OpenAI-compatible embeddings endpoint that works the same way across all supported providers — pick a model, send text, get vectors.

What are embeddings?

An embedding is a list of floating-point numbers — a vector — that represents a piece of text in a high-dimensional space. The model is trained so that texts with similar meaning land close together in that space, and unrelated texts land far apart. Concretely, “cat” and “kitten” produce nearly identical vectors. “Cat” and “airplane” produce vectors that point in very different directions. The distance between two vectors (usually measured with cosine similarity) is a numerical proxy for how related the two texts are. You generate embeddings once for your corpus, store the vectors, and then compare new query vectors against the stored ones at lookup time. That’s the entire shape of semantic search and RAG.

Use cases

  • Retrieval-Augmented Generation (RAG) — embed your docs, retrieve the most relevant chunks for a user question, feed them into an LLM.
  • Semantic search — match queries against documents by meaning, not keywords.
  • Recommendations — suggest similar products, articles, or songs based on description vectors.
  • Clustering and topic discovery — group thousands of texts by meaning without labels.
  • Deduplication — find near-duplicates that don’t share exact wording.
  • Anomaly detection — flag inputs that look unlike anything in your corpus.
  • Classification — train a small classifier on top of frozen embeddings instead of fine-tuning a full model.

Endpoints

Models are identified as provider/model — the same format used everywhere else in V3.

List available models

Each item exposes id, owned_by, context_length, pricing, capabilities, and regions. Use any id as the model field below.

Create embeddings

The example picks a model from the catalog at runtime so the snippet never goes stale.
This is the smallest end-to-end example that demonstrates the full retrieval pattern: embed a query and a small corpus in one batched call, score with cosine similarity, return the top matches.
Python
The first hit should be the document about the cost field. Swap in your own corpus, persist corpus_vecs to a vector database, and you have a working RAG retriever.

Request body

Unknown top-level fields are forwarded to the underlying provider, so provider-specific options can be passed through unchanged.

Response

provider and cost are Eden extensions on top of the OpenAI shape. When encoding_format is "base64", each embedding is a base64-encoded string instead of a list.

Batching

Pass a list to input to embed multiple strings in one call. Items in data keep their index matching the input order — that’s the property the worked example relies on. Batching is significantly cheaper and faster than one call per string.
Python

Choosing a model

There is no single best embedding model — picking one is a tradeoff between quality, dimension count, context length, language coverage, and price.
  • Small / fast / cheap (e.g. *-small variants) — good default for most semantic-search workloads. Lower latency, lower cost per token, vectors are smaller so storage and dot products are faster.
  • Large / higher quality (e.g. *-large variants) — meaningfully better recall on hard retrieval tasks (long technical docs, multilingual corpora). Costs more and produces larger vectors.
  • Context length — long-context embedding models let you embed entire documents without chunking. Most 8k-context models still need chunking for paragraphs above ~2k tokens.
  • Dimensions — some models (e.g. openai/text-embedding-3-small and openai/text-embedding-3-large) support a dimensions parameter to truncate outputs. Smaller vectors save storage and speed up similarity search at a small recall cost.
  • Multilingual — verify language support in the model’s capabilities before using it for non-English corpora.
A common pattern: prototype with a small model, then A/B test a larger model on your evaluation set before committing to the storage cost.

Errors

Common HTTP status codes returned by /v3/embeddings:

Best practices

  • Smart routing is not supported on embeddings. Always pass a concrete provider/model, not @edenai/.... See Smart routing for which endpoints support it.
  • Compare vectors with cosine similarity. It is the standard distance for embedding spaces. Normalize once at write time so retrieval is a single dot product.
  • Re-index when you change models. Vectors from different models are not compatible — store (text, embedding, model_id) together and re-embed if you switch.
  • Cache embeddings. They are deterministic for the same (model, input) pair, so caching by hash avoids re-billing for unchanged content.
  • Chunk before embedding long documents. Most models cap at 8k tokens; for retrieval, paragraph-sized chunks (~200–500 tokens) generally outperform whole-document embeddings.