> 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/17.latest/management-api/embeddings.md).

# 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 backoffice authentication with the `Umb.AI.Management.Api` authorization policy.

## Endpoints

| Method | Endpoint                                            | Description                                                                           |
| ------ | --------------------------------------------------- | ------------------------------------------------------------------------------------- |
| POST   | `/umbraco/ai/management/api/v1/embeddings/generate` | [Generate embeddings](/ai-in-umbraco/17.latest/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/TjctKyxOtM87Jvg2kiTq" %}
[Generate](/ai-in-umbraco/17.latest/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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
