Skip to content

Deprecate WorkspaceClient().serving_endpoints.get_open_ai_client() and WorkspaceClient().serving_endpoints.get_langchain_chat_open_ai_client() methods#1238

Open
smurching wants to merge 9 commits intodatabricks:mainfrom
smurching:deprecate-openai-client-methods
Open

Deprecate WorkspaceClient().serving_endpoints.get_open_ai_client() and WorkspaceClient().serving_endpoints.get_langchain_chat_open_ai_client() methods#1238
smurching wants to merge 9 commits intodatabricks:mainfrom
smurching:deprecate-openai-client-methods

Conversation

@smurching
Copy link
Contributor

@smurching smurching commented Feb 1, 2026

Deprecate get_open_ai_client and get_langchain_chat_open_ai_client methods

These methods are now deprecated in favor of the databricks-openai and databricks-langchain package.

Instead of

pip install databricks-sdk[openai]

from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
client = w.serving_endpoints.get_open_ai_client()
response = client.chat.completions.create(model="databricks-claude-sonnet-4-5", ...)

We now recommend

pip install databricks-openai

from databricks_openai import DatabricksOpenAI # or AsyncDatabricksOpenAI
client = DatabricksOpenAI()
response = client.chat.completions.create(model="databricks-claude-sonnet-4-5", ...)                                                                             

What changes are proposed in this pull request?

WHAT:
This PR deprecates two OpenAI client helper methods in the Databricks SDK:

  1. ServingEndpointsExt.get_open_ai_client()
  2. ServingEndpointsExt.get_langchain_chat_open_ai_client()

The changes include:

  • Adding DeprecationWarning messages that are raised when either method is called, with clear instructions to migrate to the databricks-openai package
  • Updating docstrings with .. deprecated:: directives pointing users to the new package
  • Adding test coverage to verify the deprecation warnings are properly raised
  • The methods remain functional - this is a soft deprecation that warns users but doesn't break existing code

WHY:
These helper methods were originally added to the Databricks SDK to make it easier to use OpenAI-compatible clients with Databricks Model Serving. However,
maintaining OpenAI client integration directly in the SDK creates several issues:

  1. Tight coupling: The SDK shouldn't be tightly coupled to specific client libraries (OpenAI, LangChain) which have their own release cycles and breaking
    changes
  2. Feature richness: A dedicated package (databricks-openai) can provide more comprehensive OpenAI compatibility features without bloating the core SDK
  3. Maintenance burden: Separating concerns allows the OpenAI integration to evolve independently from the core SDK functionality
  4. Better user experience: The databricks-openai package provides a more standard OpenAI-compatible interface that users familiar with the OpenAI SDK will
    find more intuitive

By deprecating these methods now, we give users a clear migration path while maintaining backward compatibility. The deprecation warnings will appear in users'
logs, guiding them to adopt the better-maintained databricks-openai package.

How is this tested?

Unit tests:

  • Added test_get_open_ai_client_deprecation_warning() which verifies that calling get_open_ai_client() raises a DeprecationWarning with the correct
    message pointing to databricks-openai and DatabricksOpenAI
  • Added test_get_langchain_chat_open_ai_client_deprecation_warning() which verifies that calling get_langchain_chat_open_ai_client() raises a
    DeprecationWarning with the correct message pointing to AsyncDatabricksOpenAI. This test handles both cases where langchain_openai is installed and not
    installed.
  • Verified all existing tests still pass (with expected deprecation warnings now appearing in test output)

Manual verification:
All new tests pass locally:
pytest tests/test_open_ai_mixin.py::test_get_open_ai_client_deprecation_warning -v # PASSED
pytest tests/test_open_ai_mixin.py::test_get_langchain_chat_open_ai_client_deprecation_warning -v # PASSED

The deprecation warnings are correctly raised in all existing tests that use these methods, confirming the warnings will be visible to end users.

…thods

These methods are now deprecated in favor of the databricks-openai package.
Users should install databricks-openai and use:
- DatabricksOpenAI instead of get_open_ai_client()
- AsyncDatabricksOpenAI instead of get_langchain_chat_open_ai_client()

Changes:
- Added DeprecationWarning to both methods with clear migration instructions
- Added tests to verify deprecation warnings are raised correctly
- Updated docstrings with deprecation notices

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…cks_langchain

Changed the deprecation warning for get_langchain_chat_open_ai_client() to
recommend ChatDatabricks from databricks_langchain instead of
AsyncDatabricksOpenAI from databricks_openai, as ChatDatabricks is the
proper LangChain integration for Databricks.

Updated tests to verify the new deprecation message.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated both langchain tests to mock the langchain_openai module import,
preventing ImportError when the package is not installed. This allows the
tests to verify deprecation warnings and functionality without requiring
optional dependencies.

All tests now pass successfully.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
smurching and others added 2 commits February 1, 2026 17:30
Document the deprecation of get_open_ai_client() and
get_langchain_chat_open_ai_client() methods in NEXT_CHANGELOG.md.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
from IPython.core.display_functions import display
from ipywidgets.widgets import (ValueWidget, Widget, widget_box,
widget_selection, widget_string)
from ipywidgets.widgets import ValueWidget, Widget, widget_box, widget_selection, widget_string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo noop formatting change

from .deserializer import (_EmptyDeserializer, _ErrorDeserializer,
_HtmlErrorDeserializer, _StandardErrorDeserializer,
_StringErrorDeserializer)
from .deserializer import (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo noop formatting change in this file

from types import TracebackType
from typing import (TYPE_CHECKING, AnyStr, BinaryIO, Callable, Generator,
Iterable, Optional, Type, Union)
from typing import TYPE_CHECKING, AnyStr, BinaryIO, Callable, Generator, Iterable, Optional, Type, Union
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo noop formatting change

from databricks.sdk.service.serving import (ExternalFunctionRequestHttpMethod,
HttpRequestResponse,
ServingEndpointsAPI)
from databricks.sdk.service.serving import ExternalFunctionRequestHttpMethod, HttpRequestResponse, ServingEndpointsAPI
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo this noop formatting change

@smurching smurching force-pushed the deprecate-openai-client-methods branch from 9f0cf80 to 802e95c Compare February 2, 2026 17:20
Signed-off-by: Siddharth Murching <smurching@gmail.com>
Signed-off-by: Siddharth Murching <smurching@gmail.com>
warnings.warn(
"get_open_ai_client() is deprecated. Please install the databricks-openai package "
"and use 'from databricks_openai import DatabricksOpenAI' instead. "
"See https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_openai.html for more information.",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should probably also update databricks-openai homepage to include this as the first item

currently, https://api-docs.databricks.com/python/databricks-ai-bridge/latest/databricks_openai.html doesn't talk about our custom client

Copy link

@bbqiu bbqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Siddharth Murching <smurching@gmail.com>
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1238
  • Commit SHA: 76e1fbb2bb4a021a66460d5f8fa96a4d77c047ef

Checks will be approved automatically on success.

.. deprecated::
This method is deprecated. Please install the `databricks-openai` package
and use `from databricks_openai import DatabricksOpenAI` instead.
See https://pypi.org/project/databricks-openai/ for more information.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we link to the same thing in the warning message / docstring?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants