<a id="flink-sql-embedding-action"></a>

# Create Embeddings with Confluent Cloud for Apache Flink

Confluent Cloud for Apache Flink® supports creating embeddings for Retrieval-Augmented Generation
(RAG) workflows from Kafka topics and Flink tables.

An embedding is a numerical representation that captures relationships and
meaning within complex data. In a Retrieval-Augmented Generation (RAG)
workflow, an embedding helps to retrieve the most relevant information,
ensuring AI delivers precise, context-aware results.

In the Confluent Cloud Console, you can choose your preferred embedding model and
transform a selected text column in a Kafka topic into a stream of vector
embeddings.

In this guide, you use a Flink Action to connect an existing AI model to an
input topic that has embedding data and an output topic that contains the
embedding.

## Prerequisites

- Access to Confluent Cloud.
- Access to a Flink compute pool.
- Sufficient permissions to create models. For more information, see
  [RBAC for model inference](../confluent-intelligence/overview.md#ai-model-inference-rbac).
- A Kafka topic to use as a source for the embedding data.
- A model in one of the supported providers. For more information, see
  [Run an AI Model](../ai-model-inference.md#flink-sql-ai-model).

## Configure the Create Embedding action

In the following steps, you select a column in a topic that has embedding data,
the name of an output topic that contains the embedding, and the AI model.

1. Log in to Confluent Cloud Console at
   [https://confluent.cloud/login](https://confluent.cloud/login).
2. In the navigation menu, click **Data portal** to open the **Data portal**
   page.
3. In the **Environment** drop-down, select the environment where you want the
   embedding to run.
4. Click the tile of the topic that has your embedding data, and in the details
   pane, click **Actions**.
5. Click **Create embeddings**.
6. In the **Action details** section, select the column to use as the source
   for your embedding. The dropdown shows all columns in the table that you
   can use. Only string and VARCHAR columns can be appended to the embedding.
7. In the **Output topic embedding column** textbox, enter the name of column
   in the Kafka topic that receives the embedding data. The default name is
    *<column-name>_embedding*.
8. In the **Model** dropdown, select the name of an existing model that was
   registered previously by using the
   [CREATE MODEL](../../flink/reference/statements/create-model.md#flink-sql-create-model)
   statement, or choose **Create new model** to register a new model.

   To register a new model, provide the following details:
   - **Model name:** Enter the name of the new model.
   - **Provider:** Select one of the supported model providers.
   - **Endpoint:** Enter the URL of the model.

   For more information, see
   [Create an AI model](../ai-model-inference.md#flink-sql-ai-model-create-model).
9. (Optional) If your data needs to chunked, select **Enable chunking** and
   enter values for the related settings.
10. In the **Output topic** section, select the Flink catalog and database
    (environment and cluster) for the embedding table.
11. In the **Table** textbox, enter the name of the Flink table that contains
    the embedding. The default name is  *<source-topic-name>_embedding*.
12. In the **Runtime configuration** section, select the Flink compute pool to
    run the embedding query.
    - (Optional) Select **Run with a service account** for production jobs.
    - (Optional) Select **Show SQL** to view the Flink statement that does the
      embedding work.
13. Click **Confirm and run** to start the embedding statement.

## Related content

- [CREATE MODEL statement](../../flink/reference/statements/create-model.md#flink-sql-create-model)
- [Create an AI model](../ai-model-inference.md#flink-sql-ai-model-create-model)

#### NOTE
This website includes content developed at the [Apache Software Foundation](https://www.apache.org/)
under the terms of the [Apache License v2](https://www.apache.org/licenses/LICENSE-2.0.html).
