Databricks Lakehouse Platform unifies data, analytics, and AI on one platform.This guide provides a quick overview for getting started with Databricks embedding models. For detailed documentation of all
DatabricksEmbeddings features and configurations head to the API reference.
Overview
Integration details
| Class | Package |
|---|---|
| DatabricksEmbeddings | databricks-langchain |
Supported Methods
DatabricksEmbeddings supports all methods of Embeddings class including async APIs.
Endpoint Requirement
The serving endpointDatabricksEmbeddings wraps must have OpenAI-compatible embedding input/output format (reference). As long as the input format is compatible, DatabricksEmbeddings can be used for any endpoint type hosted on Databricks Model Serving:
- Foundation Models - Curated list of state-of-the-art foundation models such as BAAI General Embedding (BGE). These endpoint are ready to use in your Databricks workspace without any set up.
- Custom Models - You can also deploy custom embedding models to a serving endpoint via MLflow with your choice of framework such as LangChain, Pytorch, Transformers, etc.
- External Models - Databricks endpoints can serve models that are hosted outside Databricks as a proxy, such as proprietary model service like OpenAI text-embedding-3.
Setup
To access Databricks models you’ll need to create a Databricks account, set up credentials (only if you are outside Databricks workspace), and install required packages.Credentials (only if you are outside Databricks)
If you are running LangChain app inside Databricks, you can skip this step. Otherwise, you need manually set the Databricks workspace hostname and personal access token toDATABRICKS_HOST and DATABRICKS_TOKEN environment variables, respectively. See Authentication Documentation for how to get an access token.
Installation
The LangChain Databricks integration lives in thedatabricks-langchain package:
Instantiation
Indexing and Retrieval
Embedding models are often used in retrieval-augmented generation (RAG) flows, both as part of indexing data as well as later retrieving it. For more detailed instructions, please see our RAG tutorials. Below, see how to index and retrieve data using theembeddings object we initialized above. In this example, we will index and retrieve a sample document in the InMemoryVectorStore.
Direct Usage
Under the hood, the vectorstore and retriever implementations are callingembeddings.embed_documents(...) and embeddings.embed_query(...) to create embeddings for the text(s) used in from_texts and retrieval invoke operations, respectively.
You can directly call these methods to get embeddings for your own use cases.
Embed single texts
You can embed single texts or documents withembed_query:
Embed multiple texts
You can embed multiple texts withembed_documents:
Async Usage
You can also useaembed_query and aembed_documents for producing embeddings asynchronously:
API reference
For detailed documentation onDatabricksEmbeddings features and configuration options, please refer to the API reference.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.