Skip to content

Commit b2f1fc8

Browse files
committed
fix(databricks): address PR review feedback
- Move Databricks scripts from packages/core/script/ to providers/databricks/scripts/ with their own package.json; remove @databricks/sdk-experimental from packages/core - Add Zod runtime validation to fetchFilteredGatewayRoutes (replaces unsafe cast) - Replace isOpenAIcompatible boolean with openAICompatiblePackages Set in schema.ts - Clarify provider.toml env comment with PAT vs OAuth M2M auth modes - Shorten dense root README.md entry to a one-liner linking to provider README - Add bun.lock to .gitignore - Add databricks-claude-opus-4-7 model TOML
1 parent ff0eca7 commit b2f1fc8

File tree

12 files changed

+81
-29
lines changed

12 files changed

+81
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ See existing providers in the `providers/` directory for reference:
186186
- `providers/anthropic/` - Anthropic Claude models
187187
- `providers/openai/` - OpenAI GPT models
188188
- `providers/google/` - Google Gemini models
189-
- `providers/databricks/` - Databricks Foundation Model APIs on **AI Gateway**: default **`mlflow/v1`** for chat and embeddings via **`@databricks/ai-sdk-provider`**; per-model **`[provider]`** for **Claude** (Anthropic Messages), **Gemini** (native API), and **OpenAI Responses**. See [providers/databricks/README.md](providers/databricks/README.md) for discovery, authentication, and validation scripts.
189+
- `providers/databricks/` - Databricks Foundation Model APIs via AI Gateway. See [providers/databricks/README.md](providers/databricks/README.md).
190190

