@databricks/ai-sdk-provider 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,69 @@
1
+ Databricks License
2
+ Copyright (2024) Databricks, Inc.
3
+
4
+ Definitions.
5
+
6
+ Agreement: The agreement between Databricks, Inc., and you governing
7
+ the use of the Databricks Services, as that term is defined in
8
+ the Master Cloud Services Agreement (MCSA) located at
9
+ www.databricks.com/legal/mcsa.
10
+
11
+ Licensed Materials: The source code, object code, data, and/or other
12
+ works to which this license applies.
13
+
14
+ Scope of Use. You may not use the Licensed Materials except in
15
+ connection with your use of the Databricks Services pursuant to
16
+ the Agreement. Your use of the Licensed Materials must comply at all
17
+ times with any restrictions applicable to the Databricks Services,
18
+ generally, and must be used in accordance with any applicable
19
+ documentation. You may view, use, copy, modify, publish, and/or
20
+ distribute the Licensed Materials solely for the purposes of using
21
+ the Licensed Materials within or connecting to the Databricks Services.
22
+ If you do not agree to these terms, you may not view, use, copy,
23
+ modify, publish, and/or distribute the Licensed Materials.
24
+
25
+ Redistribution. You may redistribute and sublicense the Licensed
26
+ Materials so long as all use is in compliance with these terms.
27
+ In addition:
28
+
29
+ - You must give any other recipients a copy of this License;
30
+ - You must cause any modified files to carry prominent notices
31
+ stating that you changed the files;
32
+ - You must retain, in any derivative works that you distribute,
33
+ all copyright, patent, trademark, and attribution notices,
34
+ excluding those notices that do not pertain to any part of
35
+ the derivative works; and
36
+ - If a "NOTICE" text file is provided as part of its
37
+ distribution, then any derivative works that you distribute
38
+ must include a readable copy of the attribution notices
39
+ contained within such NOTICE file, excluding those notices
40
+ that do not pertain to any part of the derivative works.
41
+
42
+ You may add your own copyright statement to your modifications and may
43
+ provide additional license terms and conditions for use, reproduction,
44
+ or distribution of your modifications, or for any such derivative works
45
+ as a whole, provided your use, reproduction, and distribution of
46
+ the Licensed Materials otherwise complies with the conditions stated
47
+ in this License.
48
+
49
+ Termination. This license terminates automatically upon your breach of
50
+ these terms or upon the termination of your Agreement. Additionally,
51
+ Databricks may terminate this license at any time on notice. Upon
52
+ termination, you must permanently delete the Licensed Materials and
53
+ all copies thereof.
54
+
55
+ DISCLAIMER; LIMITATION OF LIABILITY.
56
+
57
+ THE LICENSED MATERIALS ARE PROVIDED "AS-IS" AND WITH ALL FAULTS.
58
+ DATABRICKS, ON BEHALF OF ITSELF AND ITS LICENSORS, SPECIFICALLY
59
+ DISCLAIMS ALL WARRANTIES RELATING TO THE LICENSED MATERIALS, EXPRESS
60
+ AND IMPLIED, INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES,
61
+ CONDITIONS AND OTHER TERMS OF MERCHANTABILITY, SATISFACTORY QUALITY OR
62
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. DATABRICKS AND
63
+ ITS LICENSORS TOTAL AGGREGATE LIABILITY RELATING TO OR ARISING OUT OF
64
+ YOUR USE OF OR DATABRICKS' PROVISIONING OF THE LICENSED MATERIALS SHALL
65
+ BE LIMITED TO ONE THOUSAND ($1,000) DOLLARS. IN NO EVENT SHALL
66
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
67
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
68
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE LICENSED MATERIALS OR
69
+ THE USE OR OTHER DEALINGS IN THE LICENSED MATERIALS.
package/NOTICE ADDED
@@ -0,0 +1,16 @@
1
+ Copyright (2025) Databricks, Inc.
2
+
3
+ This Software includes software developed at Databricks and its use is subject to the included LICENSE file.
4
+
5
+ ________________
6
+ This Software contains code from the following open source projects, licensed under the Apache 2.0 license (Apache License, Version 2.0):
7
+
8
+ vercel/ai - https://github.com/vercel/ai
9
+ Copyright 2023 Vercel, Inc.
10
+
11
+ ________________
12
+ This Software contains code from the following open source projects, licensed under the MIT license (The MIT License):
13
+
14
+ colinhacks/zod - https://github.com/colinhacks/zod
15
+ Copyright (c) 2025 Colin McDonnell
16
+
package/README.md CHANGED
@@ -1,3 +1,169 @@
1
1
  # @databricks/ai-sdk-provider
2
2
 
