---
title: ES|QL TEXT_EMBEDDING function
description: 
url: https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/dense-vector-functions/text_embedding
products:
  - Elasticsearch
---

# ES|QL TEXT_EMBEDDING function
<applies-to>
  - Elastic Stack: Generally available since 9.4
  - Elastic Stack: Preview in 9.3
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/docs/reference/query-languages/esql/images/generated/x-pack-esql/functions/text_embedding.svg)


## Parameters

<definitions>
  <definition term="text">
    Text string to generate embeddings from. Must be a non-null literal string value.
  </definition>
  <definition term="inference_id">
    Identifier of an existing inference endpoint that will generate the embeddings. The inference endpoint must have the `text_embedding` task type and should use the same model that was used to embed your indexed data.
  </definition>
  <definition term="options Elastic Cloud Serverless: Generally available, Elastic Stack: Planned">
    (Optional) Options for the inference request.
  </definition>
</definitions>


## Description

Generates dense vector embeddings from text input using a specified [inference endpoint](https://www.elastic.co/docs/explore-analyze/elastic-inference/inference-api). Use this function to generate query vectors for KNN searches against your vectorized data or others dense vector based operations.

## Supported types


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


### Supported function named parameters

<definitions>
  <definition term="timeout Elastic Cloud Serverless: Generally available, Elastic Stack: Planned">
    (keyword) Timeout for the inference request (e.g. "30s", "1m").
  </definition>
</definitions>


## Example

Generate text embeddings using the 'test_dense_inference' inference endpoint.
```esql
FROM dense_vector_text METADATA _score
| WHERE KNN(text_embedding_field, TEXT_EMBEDDING("be excellent to each other", "test_dense_inference"))
```