191191
### Working on frontend
192192

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"private": true,
44
"workspaces": {
55
"packages": [
6-
"packages/*"
6+
"packages/*",
7+
"providers/databricks"
78
],
89
"catalog": {
910
"typescript": "5.8.2",
@@ -20,9 +21,9 @@
2021
"venice:generate": "bun ./packages/core/script/generate-venice.ts",
2122
"vercel:generate": "bun ./packages/core/script/generate-vercel.ts",
2223
"wandb:generate": "bun ./packages/core/script/generate-wandb.ts",
23-
"databricks:list-gateway": "bun ./packages/core/script/list-databricks-ai-gateway.ts",
24-
"databricks:test-inference": "bun ./packages/core/script/test-databricks.ts",
25-
"databricks:probe-capabilities": "bun ./packages/core/script/probe-databricks-capabilities.ts"
24+
"databricks:list-gateway": "bun ./providers/databricks/scripts/list-databricks-ai-gateway.ts",
25+
"databricks:test-inference": "bun ./providers/databricks/scripts/test-databricks.ts",
26+
"databricks:probe-capabilities": "bun ./providers/databricks/scripts/probe-databricks-capabilities.ts"
2627
},
2728
"dependencies": {
2829
"@cloudflare/workers-types": "^4.20250801.0",

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"$schema": "https://json.schemastore.org/package.json",
55
"type": "module",
66
"dependencies": {
7-
"@databricks/sdk-experimental": "^0.16.0",
87
"zod": "catalog:"
98
},
109
"main": "./src/index.ts",

packages/core/src/schema.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ export const Provider = z
147147
.refine(
148148
(data) => {
149149
const isOpenAI = data.npm === "@ai-sdk/openai";
150-
const isOpenAIcompatible =
151-
data.npm === "@ai-sdk/openai-compatible" ||
152-
data.npm === "@databricks/ai-sdk-provider";
150+
const openAICompatiblePackages = new Set([
151+
"@ai-sdk/openai-compatible",
152+
"@databricks/ai-sdk-provider",
153+
]);
154+
const isOpenAIcompatible = openAICompatiblePackages.has(data.npm);
153155
const isOpenrouter = data.npm === "@openrouter/ai-sdk-provider";
154156
const isAnthropic = data.npm === "@ai-sdk/anthropic";
155157
const hasApi = data.api !== undefined;
@@ -173,7 +175,7 @@ export const Provider = z
173175
},
174176
{
175177
message:
176-
"'api' is required for @ai-sdk/openai-compatible, @databricks/ai-sdk-provider, and openrouter; optional for anthropic and openai; forbidden otherwise",
178+
"'api' is required for openai-compatible packages and openrouter; optional for anthropic and openai; forbidden otherwise",
177179
path: ["api"],
178180
},
179181
);

providers/databricks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ cd packages/web && bun run build
203203
| `bun run databricks:test-inference -- --profile PROFILE` | Exercises each catalog route against AI Gateway (`--only`, `--delay-ms`, `--json` supported). |
204204

205205

206-
Scripts: `[list-databricks-ai-gateway.ts](../../packages/core/script/list-databricks-ai-gateway.ts)`, `[test-databricks.ts](../../packages/core/script/test-databricks.ts)`.
206+
Scripts: `[list-databricks-ai-gateway.ts](./scripts/list-databricks-ai-gateway.ts)`, `[test-databricks.ts](./scripts/test-databricks.ts)`.
207207

208208
---
209209

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name = "Databricks Claude Opus 4.7"
2+
family = "claude-opus"
3+
release_date = "2025-06-01"
4+
last_updated = "2026-04-20"
5+
attachment = true
6+
reasoning = true
7+
tool_call = true
8+
temperature = true
9+
open_weights = false
10+
11+
[limit]
12+
context = 200000
13+
output = 64000
14+
15+
[modalities]
16+
input = ["text", "image", "pdf"]
17+
output = ["text"]
18+
19+
[provider]
20+
npm = "@ai-sdk/anthropic"
21+
api = "https://<workspace-numeric-id>.ai-gateway.cloud.databricks.com/anthropic"

providers/databricks/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "models.dev-provider-databricks",
3+
"private": true,
4+
"type": "module",
5+
"devDependencies": {
6+
"@databricks/sdk-experimental": "^0.16.0",
7+
"@tsconfig/bun": "catalog:",
8+
"@types/bun": "catalog:",
9+
"@types/node": "catalog:",
10+
"zod": "catalog:"
11+
}
12+
}

providers/databricks/provider.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name = "Databricks"
2-
# Environment hints. Use the subset that matches each auth mode. Integrators substitute
3-
# <workspace-numeric-id> in `api` (or set baseURL after discovery—see README).
2+
# PAT auth: DATABRICKS_HOST + DATABRICKS_TOKEN
3+
# OAuth M2M: DATABRICKS_HOST + DATABRICKS_CLIENT_ID + DATABRICKS_CLIENT_SECRET
4+
# DATABRICKS_WORKSPACE_ID: only needed when constructing the AI Gateway URL manually (see README)
45
env = [
56
"DATABRICKS_HOST",
6-
"DATABRICKS_WORKSPACE_ID",
77
"DATABRICKS_TOKEN",
88
"DATABRICKS_CLIENT_ID",
99
"DATABRICKS_CLIENT_SECRET",
10+
"DATABRICKS_WORKSPACE_ID",
1011
]
1112
npm = "@databricks/ai-sdk-provider"
1213
api = "https://<workspace-numeric-id>.ai-gateway.cloud.databricks.com/mlflow/v1"

packages/core/script/databricks-ai-gateway-shared.ts renamed to providers/databricks/scripts/databricks-ai-gateway-shared.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
*/
44

55
import { WorkspaceClient } from "@databricks/sdk-experimental";
6+
import { z } from "zod";
67

7-
export interface Destination {
8-
name?: string;
9-
type?: string;
10-
}
8+
const DestinationSchema = z.object({
9+
name: z.string().optional(),
10+
type: z.string().optional(),
11+
});
1112

12-
export interface Endpoint {
13-
name?: string;
14-
ai_gateway_url?: string;
15-
config?: { destinations?: Destination[] };
16-
}
13+
const EndpointSchema = z.object({
14+
name: z.string().optional(),
15+
ai_gateway_url: z.string().optional(),
16+
config: z
17+
.object({
18+
destinations: z.array(DestinationSchema).optional(),
19+
})
20+
.optional(),
21+
});
1722

18-
export interface EndpointsResponse {
19-
endpoints?: Endpoint[];
20-
}
23+
const EndpointsResponseSchema = z.object({
24+
endpoints: z.array(EndpointSchema).optional(),
25+
});
26+
27+
export type Destination = z.infer<typeof DestinationSchema>;
28+
export type Endpoint = z.infer<typeof EndpointSchema>;
29+
export type EndpointsResponse = z.infer<typeof EndpointsResponseSchema>;
2130

2231
export interface FilteredGatewayRoute {
2332
gateway_name: string;
@@ -57,17 +66,24 @@ export function filterEndpoints(endpoints: Endpoint[]): FilteredGatewayRoute[] {
5766
export async function fetchFilteredGatewayRoutes(
5867
client: WorkspaceClient,
5968
): Promise<FilteredGatewayRoute[]> {
60-
const raw = (await client.apiClient.request(
69+
const raw = await client.apiClient.request(
6170
{
6271
path: "/api/ai-gateway/v2/endpoints",
6372
method: "GET",
6473
headers: new Headers(),
6574
raw: false,
6675
},
6776
undefined,
68-
)) as EndpointsResponse;
77+
);
78+
79+
const parsed = EndpointsResponseSchema.safeParse(raw);
80+
if (!parsed.success) {
81+
throw new Error(
82+
`Unexpected response shape from /api/ai-gateway/v2/endpoints: ${parsed.error.message}`,
83+
);
84+
}
6985

70-
return filterEndpoints(raw.endpoints ?? []);
86+
return filterEndpoints(parsed.data.endpoints ?? []);
7187
}
7288

7389
/** OpenAI-compatible base URL for chat/embeddings (no trailing slash). */

packages/core/script/list-databricks-ai-gateway.ts renamed to providers/databricks/scripts/list-databricks-ai-gateway.ts

File renamed without changes.

0 commit comments

Comments
 (0)