> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/ai-in-umbraco/management-api/embeddings.md).

# Embeddings

REST API endpoints for generating text embeddings.

The Embeddings API provides endpoints for generating vector embeddings from text, useful for semantic search, content similarity, and recommendation systems.

## Overview

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
* **Content similarity**: Identify related articles or documents
* **Recommendations**: Suggest similar content to users
* **Clustering**: Group similar content together

## Base URL

```
/umbraco/ai/management/api/v1/embeddings
```

## Authentication

All endpoints require an authenticated backoffice user (the `BackOfficeAccess` authorization policy). Unlike most Management API endpoints, they don't require access to the AI section.

## Endpoints

| Method | Endpoint                                            | Description                                                                 |
| ------ | --------------------------------------------------- | --------------------------------------------------------------------------- |
| POST   | `/umbraco/ai/management/api/v1/embeddings/generate` | [Generate embeddings](/ai-in-umbraco/management-api/embeddings/generate.md) |

## Response Model

### EmbeddingResponseModel

```json
{
  "embeddings": [
    {
      "index": 0,
      "vector": [0.0023, -0.0092, 0.0156, ...]
    },
    {
      "index": 1,
      "vector": [0.0089, -0.0034, 0.0201, ...]
    }
  ]
}
```

| Property              | Type     | Description                        |
| --------------------- | -------- | ---------------------------------- |
| `embeddings`          | array    | List of embedding results          |
| `embeddings[].index`  | int      | Index of the input value (0-based) |
| `embeddings[].vector` | float\[] | The embedding vector               |

## Vector Dimensions

The vector size depends on the embedding model configured in your profile:

| Model                  | Dimensions |
| ---------------------- | ---------- |
| text-embedding-3-small | 1536       |
| text-embedding-3-large | 3072       |
| text-embedding-ada-002 | 1536       |

## Working with Embeddings

### Calculating Similarity

Use cosine similarity to compare embedding vectors:

{% code title="Example" %}

```csharp
public static double CosineSimilarity(float[] a, float[] b)
{
    double dotProduct = 0;
    double normA = 0;
    double normB = 0;

    for (int i = 0; i < a.Length; i++)
    {
        dotProduct += a[i] * b[i];
        normA += a[i] * a[i];
        normB += b[i] * b[i];
    }

    return dotProduct / (Math.Sqrt(normA) * Math.Sqrt(normB));
}

// Similarity ranges from -1 to 1 (higher = more similar)
var similarity = CosineSimilarity(embedding1.Vector, embedding2.Vector);
```

{% endcode %}

### Storing Embeddings

For production use, store embeddings in a vector database:

* **pgvector** (PostgreSQL extension)
* **Azure AI Search**
* **Pinecone**
* **Qdrant**

## In This Section

{% content-ref url="/pages/2vyx22aPVur0punosz5R" %}
[Generate](/ai-in-umbraco/management-api/embeddings/generate.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/ai-in-umbraco/management-api/embeddings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
