Databricks Integration (Deprecated)

0.1.2 · deprecated · verified Thu Apr 16

The `langchain-databricks` package was an integration library connecting LangChain with Databricks AI features, including LLMs, vector search, and MLflow. It has been superseded by `databricks-langchain` to consolidate Databricks-related LangChain components. The last published version of `langchain-databricks` is 0.1.2, and it is no longer actively maintained or receiving new features. Users should migrate to the `databricks-langchain` package for continued support and new functionality.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate and use `ChatDatabricks` from the *recommended* `databricks-langchain` package to interact with a Databricks Model Serving endpoint. If running outside a Databricks Workspace, ensure `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables are set for authentication. The code for the deprecated `langchain-databricks` is shown for historical context but should not be used in new projects.

import os
from databricks_langchain import ChatDatabricks
from langchain_core.messages import HumanMessage

# --- IMPORTANT: FOR RUNNING OUTSIDE DATABRICKS WORKSPACE ---
# Set these environment variables or pass them directly to the ChatDatabricks constructor.
# os.environ["DATABRICKS_HOST"] = os.environ.get("DATABRICKS_HOST", "https://your-databricks-workspace.cloud.databricks.com")
# os.environ["DATABRICKS_TOKEN"] = os.environ.get("DATABRICKS_TOKEN", "dapi********************************")

# Instantiate the chat model using a Databricks Model Serving endpoint
# Replace 'databricks-meta-llama-3-70b-instruct' with your actual endpoint name.
# Ensure DATABRICKS_HOST and DATABRICKS_TOKEN are set if running outside Databricks workspace.
chat_model = ChatDatabricks(
    endpoint="databricks-meta-llama-3-70b-instruct",
    temperature=0.1,
    max_tokens=256
)

# Invoke the model
response = chat_model.invoke([HumanMessage(content="What is MLflow?")])
print(response.content)

# --- DEPRECATED PACKAGE USAGE (for context, prefer databricks-langchain) ---
# from langchain_databricks import ChatDatabricks
# deprecated_chat_model = ChatDatabricks(endpoint="your-deprecated-endpoint")
# print("WARNING: Using deprecated langchain-databricks package.")

view raw JSON →