Commit 536d45c
Deprecate WorkspaceClient().serving_endpoints.get_open_ai_client() and WorkspaceClient().serving_endpoints.get_langchain_chat_open_ai_client() methods (#1238)
# 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.
---------
Signed-off-by: Siddharth Murching <smurching@gmail.com>
Signed-off-by: Sid Murching <sid.murching@databricks.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 50a5b40 commit 536d45c
File tree
3 files changed
+124
-4
lines changed- databricks/sdk/mixins
- tests
3 files changed
+124
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
| |||
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
69 | 82 | | |
70 | 83 | | |
71 | 84 | | |
| |||
95 | 108 | | |
96 | 109 | | |
97 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
98 | 125 | | |
99 | 126 | | |
100 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
89 | | - | |
90 | 91 | | |
91 | | - | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
93 | 115 | | |
94 | 116 | | |
95 | 117 | | |
| |||
115 | 137 | | |
116 | 138 | | |
117 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
0 commit comments