﻿---
title: ES|QL EMBEDDING function
description: navigation_title: "EMBEDDING" 
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/esql/functions-operators/dense-vector-functions/embedding
products:
  - Elasticsearch
---

# ES|QL EMBEDDING function
---

navigation_title: "EMBEDDING"
<applies-to>
  - Elastic Stack: Planned
</applies-to>


## Syntax

![Embedded](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/esql/images/functions/embedding.svg)


## Parameters

<definitions>
  <definition term="value">
    Value to generate embeddings from. Must be a non-null literal string value. Use data type and format options to specify the content type and format (e.g. plain text, base64-encoded images) of the input.
  </definition>
  <definition term="inference_id">
    Identifier of an existing inference endpoint that will generate the embeddings. The inference endpoint must have the `embedding` task type and should use the same model that was used to embed your indexed data.
  </definition>
  <definition term="options">
    (Optional) Options for the input value.
  </definition>
</definitions>


## Description

Generates dense vector embeddings from multimodal input using a specified [inference endpoint](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/explore-analyze/elastic-inference/inference-api) with the {@code embedding} task type. Use this function to generate query vectors for KNN searches from multimodal inputs against your vectorized data or other dense vector based operations.

## Supported types


| value   | inference_id | options          | result       |
|---------|--------------|------------------|--------------|
| keyword | keyword      | named parameters | dense_vector |


### Supported function named parameters

<definitions>
  <definition term="type">
    (keyword) Content type of the input (e.g. "text", "image").
  </definition>
  <definition term="timeout">
    (keyword) Timeout for the inference request (e.g. "30s", "1m").
  </definition>
</definitions>


## Examples

Generate embeddings using the 'test_dense_inference' inference endpoint, using the default type and format (text):
```esql
FROM dense_vector_text METADATA _score
| EVAL query_embedding = EMBEDDING("be excellent to each other", "test_embedding_inference")
| WHERE KNN(text_embedding_field, query_embedding)
| SORT _score DESC
| LIMIT 10
```

Generate embeddings using an inference endpoint, specifying the data type:
```esql
ROW b64_input="This is an image"
| EVAL embedding = EMBEDDING("data:image/jpeg;base64,VGhpcyBpcyBhbiBpbWFnZQ==", "test_embedding_inference", {"type": "image"})
```