For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Embeddings

Generate vector embeddings for semantic search, similarity matching, and RAG applications.

The embeddings API generates vector representations of text. Use embeddings for semantic search, document similarity, clustering, and Retrieval-Augmented Generation (RAG).

What Are Embeddings

Embeddings convert text into numerical vectors that capture semantic meaning. Similar texts produce similar vectors, enabling:

  • Semantic search - Find content by meaning, beyond keyword matching

  • Document similarity - Compare how related two pieces of content are

  • Clustering - Group similar content together

  • RAG - Retrieve relevant context for AI responses

IAIEmbeddingService

The primary interface for embedding operations:

IAIEmbeddingService.cs
public interface IAIEmbeddingService
{
    // Single embedding
    Task<Embedding<float>> GenerateEmbeddingAsync(
        Action<AIEmbeddingBuilder> configure,
        string value,
        CancellationToken cancellationToken = default);

    // Multiple embeddings
    Task<GeneratedEmbeddings<Embedding<float>>> GenerateEmbeddingsAsync(
        Action<AIEmbeddingBuilder> configure,
        IEnumerable<string> values,
        CancellationToken cancellationToken = default);

    // Advanced: Get a configured generator
    Task<IEmbeddingGenerator<string, Embedding<float>>> CreateEmbeddingGeneratorAsync(
        Action<AIEmbeddingBuilder> configure,
        CancellationToken cancellationToken = default);
}

Basic Usage

Choosing a Profile

Default Profile

Once you have configured a default embedding profile in the backoffice, you can call without specifying a profile on the builder:

Specific Profile

Select a profile by ID or alias on the builder:

Common Use Cases

  1. Generate embeddings for all searchable content

  2. Store embeddings in a vector database

  3. When searching, embed the query and find nearest neighbors

Content Similarity

Compare two pieces of content:

RAG (Retrieval-Augmented Generation)

  1. Embed user question

  2. Find relevant content via vector search

  3. Include retrieved content in chat prompt

In This Section

Generating EmbeddingsBatch Embeddings

Last updated

Was this helpful?