Skip to main content

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.

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
)

Contribution Guide

We welcome contributions! Please see our contribution guidelines for details.

License

This project is licensed under the MIT License.

Thank you for using Databricks OpenAI!

Metadata

Release files for databricks-openai 0.17.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for databricks-openai 0.17.1
File Size Uploaded
databricks_openai-0.17.1.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for databricks-openai 0.17.1
File Interpreter ABI Platform
databricks_openai-0.17.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / databricks_openai-0.17.1.tar.gz

Download URL databricks_openai-0.17.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
539ed84c1131a807c21e1eb3f0f6eb40ca980dfb78dafd1519f5001e14ba77e0
BLAKE2b-256 checksum
How to use checksums
8e4d117348a87bb22ba87f24605f7195ed9515f0ef7405fe7a5d4ea0371d9f7d
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.17.1-py3-none-any.whl

Download URL databricks_openai-0.17.1-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29b98f04984f800c44e4351c19fbd87e5c07a374f9dfda4def1dff2f2d3b3c69
BLAKE2b-256 checksum
How to use checksums
bb773b52ae812ea11bb072def2c96b9159fe203f7cbd3e2fe56809d1588a70fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.17.1 This release

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page