3
- Placeholder package - reserved for Databricks AI SDK Provider.
3
+ Databricks provider for the [Vercel AI SDK](https://sdk.vercel.ai/docs).
4
+
5
+ ## Features
6
+
7
+ - 🚀 Support for three Databricks endpoint types:
8
+ - **Chat Agent** (`agent/v2/chat`) - Databricks chat agent API
9
+ - **Responses Agent** (`agent/v2/responses`) - Databricks responses agent API
10
+ - **FM API** (`llm/v1/chat`) - Foundation model chat completions API
11
+ - 🔄 Stream and non-stream (generate) support for all endpoint types
12
+ - 🛠️ Custom tool calling mechanism for Databricks agents
13
+ - 🔐 Flexible authentication (bring your own tokens/headers)
14
+ - 🎯 Full TypeScript support
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @databricks/ai-sdk-provider
20
+ ```
21
+
22
+ ## Peer Dependencies
23
+
24
+ This package requires the following peer dependencies:
25
+
26
+ ```bash
27
+ npm install @ai-sdk/provider @ai-sdk/provider-utils
28
+ ```
29
+
30
+ To use the provider with AI SDK functions like `generateText` or `streamText`, also install:
31
+
32
+ ```bash
33
+ npm install ai
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```typescript
39
+ import { createDatabricksProvider } from '@databricks/ai-sdk-provider'
40
+ import { generateText } from 'ai'
41
+
42
+ // Create provider with your workspace URL and authentication
43
+ const provider = createDatabricksProvider({
44
+ baseURL: 'https://your-workspace.databricks.com/serving-endpoints',
45
+ headers: {
46
+ Authorization: `Bearer ${token}`,
47
+ },
48
+ })
49
+
50
+ // Use the Chat Agent endpoint
51
+ const responsesAgent = provider.responsesAgent('your-agent-endpoint')
52
+
53
+ const result = await generateText({
54
+ model: responsesAgent,
55
+ prompt: 'Hello, how are you?',
56
+ })
57
+
58
+ console.log(result.text)
59
+ ```
60
+
61
+ ## Authentication
62
+
63
+ The provider requires you to pass authentication headers:
64
+
65
+ ```typescript
66
+ const provider = createDatabricksProvider({
67
+ baseURL: 'https://your-workspace.databricks.com/serving-endpoints',
68
+ headers: {
69
+ Authorization: `Bearer ${token}`,
70
+ },
71
+ })
72
+ ```
73
+
74
+ ## API Reference
75
+
76
+ ### Main Export
77
+
78
+ #### `createDatabricksProvider(settings)`
79
+
80
+ Creates a Databricks provider instance.
81
+
82
+ **Parameters:**
83
+
84
+ - `settings.baseURL` (string, required): Base URL for the Databricks API calls
85
+ - `settings.headers` (object, optional): Custom headers to include in requests
86
+ - `settings.provider` (string, optional): Provider name (defaults to "databricks")
87
+ - `settings.fetch` (function, optional): Custom fetch implementation
88
+ - `settings.formatUrl` (function, optional): Optional function to format the URL
89
+
90
+ **Returns:** `DatabricksProvider` with three model creation methods:
91
+
92
+ - `chatAgent(modelId: string)`: Create a Chat Agent model
93
+ - `responsesAgent(modelId: string)`: Create a Responses Agent model
94
+ - `fmapi(modelId: string)`: Create an FM API model
95
+
96
+ ### Tool Constants
97
+
98
+ ```typescript
99
+ import { DATABRICKS_TOOL_DEFINITION, DATABRICKS_TOOL_CALL_ID } from '@databricks/ai-sdk-provider'
100
+ ```
101
+
102
+ #### Why are these needed?
103
+
104
+ The AI SDK requires tools to be defined ahead of time with known schemas. However, Databricks agents can orchestrate tools dynamically at runtime - we don't know which tools will be called until the model executes.
105
+
106
+ To bridge this gap, this provider uses a special "catch-all" tool definition:
107
+
108
+ - **`DATABRICKS_TOOL_DEFINITION`**: A universal tool definition that accepts any input/output schema. This allows the provider to handle any tool that Databricks agents orchestrate, regardless of its schema.
109
+
110
+ - **`DATABRICKS_TOOL_CALL_ID`**: The constant ID (`'databricks-tool-call'`) used to identify this special tool. The actual tool name from Databricks is preserved in the metadata so it can be displayed correctly in the UI and passed back to the model.
111
+
112
+ This pattern enables dynamic tool orchestration by Databricks while maintaining compatibility with the AI SDK's tool interface.
113
+
114
+ ### MCP Utilities
115
+
116
+ ```typescript
117
+ import {
118
+ MCP_APPROVAL_STATUS_KEY,
119
+ MCP_APPROVAL_REQUEST_TYPE,
120
+ MCP_APPROVAL_RESPONSE_TYPE,
121
+ isMcpApprovalRequest,
122
+ isMcpApprovalResponse,
123
+ createApprovalStatusOutput,
124
+ getMcpApprovalState,
125
+ } from '@databricks/ai-sdk-provider'
126
+ ```
127
+
128
+ MCP (Model Context Protocol) approval utilities for handling approval workflows.
129
+
130
+ ## Examples
131
+
132
+ ### Responses Agent Endpoint
133
+
134
+ ```typescript
135
+ const responsesAgent = provider.responsesAgent('my-responses-agent')
136
+
137
+ const result = await generateText({
138
+ model: responsesAgent,
139
+ prompt: 'Analyze this data...',
140
+ })
141
+
142
+ console.log(result.text)
143
+ ```
144
+
145
+ ### With Tool Calling
146
+
147
+ ```typescript
148
+ import { DATABRICKS_TOOL_CALL_ID, DATABRICKS_TOOL_DEFINITION } from '@databricks/ai-sdk-provider'
149
+
150
+ const responsesAgent = provider.responsesAgent('my-agent-with-tools')
151
+
152
+ const result = await generateText({
153
+ model: responsesAgent,
154
+ prompt: 'Search for information about AI',
155
+ tools: {
156
+ [DATABRICKS_TOOL_CALL_ID]: DATABRICKS_TOOL_DEFINITION,
157
+ },
158
+ })
159
+ ```
160
+
161
+ ## Links
162
+
163
+ - [Vercel AI SDK Documentation](https://sdk.vercel.ai/docs)
164
+ - [Databricks Documentation](https://docs.databricks.com/)
165
+ - [GitHub Repository](https://github.com/databricks/databricks-ai-bridge)
166
+
167
+ ## Contributing
168
+
169
+ This package is part of the [databricks-ai-bridge](https://github.com/databricks/databricks-ai-bridge) monorepo.