Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">15.5.5</button>

- [15.5.5](https://docs.cloud.google.com/alloydb/omni/containers/15.5.5/docs/model-endpoint-embeddings.md.txt)
- [15.5.4](https://docs.cloud.google.com/alloydb/omni/containers/15.5.4/docs/model-endpoint-embeddings.md.txt)
- [15.5.2](https://docs.cloud.google.com/alloydb/omni/containers/15.5.2/docs/model-endpoint-embeddings.md.txt)

<br />

> [!WARNING]
>
> **Preview
> --- Model endpoint management**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

This page describes a preview that lets you experiment with registering an AI model endpoint
and invoking predictions with Model endpoint management. For using AI models in
production environments, see [Build generative AI applications using
AlloyDB AI](https://docs.cloud.google.com/alloydb/docs/ai) and [Work with vector embeddings](https://docs.cloud.google.com/alloydb/omni/containers/15.5.5/docs/work-with-embeddings.md.txt).

After the model endpoints are added and registered in the Model endpoint management, you can
reference them using the model ID to generate embeddings.

## Before you begin

Make sure that you have registered your model endpoint with Model endpoint management. For
more information, see [Register a model endpoint with
model endpoint management](https://docs.cloud.google.com/alloydb/omni/containers/15.5.5/docs/model-endpoint-register-model)

## Generate embeddings

Use the `google_ml.embedding()` SQL function to call the registered model endpoint with
the text embedding model type to generate embeddings.

To call the model and generate embeddings, use the following SQL query:

```sql
SELECT
  google_ml.embedding(
    model_id => 'MODEL_ID',
    content => 'CONTENT');
```

Replace the following:

- `MODEL_ID`: the model ID you defined when registering the model endpoint.
- `CONTENT`: the text to translate into a vector embedding.

## Examples

Some examples for generating embeddings using registered model endpoint are listed in this section.

#### Text embedding models with in-built support

To generate embeddings for a registered `textembedding-gecko@002` model endpoint, run the following statement:

```sql
    SELECT
      google_ml.embedding(
        model_id => 'textembedding-gecko@002',
        content => 'AlloyDB is a managed, cloud-hosted SQL database service');
```

To generate embeddings for a registered `text-embedding-ada-002` model endpoint by OpenAI, run the following statement:

```sql
    SELECT
      google_ml.embedding(
        model_id => 'text-embedding-ada-002',
        content => 'e-mail spam');
```

#### Other text embedding models

To generate embeddings for a registered `text-embedding-3-small` or `text-embedding-3-large` model endpoints by OpenAI, run the following statement:

```sql
  SELECT
    google_ml.embedding(
      model_id => 'text-embedding-3-small',
      content => 'Vector embeddings in AI');
```