Databricks OpenAI Integration
The databricks-openai package provides seamless integration of Databricks AI features into OpenAI applications.
Installation
From PyPI
pip install databricks-openai
From Source
pip install git+https://git@github.com/databricks/databricks-ai-bridge.git#subdirectory=integrations/openai
Key Features
- Vector Search: Store and query vector representations using
VectorSearchRetrieverTool. - Sandbox: Run an OpenAI Agents SDK agent's shell and filesystem tools inside a Databricks sandbox with
DatabricksSandboxClient(installdatabricks-openai[sandbox]).
Getting Started
Use Vector Search on Databricks
# Step 1: call model with VectorSearchRetrieverTool defined
dbvs_tool = VectorSearchRetrieverTool(index_name="catalog.schema.my_index_name")
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{
"role": "user",
"content": "Using the Databricks documentation, answer what is Spark?"
}
]
first_response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=[dbvs_tool.tool]
)
# Step 2: Execute function code – parse the model's response and handle function calls.
tool_call = first_response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
result = dbvs_tool.execute(query=args["query"]) # For self-managed embeddings, optionally pass in openai_client=client
# Step 3: Supply model with results – so it can incorporate them into its final response.
messages.append(first_response.choices[0].message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps(result)
})
second_response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
tools=tools
)
Run an agent in a Databricks sandbox
Install the extra:
pip install databricks-openai[sandbox]
Register DatabricksSandboxClient as the sandbox backend on a RunConfig. The client provisions a Databricks sandbox when the run starts and tears it down when it finishes, so the agent's shell and filesystem tools execute inside the sandbox:
from agents.run_config import RunConfig, SandboxRunConfig
from databricks_openai import DatabricksSandboxClient, DatabricksSandboxClientOptions
run_config = RunConfig(
sandbox=SandboxRunConfig(
client=DatabricksSandboxClient(profile="DEFAULT"),
options=DatabricksSandboxClientOptions(),
)
)
# Pass run_config to your Runner, e.g. Runner.run(agent, input, run_config=run_config)
DatabricksSandboxClient(profile=...) builds a WorkspaceClient from the named Databricks CLI profile; to reuse an existing client, pass DatabricksSandboxClient(client=...) instead.
Contribution Guide
We welcome contributions! Please see our contribution guidelines for details.
Cross-version compatibility tests
The openai_cross_version_test CI job installs current core with an unchanged historical
OpenAI integration. It runs the maintained tests in tests/compatibility rather than the
historical release's tests, so the test harness uses the tracing API supported by current core.
The 24 cases cover retriever construction, resources, retrieval results, and persisted traces.
Resource expectations retain the differences between historical releases.
External services are mocked; MLflow writes traces to a temporary local store.
To reproduce from the repository root, with a historical checkout at older-version:
pip install . older-version/integrations/openai --group dev
pip check
pytest -c pyproject.toml integrations/openai/tests/compatibility
License
This project is licensed under the MIT License.
Thank you for using Databricks OpenAI!
Metadata
Release files for databricks-openai 0.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| databricks_openai-0.18.0.tar.gz | 25.7 kB | Without provenance | Details for databricks_openai-0.18.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| databricks_openai-0.18.0-py3-none-any.whl | Python 3 | none | any | Details for databricks_openai-0.18.0-py3-none-any.whl |
Total release size: 55.2 kB
Release files / databricks_openai-0.18.0.tar.gz
| Download URL | databricks_openai-0.18.0.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7385563310b8c75afaf38d59a5f242a5c58a6be7b43584166ad8804c83ff8f07
|
|
BLAKE2b-256 checksum How to use checksums |
b1f6a3ed7373de65d252e9882c84dc4aa3ed151d522e737dbf9a7124b464950f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / databricks_openai-0.18.0-py3-none-any.whl
| Download URL | databricks_openai-0.18.0-py3-none-any.whl |
|---|---|
| Size | 29.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9abba05559ba680c9f47b2ebdb9c9d4fd8e83cd28252b5edee040f25184a2cd5
|
|
BLAKE2b-256 checksum How to use checksums |
7feebb2ca1651e2f2db7b9d481a358be8cdb7f60e6a87215af3479419504e3c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for databricks-openai 0.18.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.