{"id":3448,"library":"databricks-langchain","title":"Databricks LangChain Integration","description":"The databricks-langchain library provides support for integrating Databricks AI capabilities, such as LLMs and Vector Search, directly into LangChain applications. It enables developers to leverage Databricks-hosted models and data artifacts within the LangChain ecosystem. The current version is 0.18.0, with releases typically aligning with LangChain community updates and Databricks feature rollouts.","status":"active","version":"0.18.0","language":"en","source_language":"en","source_url":"https://github.com/databricks/databricks-langchain","tags":["databricks","langchain","llm","ai","vector-db","rag","integration"],"install":[{"cmd":"pip install databricks-langchain","lang":"bash","label":"Install core library"}],"dependencies":[{"reason":"Core LangChain framework components are required for integration.","package":"langchain","optional":false},{"reason":"Fundamental LangChain abstractions and utilities.","package":"langchain-core","optional":false},{"reason":"Data validation and settings management, common across the LangChain ecosystem.","package":"pydantic","optional":false}],"imports":[{"note":"Databricks integrations are part of LangChain's community modules; import via `langchain_community` for correct functionality within the LangChain ecosystem.","wrong":"from databricks_langchain.chat_models import ChatDatabricks","symbol":"ChatDatabricks","correct":"from langchain_community.chat_models import ChatDatabricks"},{"note":"Databricks integrations are part of LangChain's community modules; import via `langchain_community` for correct functionality within the LangChain ecosystem.","wrong":"from databricks_langchain.vectorstores import DatabricksVectorSearch","symbol":"DatabricksVectorSearch","correct":"from langchain_community.vectorstores import DatabricksVectorSearch"}],"quickstart":{"code":"import os\nfrom langchain_community.chat_models import ChatDatabricks\nfrom langchain_core.messages import HumanMessage\n\n# Ensure these environment variables are set for authentication:\n# os.environ[\"DATABRICKS_HOST\"] = \"https://<your-workspace-url>\"\n# os.environ[\"DATABRICKS_TOKEN\"] = \"dapixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\n# Retrieve credentials from environment variables\nhost = os.environ.get(\"DATABRICKS_HOST\", \"\")\ntoken = os.environ.get(\"DATABRICKS_TOKEN\", \"\")\n\nif not host or not token:\n    print(\"Error: DATABRICKS_HOST and DATABRICKS_TOKEN environment variables must be set.\")\n    # In a production environment, you would likely raise an exception or handle gracefully.\n    exit(1)\n\n# Initialize the Databricks chat model\nllm = ChatDatabricks(\n    databricks_host=host,\n    databricks_token=token,\n    temperature=0.1,\n    model=\"databricks-mixtral-8x7b-instruct\" # Use an appropriate model available in your workspace\n)\n\n# Invoke the model with a string prompt\nresponse = llm.invoke(\"Explain the concept of RAG in LLMs in one sentence.\")\nprint(f\"\\nString prompt response: {response.content}\")\n\n# Example with a list of messages (common for chat models)\nmessages = [\n    HumanMessage(content=\"What is the capital of France?\"),\n]\nresponse_chat = llm.invoke(messages)\nprint(f\"\\nChat response: {response_chat.content}\")","lang":"python","description":"Demonstrates how to initialize and use `ChatDatabricks` for interacting with Databricks-hosted LLMs. It highlights setting up authentication credentials (host and token) via environment variables and making simple API calls with both string and message list inputs."},"warnings":[{"fix":"Verify `os.environ.get('DATABRICKS_HOST')` and `os.environ.get('DATABRICKS_TOKEN')` return valid values. Check Databricks workspace URL and the scope/permissions of your access token.","message":"Authentication failures are common. Ensure `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables are correctly set or passed directly. The host URL should include the `https://` prefix.","severity":"gotcha","affected_versions":"All"},{"fix":"Always use `from langchain_community.<component_type> import <Class>` (e.g., `from langchain_community.chat_models import ChatDatabricks`). Directly importing from `databricks_langchain` will likely fail or lead to unexpected behavior.","message":"Incorrect import paths. While the package name is `databricks-langchain`, its components are integrated into LangChain's community modules and should be imported from `langchain_community`.","severity":"gotcha","affected_versions":"All versions >=0.1.0"},{"fix":"Use dedicated virtual environments for your projects. If conflicts arise, try to find compatible versions across all your LangChain-related dependencies or consider isolating conflicting parts of your application.","message":"Pydantic version conflicts are frequent within the LangChain ecosystem. `databricks-langchain` currently requires `pydantic<3`. If other libraries in your environment demand `pydantic>=2`, you may encounter dependency resolution issues.","severity":"gotcha","affected_versions":"All versions where `pydantic<2` or similar constraint is specified in `install_requires` (current: `<3`)."},{"fix":"Consult your Databricks workspace's serving endpoints configuration (e.g., through the UI or Databricks SDK) to confirm the exact names of available LLM deployments and ensure they are accessible from your execution environment.","message":"The `model` parameter for `ChatDatabricks` (and similar components) must refer to a valid and accessible LLM deployment within your Databricks workspace. Using an incorrect or unavailable model name will result in an API error.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}