Databricks Lakehouse Platform unifies data, analytics, and AI on one platform.This guide provides a quick overview for getting started with Databricks chat models. For detailed documentation of all ChatDatabricks features and configurations head to the API reference.
Overview
ChatDatabricks class wraps a chat model endpoint hosted on Databricks Model Serving. This example notebook shows how to wrap your serving endpoint and use it as a chat model in your LangChain application.
Integration details
| Class | Package | Local | Serializable | Downloads | Version |
|---|---|---|---|---|---|
| ChatDatabricks | databricks-langchain | ❌ | beta |
Model features
| Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
|---|---|---|---|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
Supported Methods
ChatDatabricks supports all methods of ChatModel including async APIs.
Endpoint Requirement
The serving endpointChatDatabricks wraps must have OpenAI-compatible chat input/output format (reference). As long as the input format is compatible, ChatDatabricks 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 DRBX, Llama3, Mixtral-8x7B, and etc. These endpoint are ready to use in your Databricks workspace without any set up.
- Custom Models - You can also deploy custom 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 GPT4.
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.
ChatDatabricks.
For other type of endpoints, there are some difference in how to set up the endpoint itself, however, once the endpoint is ready, there is no difference in how to query it with ChatDatabricks. Please refer to the bottom of this notebook for the examples with other type of endpoints.
Instantiation
Invocation
Chaining
Similar to other chat models,ChatDatabricks can be used as a part of a complex chain.
Invocation (streaming)
Async Invocation
Tool calling
ChatDatabricks supports OpenAI-compatible tool calling API that lets you describe tools and their arguments, and have the model return a JSON object with a tool to invoke and the inputs to that tool. tool-calling is extremely useful for building tool-using chains and agents, and for getting structured outputs from models more generally. WithChatDatabricks.bind_tools, we can easily pass in Pydantic classes, dict schemas, LangChain tools, or even functions as tools to the model. Under the hood these are converted to the OpenAI-compatible tool schemas, which looks like:
Wrapping Custom Model Endpoint
Prerequisites:- An LLM was registered and deployed to a Databricks serving endpoint via MLflow. The endpoint must have OpenAI-compatible chat input/output format (reference)
- You have “Can Query” permission to the endpoint.
Wrapping External Models
Prerequisite: Create Proxy Endpoint First, create a new Databricks serving endpoint that proxies requests to the target external model. The endpoint creation should be fairy quick for proxying external models. This requires registering your OpenAI API Key within the Databricks secret manager as follows:Function calling on Databricks
Databricks Function Calling is OpenAI-compatible and is only available during model serving as part of Foundation Model APIs. See Databricks function calling introduction for supported models.API reference
For detailed documentation of all ChatDatabricks features and configurations head to the API reference: api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_langchain.html#databricks_langchain.ChatDatabricksConnect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.