DatabricksOpenAI: forward extra kwargs to OpenAI init#429
Merged
jennsun merged 5 commits intoMay 13, 2026
Conversation
Both DatabricksOpenAI and AsyncDatabricksOpenAI had closed init signatures, so ChatDatabricks(max_retries=..., timeout=...) crashed the moment .client or .async_client was constructed. The async path was broken since 0.15.0 (when async_client was introduced); 0.19.0 migrated the sync path onto the same wrapper and inherited the same bug. Add **kwargs to both wrappers and forward them through to super().__init__, so timeout, max_retries, default_headers, and other openai.OpenAI kwargs work as advertised in get_*_openai_client's docstring. Conflicts with the hardcoded api_key/http_client (which carry Databricks auth) surface as Python's native TypeError on duplicate kwargs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…st-direct CI resolves databricks-openai from PyPI at its floor pin (>=0.14.0), which predates the **kwargs fix in this PR. The openai-side test in integrations/openai/tests/unit_tests/test_clients.py already covers the regression at the layer where the bug actually lived. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jennsun
requested changes
May 11, 2026
Contributor
jennsun
left a comment
There was a problem hiding this comment.
functionality looks good, let's make sure we add coverage to api docs / tests with this new param we are supporting?
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Locks in the safety invariant that the new **kwargs surface cannot be used to override Databricks-managed auth. Python's native double-pass TypeError serves as the guardrail; this test asserts it stays that way. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jennsun
approved these changes
May 12, 2026
jennsun
reviewed
May 12, 2026
| **kwargs: Additional keyword arguments forwarded to the underlying ``openai.OpenAI`` | ||
| client (e.g. ``timeout``, ``max_retries``, ``default_headers``). ``api_key`` and | ||
| ``http_client`` are managed internally for Databricks authentication and cannot | ||
| be overridden. |
Contributor
There was a problem hiding this comment.
nit: remove comment
``api_key`` and
``http_client`` are managed internally for Databricks authentication and cannot
be overridden.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
**kwargstoDatabricksOpenAI.__init__andAsyncDatabricksOpenAI.__init__so callers can passtimeout,max_retries,default_headers, etc. through to the underlyingopenai.OpenAI/openai.AsyncOpenAI.ChatDatabricks(max_retries=...)raisesTypeErrorbecauseAsyncDatabricksOpenAI/DatabricksOpenAIreject kwargs #423 —ChatDatabricks(max_retries=...)raisedTypeErroron both.clientand.async_client. The async path has been broken sincedatabricks-langchain==0.15.0(whenasync_clientwas introduced); the sync path regressed in 0.19.0 whenChatDatabrickswas migrated ontoDatabricksOpenAIin Update ChatDatabricks to use DatabricksOpenAI #418.api_key/http_client(which carry Databricks auth) surface as Python's nativeTypeError: got multiple values for keyword argument 'api_key', so no custom validation is needed.Test plan
integrations/openai/tests/unit_tests/test_clients.pyverifies sync + async wrappers forwardtimeout/max_retries.https://dogfood.staging.databricks.com/editor/notebooks/278592140196282?o=6051921418418893#command/6233639109873383
https://dogfood.staging.databricks.com/editor/notebooks/278592140202289?o=6051921418418893#command/278592140202292
🤖 Generated with Claude Code