---
title: Query an embedding model | Databricks on AWS
source: https://docs.databricks.com/aws/en/machine-learning/model-serving/query-embedding-models
ingestedAt: "2026-06-18T08:12:31.459Z"
---

In this article, you learn how to write query requests for foundation models that are optimized for embeddings tasks and send them to your model serving endpoint.

The examples in this article apply to querying foundation models that are made available using either:

*   [Foundation Models APIs](https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/) which are referred to as **Databricks-hosted foundation models**.
*   [External models](https://docs.databricks.com/aws/en/generative-ai/external-models/) which are referred to as **foundation models hosted outside of Databricks**.

## Requirements[​](#requirements "Direct link to Requirements")

*   See [Requirements](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#required).
*   [Install the appropriate package](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#install) to your cluster based on the [querying client option](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#client-options) you choose.

## Query examples[​](#query-examples "Direct link to Query examples")

The following is an embeddings request for the `gte-large-en` model made available by Foundation Model APIs pay-per-token, using the different [client options](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#client-options).

*   OpenAI client
*   SQL
*   REST API
*   MLflow Deployments SDK
*   Databricks Python SDK
*   LangChain

To use the OpenAI client, specify the model serving endpoint name as the `model` input.

Python

    from databricks_openai import DatabricksOpenAIclient = DatabricksOpenAI()response = client.embeddings.create(  model="databricks-gte-large-en",  input="what is databricks")

To query foundation models outside your workspace, you must use the OpenAI client directly, as demonstrated below. The following example assumes you have a Databricks API token and `openai` installed on your compute. You also need your Databricks workspace instance to connect the OpenAI client to Databricks.

Python

    import osimport openaifrom openai import OpenAIclient = OpenAI(    api_key="dapi-your-databricks-token",    base_url="https://example.staging.cloud.databricks.com/serving-endpoints")response = client.embeddings.create(  model="databricks-gte-large-en",  input="what is databricks")

The following is the expected request format for an embeddings model. For external models, you can include additional parameters that are valid for a given provider and endpoint configuration. See [Additional query parameters](https://docs.databricks.com/aws/en/generative-ai/external-models/#extra-parameters).

Bash

    {  "input": [    "embedding text"  ]}

The following is the expected response format:

JSON

    {  "object": "list",  "data": [    {      "object": "embedding",      "index": 0,      "embedding": []    }  ],  "model": "text-embedding-ada-002-v2",  "usage": {    "prompt_tokens": 2,    "total_tokens": 2  }}

## Supported models[​](#supported-models "Direct link to Supported models")

See [Foundation model types](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#model-types) for supported embedding models.

## Check whether embeddings are normalized[​](#check-whether-embeddings-are-normalized "Direct link to Check whether embeddings are normalized")

Use the following to check if the embeddings generated by your model are normalized.

Python

      import numpy as np  def is_normalized(vector: list[float], tol=1e-3) -> bool:      magnitude = np.linalg.norm(vector)      return abs(magnitude - 1) < tol

## Additional resources[​](#additional-resources "Direct link to Additional resources")

*   [Query a chat model](https://docs.databricks.com/aws/en/machine-learning/model-serving/query-chat-models).
*   [Query reasoning models](https://docs.databricks.com/aws/en/machine-learning/model-serving/query-reason-models).
*   [Query vision models](https://docs.databricks.com/aws/en/machine-learning/model-serving/query-vision-models).
