@ai-sdk/baseten 2.1.37 → 2.1.39

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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ai-sdk/baseten
2
2
 
3
+ ## 2.1.39
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8c65988]
8
+ - Updated dependencies [527a163]
9
+ - @ai-sdk/provider@4.0.21
10
+ - @ai-sdk/provider-utils@5.0.53
11
+ - @ai-sdk/openai-compatible@3.0.61
12
+
13
+ ## 2.1.38
14
+
15
+ ### Patch Changes
16
+
17
+ - ede5b89: chore: migrate package builds from tsup to tsdown
18
+ - Updated dependencies [ede5b89]
19
+ - @ai-sdk/openai-compatible@3.0.60
20
+ - @ai-sdk/provider@4.0.20
21
+ - @ai-sdk/provider-utils@5.0.52
22
+
3
23
  ## 2.1.37
4
24
 
5
25
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,105 +1,109 @@
1
- import { ProviderV4, LanguageModelV4, EmbeddingModelV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
1
+ import { EmbeddingModelV4, LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
2
+ import { FetchFunction } from "@ai-sdk/provider-utils";
3
+ import { z } from "zod/v4";
4
+ //#region src/baseten-chat-options.d.ts
5
5
  type BasetenChatModelId = 'deepseek-ai/DeepSeek-R1-0528' | 'deepseek-ai/DeepSeek-V3-0324' | 'deepseek-ai/DeepSeek-V3.1' | 'moonshotai/Kimi-K2-Instruct-0905' | 'moonshotai/Kimi-K2-Thinking' | 'Qwen/Qwen3-235B-A22B-Instruct-2507' | 'Qwen/Qwen3-Coder-480B-A35B-Instruct' | 'openai/gpt-oss-120b' | 'zai-org/GLM-4.6' | 'zai-org/GLM-4.7' | (string & {});
6
-
6
+ //#endregion
7
+ //#region src/baseten-embedding-options.d.ts
7
8
  type BasetenEmbeddingModelId = string & {};
8
9
  declare const basetenEmbeddingModelOptions: z.ZodObject<{}, z.core.$strip>;
9
10
  type BasetenEmbeddingModelOptions = z.infer<typeof basetenEmbeddingModelOptions>;
10
-
11
+ //#endregion
12
+ //#region src/baseten-provider.d.ts
11
13
  /**
12
14
  * The part of `@basetenlabs/performance-client` we use, declared structurally to
13
15
  * keep that native addon out of our dependency and type graph.
14
16
  */
15
17
  type BasetenPerformanceClient = {
16
- embed(input: string[], model: string): Promise<{
17
- data: {
18
- embedding: number[];
19
- }[];
20
- usage?: {
21
- total_tokens?: number;
22
- };
23
- }>;
18
+ embed(input: string[], model: string): Promise<{
19
+ data: {
20
+ embedding: number[];
21
+ }[];
22
+ usage?: {
23
+ total_tokens?: number;
24
+ };
25
+ }>;
24
26
  };
25
27
  type BasetenPerformanceClientConstructor = new (baseUrl: string, apiKey?: string) => BasetenPerformanceClient;
26
28
  type BasetenErrorData = z.infer<typeof basetenErrorSchema>;
27
29
  declare const basetenErrorSchema: z.ZodObject<{
28
- error: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
- message: z.ZodString;
30
- object: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
- type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
- param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
33
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
34
- }, z.core.$strip>]>;
30
+ error: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
31
+ message: z.ZodString;
32
+ object: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
35
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
36
+ }, z.core.$strip>]>;
35
37
  }, z.core.$strip>;
36
38
  interface BasetenProviderSettings {
37
- /**
38
- * Baseten API key. Default value is taken from the `BASETEN_API_KEY`
39
- * environment variable.
40
- */
41
- apiKey?: string;
42
- /**
43
- * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'
44
- */
45
- baseURL?: string;
46
- /**
47
- * Model URL for custom models (chat or embeddings).
48
- * If not supplied, the default Model APIs will be used.
49
- */
50
- modelURL?: string;
51
- /**
52
- * Custom headers to include in the requests.
53
- */
54
- headers?: Record<string, string>;
55
- /**
56
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
57
- * or to provide a custom fetch implementation for e.g. testing.
58
- */
59
- fetch?: FetchFunction;
60
- /**
61
- * Opt in to Baseten's native performance client for embeddings, for
62
- * client-side batching and request hedging. Pass the `PerformanceClient`
63
- * constructor from `@basetenlabs/performance-client`, which you install
64
- * yourself:
65
- *
66
- * ```ts
67
- * import { PerformanceClient } from '@basetenlabs/performance-client';
68
- *
69
- * const baseten = createBaseten({ modelURL, performanceClient: PerformanceClient });
70
- * ```
71
- *
72
- * When omitted, embeddings go over plain HTTP to Baseten's OpenAI-compatible
73
- * endpoint — the default, since this NAPI addon cannot load in edge runtimes
74
- * and bundlers cannot resolve its platform binaries.
75
- */
76
- performanceClient?: BasetenPerformanceClientConstructor;
39
+ /**
40
+ * Baseten API key. Default value is taken from the `BASETEN_API_KEY`
41
+ * environment variable.
42
+ */
43
+ apiKey?: string;
44
+ /**
45
+ * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'
46
+ */
47
+ baseURL?: string;
48
+ /**
49
+ * Model URL for custom models (chat or embeddings).
50
+ * If not supplied, the default Model APIs will be used.
51
+ */
52
+ modelURL?: string;
53
+ /**
54
+ * Custom headers to include in the requests.
55
+ */
56
+ headers?: Record<string, string>;
57
+ /**
58
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
59
+ * or to provide a custom fetch implementation for e.g. testing.
60
+ */
61
+ fetch?: FetchFunction;
62
+ /**
63
+ * Opt in to Baseten's native performance client for embeddings, for
64
+ * client-side batching and request hedging. Pass the `PerformanceClient`
65
+ * constructor from `@basetenlabs/performance-client`, which you install
66
+ * yourself:
67
+ *
68
+ * ```ts
69
+ * import { PerformanceClient } from '@basetenlabs/performance-client';
70
+ *
71
+ * const baseten = createBaseten({ modelURL, performanceClient: PerformanceClient });
72
+ * ```
73
+ *
74
+ * When omitted, embeddings go over plain HTTP to Baseten's OpenAI-compatible
75
+ * endpoint — the default, since this NAPI addon cannot load in edge runtimes
76
+ * and bundlers cannot resolve its platform binaries.
77
+ */
78
+ performanceClient?: BasetenPerformanceClientConstructor;
77
79
  }
78
80
  interface BasetenProvider extends ProviderV4 {
79
- /**
80
- * Creates a chat model for text generation.
81
- */
82
- (modelId?: BasetenChatModelId): LanguageModelV4;
83
- /**
84
- * Creates a chat model for text generation.
85
- */
86
- chatModel(modelId?: BasetenChatModelId): LanguageModelV4;
87
- /**
88
- * Creates a language model for text generation. Alias for chatModel.
89
- */
90
- languageModel(modelId?: BasetenChatModelId): LanguageModelV4;
91
- /**
92
- * Creates a embedding model for text generation.
93
- */
94
- embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
95
- /**
96
- * @deprecated Use `embeddingModel` instead.
97
- */
98
- textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
81
+ /**
82
+ * Creates a chat model for text generation.
83
+ */
84
+ (modelId?: BasetenChatModelId): LanguageModelV4;
85
+ /**
86
+ * Creates a chat model for text generation.
87
+ */
88
+ chatModel(modelId?: BasetenChatModelId): LanguageModelV4;
89
+ /**
90
+ * Creates a language model for text generation. Alias for chatModel.
91
+ */
92
+ languageModel(modelId?: BasetenChatModelId): LanguageModelV4;
93
+ /**
94
+ * Creates a embedding model for text generation.
95
+ */
96
+ embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
97
+ /**
98
+ * @deprecated Use `embeddingModel` instead.
99
+ */
100
+ textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;
99
101
  }
100
- declare function createBaseten(options?: BasetenProviderSettings): BasetenProvider;
101
- declare const baseten: BasetenProvider;
102
-
103
- declare const VERSION: string;
104
-
105
- export { type BasetenChatModelId, type BasetenEmbeddingModelOptions, type BasetenErrorData, type BasetenPerformanceClient, type BasetenPerformanceClientConstructor, type BasetenProvider, type BasetenProviderSettings, VERSION, baseten, createBaseten };
102
+ export declare function createBaseten(options?: BasetenProviderSettings): BasetenProvider;
103
+ export declare const baseten: BasetenProvider;
104
+ //#endregion
105
+ //#region src/version.d.ts
106
+ export declare const VERSION: string;
107
+ //#endregion
108
+ export type { BasetenChatModelId, BasetenEmbeddingModelOptions, BasetenErrorData, BasetenPerformanceClient, BasetenPerformanceClientConstructor, BasetenProvider, BasetenProviderSettings };
109
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/baseten-chat-options.ts","../src/baseten-embedding-options.ts","../src/baseten-provider.ts","../src/version.ts"],"mappings":";;;;KAGY;;;KCEA;cAEC,8BAA4B,EAAA,cAAA,EAAA,KAAA;KAE7B,+BAA+B,EAAE,aACpC;;;;;;;KCwBG;EACV,MACE,iBACA,gBACC;IACD;MAAQ;;IACR;MAAU;;;;KAIF,2CACV,iBACA,oBACG;KAEO,mBAAmB,EAAE,aAAa;cAOxC,oBAAkB,EAAA;;;;;;;;GAWtB,EAAA,KAAA;UAQe;;;;;EAKf;;;;EAKA;;;;;EAMA;;;;EAIA,UAAU;;;;;EAMV,QAAQ;;;;;;;;;;;;;;;;;EAkBR,oBAAoB;;UAGL,wBAAwB;;;;GAItC,UAAU,qBAAqB;;;;EAKhC,UAAU,UAAU,qBAAqB;;;;EAKzC,cAAc,UAAU,qBAAqB;;;;EAK7C,eAAe,UAAU,0BAA0B;;;;EAKnD,mBAAmB,UAAU,0BAA0B;;wBAMzC,cACd,UAAS,0BACR;qBAsJU,SAAO;;;qBC9SP"}
package/dist/index.js CHANGED
@@ -1,154 +1,112 @@
1
- // src/baseten-provider.ts
2
- import {
3
- OpenAICompatibleChatLanguageModel,
4
- OpenAICompatibleEmbeddingModel
5
- } from "@ai-sdk/openai-compatible";
6
- import {
7
- NoSuchModelError
8
- } from "@ai-sdk/provider";
9
- import {
10
- loadApiKey,
11
- withoutTrailingSlash,
12
- withUserAgentSuffix
13
- } from "@ai-sdk/provider-utils";
1
+ import { OpenAICompatibleChatLanguageModel, OpenAICompatibleEmbeddingModel } from "@ai-sdk/openai-compatible";
2
+ import { NoSuchModelError } from "@ai-sdk/provider";
3
+ import { loadApiKey, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
14
4
  import { z } from "zod/v4";
15
-
16
- // src/version.ts
17
- var VERSION = true ? "2.1.37" : "0.0.0-test";
18
-
19
- // src/baseten-provider.ts
20
- var MAX_EMBEDDINGS_PER_CALL = 128;
21
- var basetenErrorSchema = z.object({
22
- error: z.union([
23
- z.string(),
24
- z.object({
25
- message: z.string(),
26
- object: z.string().nullish(),
27
- type: z.string().nullish(),
28
- param: z.any().nullish(),
29
- code: z.union([z.string(), z.number()]).nullish()
30
- })
31
- ])
32
- });
33
- var basetenErrorStructure = {
34
- errorSchema: basetenErrorSchema,
35
- errorToMessage: (data) => typeof data.error === "string" ? data.error : data.error.message
5
+ //#region src/version.ts
6
+ const VERSION = "2.1.39";
7
+ //#endregion
8
+ //#region src/baseten-provider.ts
9
+ /**
10
+ * Baseten's per-request embedding input limit: larger batches are rejected with
11
+ * `413 batch size N > maximum allowed batch size 128`. It is also the native
12
+ * performance client's own default `batchSize`. `embedMany` splits larger
13
+ * inputs into chunks of this size and runs them in parallel.
14
+ */
15
+ const MAX_EMBEDDINGS_PER_CALL = 128;
16
+ const basetenErrorStructure = {
17
+ errorSchema: z.object({ error: z.union([z.string(), z.object({
18
+ message: z.string(),
19
+ object: z.string().nullish(),
20
+ type: z.string().nullish(),
21
+ param: z.any().nullish(),
22
+ code: z.union([z.string(), z.number()]).nullish()
23
+ })]) }),
24
+ errorToMessage: (data) => typeof data.error === "string" ? data.error : data.error.message
36
25
  };
37
- var defaultBaseURL = "https://inference.baseten.co/v1";
26
+ const defaultBaseURL = "https://inference.baseten.co/v1";
38
27
  function createBaseten(options = {}) {
39
- const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);
40
- const getHeaders = () => withUserAgentSuffix(
41
- {
42
- Authorization: `Bearer ${loadApiKey({
43
- apiKey: options.apiKey,
44
- environmentVariableName: "BASETEN_API_KEY",
45
- description: "Baseten API key"
46
- })}`,
47
- ...options.headers
48
- },
49
- `ai-sdk-baseten/${VERSION}`
50
- );
51
- const getCommonModelConfig = (modelType, customURL) => ({
52
- provider: `baseten.${modelType}`,
53
- url: ({ path }) => {
54
- if (modelType === "embedding" && customURL?.includes("/sync") && !customURL?.includes("/sync/v1")) {
55
- return `${customURL}/v1${path}`;
56
- }
57
- return `${customURL || baseURL}${path}`;
58
- },
59
- headers: getHeaders,
60
- fetch: options.fetch
61
- });
62
- const createChatModel = (modelId) => {
63
- const customURL = options.modelURL;
64
- if (customURL) {
65
- if (customURL.includes("/sync/v1")) {
66
- return new OpenAICompatibleChatLanguageModel(modelId ?? "placeholder", {
67
- ...getCommonModelConfig("chat", customURL),
68
- errorStructure: basetenErrorStructure,
69
- // Or stream_options.include_usage is omitted and streams report no usage.
70
- includeUsage: true,
71
- supportsStructuredOutputs: true
72
- });
73
- } else if (customURL.includes("/predict")) {
74
- throw new Error(
75
- "Not supported. You must use a /sync/v1 endpoint for chat models."
76
- );
77
- }
78
- }
79
- return new OpenAICompatibleChatLanguageModel(modelId ?? "chat", {
80
- ...getCommonModelConfig("chat"),
81
- errorStructure: basetenErrorStructure,
82
- includeUsage: true,
83
- supportsStructuredOutputs: true
84
- });
85
- };
86
- const createEmbeddingModel = (modelId) => {
87
- const customURL = options.modelURL;
88
- if (!customURL) {
89
- throw new Error(
90
- "No model URL provided for embeddings. Please set modelURL option for embeddings."
91
- );
92
- }
93
- if (!customURL.includes("/sync")) {
94
- throw new Error(
95
- "Not supported. You must use a /sync or /sync/v1 endpoint for embeddings."
96
- );
97
- }
98
- const model = new OpenAICompatibleEmbeddingModel(modelId ?? "embeddings", {
99
- ...getCommonModelConfig("embedding", customURL),
100
- errorStructure: basetenErrorStructure,
101
- // Over HTTP, cap each request and let `embedMany` split and parallelise.
102
- // The native client does its own batching, so let it take everything at
103
- // once — `embedMany` treats Infinity as "one call".
104
- maxEmbeddingsPerCall: options.performanceClient ? Number.POSITIVE_INFINITY : MAX_EMBEDDINGS_PER_CALL
105
- });
106
- if (!options.performanceClient) {
107
- return model;
108
- }
109
- const performanceClient = new options.performanceClient(
110
- customURL.replace("/sync/v1", "/sync"),
111
- loadApiKey({
112
- apiKey: options.apiKey,
113
- environmentVariableName: "BASETEN_API_KEY",
114
- description: "Baseten API key"
115
- })
116
- );
117
- model.doEmbed = async (params) => {
118
- if (!params.values || !Array.isArray(params.values)) {
119
- throw new Error("params.values must be an array of strings");
120
- }
121
- const response = await performanceClient.embed(
122
- params.values,
123
- // model_id is for Model APIs; dedicated deployments ignore it.
124
- modelId ?? "embeddings"
125
- );
126
- return {
127
- embeddings: response.data.map((item) => item.embedding),
128
- // The native client types its response as `any`; only report usage when
129
- // a token count is actually present rather than `{ tokens: undefined }`.
130
- usage: typeof response.usage?.total_tokens === "number" ? { tokens: response.usage.total_tokens } : void 0,
131
- response: { headers: {}, body: response },
132
- warnings: []
133
- };
134
- };
135
- return model;
136
- };
137
- const provider = (modelId) => createChatModel(modelId);
138
- provider.specificationVersion = "v4";
139
- provider.chatModel = createChatModel;
140
- provider.languageModel = createChatModel;
141
- provider.imageModel = (modelId) => {
142
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
143
- };
144
- provider.embeddingModel = createEmbeddingModel;
145
- provider.textEmbeddingModel = createEmbeddingModel;
146
- return provider;
28
+ const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);
29
+ const getHeaders = () => withUserAgentSuffix({
30
+ Authorization: `Bearer ${loadApiKey({
31
+ apiKey: options.apiKey,
32
+ environmentVariableName: "BASETEN_API_KEY",
33
+ description: "Baseten API key"
34
+ })}`,
35
+ ...options.headers
36
+ }, `ai-sdk-baseten/${VERSION}`);
37
+ const getCommonModelConfig = (modelType, customURL) => ({
38
+ provider: `baseten.${modelType}`,
39
+ url: ({ path }) => {
40
+ if (modelType === "embedding" && customURL?.includes("/sync") && !customURL?.includes("/sync/v1")) return `${customURL}/v1${path}`;
41
+ return `${customURL || baseURL}${path}`;
42
+ },
43
+ headers: getHeaders,
44
+ fetch: options.fetch
45
+ });
46
+ const createChatModel = (modelId) => {
47
+ const customURL = options.modelURL;
48
+ if (customURL) {
49
+ if (customURL.includes("/sync/v1")) return new OpenAICompatibleChatLanguageModel(modelId ?? "placeholder", {
50
+ ...getCommonModelConfig("chat", customURL),
51
+ errorStructure: basetenErrorStructure,
52
+ includeUsage: true,
53
+ supportsStructuredOutputs: true
54
+ });
55
+ else if (customURL.includes("/predict")) throw new Error("Not supported. You must use a /sync/v1 endpoint for chat models.");
56
+ }
57
+ return new OpenAICompatibleChatLanguageModel(modelId ?? "chat", {
58
+ ...getCommonModelConfig("chat"),
59
+ errorStructure: basetenErrorStructure,
60
+ includeUsage: true,
61
+ supportsStructuredOutputs: true
62
+ });
63
+ };
64
+ const createEmbeddingModel = (modelId) => {
65
+ const customURL = options.modelURL;
66
+ if (!customURL) throw new Error("No model URL provided for embeddings. Please set modelURL option for embeddings.");
67
+ if (!customURL.includes("/sync")) throw new Error("Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.");
68
+ const model = new OpenAICompatibleEmbeddingModel(modelId ?? "embeddings", {
69
+ ...getCommonModelConfig("embedding", customURL),
70
+ errorStructure: basetenErrorStructure,
71
+ maxEmbeddingsPerCall: options.performanceClient ? Number.POSITIVE_INFINITY : MAX_EMBEDDINGS_PER_CALL
72
+ });
73
+ if (!options.performanceClient) return model;
74
+ const performanceClient = new options.performanceClient(customURL.replace("/sync/v1", "/sync"), loadApiKey({
75
+ apiKey: options.apiKey,
76
+ environmentVariableName: "BASETEN_API_KEY",
77
+ description: "Baseten API key"
78
+ }));
79
+ model.doEmbed = async (params) => {
80
+ if (!params.values || !Array.isArray(params.values)) throw new Error("params.values must be an array of strings");
81
+ const response = await performanceClient.embed(params.values, modelId ?? "embeddings");
82
+ return {
83
+ embeddings: response.data.map((item) => item.embedding),
84
+ usage: typeof response.usage?.total_tokens === "number" ? { tokens: response.usage.total_tokens } : void 0,
85
+ response: {
86
+ headers: {},
87
+ body: response
88
+ },
89
+ warnings: []
90
+ };
91
+ };
92
+ return model;
93
+ };
94
+ const provider = (modelId) => createChatModel(modelId);
95
+ provider.specificationVersion = "v4";
96
+ provider.chatModel = createChatModel;
97
+ provider.languageModel = createChatModel;
98
+ provider.imageModel = (modelId) => {
99
+ throw new NoSuchModelError({
100
+ modelId,
101
+ modelType: "imageModel"
102
+ });
103
+ };
104
+ provider.embeddingModel = createEmbeddingModel;
105
+ provider.textEmbeddingModel = createEmbeddingModel;
106
+ return provider;
147
107
  }
148
- var baseten = createBaseten();
149
- export {
150
- VERSION,
151
- baseten,
152
- createBaseten
153
- };
108
+ const baseten = createBaseten();
109
+ //#endregion
110
+ export { VERSION, baseten, createBaseten };
111
+
154
112
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/baseten-provider.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n NoSuchModelError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { BasetenChatModelId } from './baseten-chat-options';\nimport type { BasetenEmbeddingModelId } from './baseten-embedding-options';\nimport { VERSION } from './version';\n\n/**\n * Baseten's per-request embedding input limit: larger batches are rejected with\n * `413 batch size N > maximum allowed batch size 128`. It is also the native\n * performance client's own default `batchSize`. `embedMany` splits larger\n * inputs into chunks of this size and runs them in parallel.\n */\nconst MAX_EMBEDDINGS_PER_CALL = 128;\n\n/**\n * The part of `@basetenlabs/performance-client` we use, declared structurally to\n * keep that native addon out of our dependency and type graph.\n */\nexport type BasetenPerformanceClient = {\n embed(\n input: string[],\n model: string,\n ): Promise<{\n data: { embedding: number[] }[];\n usage?: { total_tokens?: number };\n }>;\n};\n\nexport type BasetenPerformanceClientConstructor = new (\n baseUrl: string,\n apiKey?: string,\n) => BasetenPerformanceClient;\n\nexport type BasetenErrorData = z.infer<typeof basetenErrorSchema>;\n\n// Baseten returns two different envelopes. The Model APIs send a bare string\n// (`{\"error\":\"please check the model you provided\"}`), while dedicated\n// deployments pass through their server's OpenAI-shaped object. Parsing only\n// the string form left dedicated-deployment errors falling back to the HTTP\n// reason phrase — \"Not Found\", or nothing at all over HTTP/2.\nconst basetenErrorSchema = z.object({\n error: z.union([\n z.string(),\n z.object({\n message: z.string(),\n object: z.string().nullish(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n ]),\n});\n\nconst basetenErrorStructure: ProviderErrorStructure<BasetenErrorData> = {\n errorSchema: basetenErrorSchema,\n errorToMessage: data =>\n typeof data.error === 'string' ? data.error : data.error.message,\n};\n\nexport interface BasetenProviderSettings {\n /**\n * Baseten API key. Default value is taken from the `BASETEN_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'\n */\n baseURL?: string;\n\n /**\n * Model URL for custom models (chat or embeddings).\n * If not supplied, the default Model APIs will be used.\n */\n modelURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\n * Opt in to Baseten's native performance client for embeddings, for\n * client-side batching and request hedging. Pass the `PerformanceClient`\n * constructor from `@basetenlabs/performance-client`, which you install\n * yourself:\n *\n * ```ts\n * import { PerformanceClient } from '@basetenlabs/performance-client';\n *\n * const baseten = createBaseten({ modelURL, performanceClient: PerformanceClient });\n * ```\n *\n * When omitted, embeddings go over plain HTTP to Baseten's OpenAI-compatible\n * endpoint — the default, since this NAPI addon cannot load in edge runtimes\n * and bundlers cannot resolve its platform binaries.\n */\n performanceClient?: BasetenPerformanceClientConstructor;\n}\n\nexport interface BasetenProvider extends ProviderV4 {\n /**\n * Creates a chat model for text generation.\n */\n (modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a language model for text generation. Alias for chatModel.\n */\n languageModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a embedding model for text generation.\n */\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n}\n\n// by default, we use the Model APIs\nconst defaultBaseURL = 'https://inference.baseten.co/v1';\n\nexport function createBaseten(\n options: BasetenProviderSettings = {},\n): BasetenProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-baseten/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (\n modelType: string,\n customURL?: string,\n ): CommonModelConfig => ({\n provider: `baseten.${modelType}`,\n url: ({ path }) => {\n // For embeddings with /sync URLs (but not /sync/v1), we need to add /v1\n if (\n modelType === 'embedding' &&\n customURL?.includes('/sync') &&\n !customURL?.includes('/sync/v1')\n ) {\n return `${customURL}/v1${path}`;\n }\n return `${customURL || baseURL}${path}`;\n },\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId?: BasetenChatModelId) => {\n const customURL = options.modelURL;\n if (customURL) {\n if (customURL.includes('/sync/v1')) {\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'placeholder', {\n ...getCommonModelConfig('chat', customURL),\n errorStructure: basetenErrorStructure,\n // Or stream_options.include_usage is omitted and streams report no usage.\n includeUsage: true,\n supportsStructuredOutputs: true,\n });\n } else if (customURL.includes('/predict')) {\n throw new Error(\n 'Not supported. You must use a /sync/v1 endpoint for chat models.',\n );\n }\n }\n\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'chat', {\n ...getCommonModelConfig('chat'),\n errorStructure: basetenErrorStructure,\n includeUsage: true,\n supportsStructuredOutputs: true,\n });\n };\n\n const createEmbeddingModel = (modelId?: BasetenEmbeddingModelId) => {\n const customURL = options.modelURL;\n if (!customURL) {\n throw new Error(\n 'No model URL provided for embeddings. Please set modelURL option for embeddings.',\n );\n }\n\n if (!customURL.includes('/sync')) {\n throw new Error(\n 'Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.',\n );\n }\n\n // BEI embedding deployments are OpenAI-compatible with no extra settings, so\n // plain HTTP is the default and needs no override.\n const model = new OpenAICompatibleEmbeddingModel(modelId ?? 'embeddings', {\n ...getCommonModelConfig('embedding', customURL),\n errorStructure: basetenErrorStructure,\n // Over HTTP, cap each request and let `embedMany` split and parallelise.\n // The native client does its own batching, so let it take everything at\n // once — `embedMany` treats Infinity as \"one call\".\n maxEmbeddingsPerCall: options.performanceClient\n ? Number.POSITIVE_INFINITY\n : MAX_EMBEDDINGS_PER_CALL,\n });\n\n if (!options.performanceClient) {\n return model;\n }\n\n // Opted in to the native client. It appends /v1 itself, so hand it the bare\n // /sync form.\n const performanceClient = new options.performanceClient(\n customURL.replace('/sync/v1', '/sync'),\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n }),\n );\n\n model.doEmbed = async params => {\n if (!params.values || !Array.isArray(params.values)) {\n throw new Error('params.values must be an array of strings');\n }\n\n const response = await performanceClient.embed(\n params.values,\n // model_id is for Model APIs; dedicated deployments ignore it.\n modelId ?? 'embeddings',\n );\n\n return {\n embeddings: response.data.map(item => item.embedding),\n // The native client types its response as `any`; only report usage when\n // a token count is actually present rather than `{ tokens: undefined }`.\n usage:\n typeof response.usage?.total_tokens === 'number'\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\n warnings: [],\n };\n };\n\n return model;\n };\n\n const provider = (modelId?: BasetenChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n return provider;\n}\n\nexport const baseten = createBaseten();\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS;;;ACfX,IAAM,UACX,OACI,WACA;;;ADuBN,IAAM,0BAA0B;AA4BhC,IAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,OAAO,EAAE,MAAM;AAAA,IACb,EAAE,OAAO;AAAA,IACT,E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BAAkB;AAAA,QACvC,OAAO;AAAA;AAAA,QAEP,WAAW;AAAA,MACb;AAEA,aAAO;AAAA,QACL,YAAY,SAAS,KAAK,IAAI,UAAQ,KAAK,SAAS;AAAA;AAAA;AAAA,QAGpD,OACE,OAAO,SAAS,OAAO,iBAAiB,WACpC,EAAE,QAAQ,SAAS,MAAM,aAAa,IACtC;AAAA,QACN,UAAU,EAAE,SAAS,CAAC,GAAG,MAAM,SAAS;AAAA,QACxC,UAAU,CAAC;AAAA,MACb;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,CAAC,YAAiC,gBAAgB,OAAO;AAE1E,WAAS,uBAAuB;AAChC,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AACA,WAAS,iBAAiB;AAC1B,WAAS,qBAAqB;AAC9B,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/version.ts","../src/baseten-provider.ts"],"sourcesContent":["// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleEmbeddingModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\n NoSuchModelError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { BasetenChatModelId } from './baseten-chat-options';\nimport type { BasetenEmbeddingModelId } from './baseten-embedding-options';\nimport { VERSION } from './version';\n\n/**\n * Baseten's per-request embedding input limit: larger batches are rejected with\n * `413 batch size N > maximum allowed batch size 128`. It is also the native\n * performance client's own default `batchSize`. `embedMany` splits larger\n * inputs into chunks of this size and runs them in parallel.\n */\nconst MAX_EMBEDDINGS_PER_CALL = 128;\n\n/**\n * The part of `@basetenlabs/performance-client` we use, declared structurally to\n * keep that native addon out of our dependency and type graph.\n */\nexport type BasetenPerformanceClient = {\n embed(\n input: string[],\n model: string,\n ): Promise<{\n data: { embedding: number[] }[];\n usage?: { total_tokens?: number };\n }>;\n};\n\nexport type BasetenPerformanceClientConstructor = new (\n baseUrl: string,\n apiKey?: string,\n) => BasetenPerformanceClient;\n\nexport type BasetenErrorData = z.infer<typeof basetenErrorSchema>;\n\n// Baseten returns two different envelopes. The Model APIs send a bare string\n// (`{\"error\":\"please check the model you provided\"}`), while dedicated\n// deployments pass through their server's OpenAI-shaped object. Parsing only\n// the string form left dedicated-deployment errors falling back to the HTTP\n// reason phrase — \"Not Found\", or nothing at all over HTTP/2.\nconst basetenErrorSchema = z.object({\n error: z.union([\n z.string(),\n z.object({\n message: z.string(),\n object: z.string().nullish(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n ]),\n});\n\nconst basetenErrorStructure: ProviderErrorStructure<BasetenErrorData> = {\n errorSchema: basetenErrorSchema,\n errorToMessage: data =>\n typeof data.error === 'string' ? data.error : data.error.message,\n};\n\nexport interface BasetenProviderSettings {\n /**\n * Baseten API key. Default value is taken from the `BASETEN_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n\n /**\n * Base URL for the Model APIs. Default: 'https://inference.baseten.co/v1'\n */\n baseURL?: string;\n\n /**\n * Model URL for custom models (chat or embeddings).\n * If not supplied, the default Model APIs will be used.\n */\n modelURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n /**\n * Opt in to Baseten's native performance client for embeddings, for\n * client-side batching and request hedging. Pass the `PerformanceClient`\n * constructor from `@basetenlabs/performance-client`, which you install\n * yourself:\n *\n * ```ts\n * import { PerformanceClient } from '@basetenlabs/performance-client';\n *\n * const baseten = createBaseten({ modelURL, performanceClient: PerformanceClient });\n * ```\n *\n * When omitted, embeddings go over plain HTTP to Baseten's OpenAI-compatible\n * endpoint — the default, since this NAPI addon cannot load in edge runtimes\n * and bundlers cannot resolve its platform binaries.\n */\n performanceClient?: BasetenPerformanceClientConstructor;\n}\n\nexport interface BasetenProvider extends ProviderV4 {\n /**\n * Creates a chat model for text generation.\n */\n (modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a language model for text generation. Alias for chatModel.\n */\n languageModel(modelId?: BasetenChatModelId): LanguageModelV4;\n\n /**\n * Creates a embedding model for text generation.\n */\n embeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId?: BasetenEmbeddingModelId): EmbeddingModelV4;\n}\n\n// by default, we use the Model APIs\nconst defaultBaseURL = 'https://inference.baseten.co/v1';\n\nexport function createBaseten(\n options: BasetenProviderSettings = {},\n): BasetenProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-baseten/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (\n modelType: string,\n customURL?: string,\n ): CommonModelConfig => ({\n provider: `baseten.${modelType}`,\n url: ({ path }) => {\n // For embeddings with /sync URLs (but not /sync/v1), we need to add /v1\n if (\n modelType === 'embedding' &&\n customURL?.includes('/sync') &&\n !customURL?.includes('/sync/v1')\n ) {\n return `${customURL}/v1${path}`;\n }\n return `${customURL || baseURL}${path}`;\n },\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId?: BasetenChatModelId) => {\n const customURL = options.modelURL;\n if (customURL) {\n if (customURL.includes('/sync/v1')) {\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'placeholder', {\n ...getCommonModelConfig('chat', customURL),\n errorStructure: basetenErrorStructure,\n // Or stream_options.include_usage is omitted and streams report no usage.\n includeUsage: true,\n supportsStructuredOutputs: true,\n });\n } else if (customURL.includes('/predict')) {\n throw new Error(\n 'Not supported. You must use a /sync/v1 endpoint for chat models.',\n );\n }\n }\n\n return new OpenAICompatibleChatLanguageModel(modelId ?? 'chat', {\n ...getCommonModelConfig('chat'),\n errorStructure: basetenErrorStructure,\n includeUsage: true,\n supportsStructuredOutputs: true,\n });\n };\n\n const createEmbeddingModel = (modelId?: BasetenEmbeddingModelId) => {\n const customURL = options.modelURL;\n if (!customURL) {\n throw new Error(\n 'No model URL provided for embeddings. Please set modelURL option for embeddings.',\n );\n }\n\n if (!customURL.includes('/sync')) {\n throw new Error(\n 'Not supported. You must use a /sync or /sync/v1 endpoint for embeddings.',\n );\n }\n\n // BEI embedding deployments are OpenAI-compatible with no extra settings, so\n // plain HTTP is the default and needs no override.\n const model = new OpenAICompatibleEmbeddingModel(modelId ?? 'embeddings', {\n ...getCommonModelConfig('embedding', customURL),\n errorStructure: basetenErrorStructure,\n // Over HTTP, cap each request and let `embedMany` split and parallelise.\n // The native client does its own batching, so let it take everything at\n // once — `embedMany` treats Infinity as \"one call\".\n maxEmbeddingsPerCall: options.performanceClient\n ? Number.POSITIVE_INFINITY\n : MAX_EMBEDDINGS_PER_CALL,\n });\n\n if (!options.performanceClient) {\n return model;\n }\n\n // Opted in to the native client. It appends /v1 itself, so hand it the bare\n // /sync form.\n const performanceClient = new options.performanceClient(\n customURL.replace('/sync/v1', '/sync'),\n loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'BASETEN_API_KEY',\n description: 'Baseten API key',\n }),\n );\n\n model.doEmbed = async params => {\n if (!params.values || !Array.isArray(params.values)) {\n throw new Error('params.values must be an array of strings');\n }\n\n const response = await performanceClient.embed(\n params.values,\n // model_id is for Model APIs; dedicated deployments ignore it.\n modelId ?? 'embeddings',\n );\n\n return {\n embeddings: response.data.map(item => item.embedding),\n // The native client types its response as `any`; only report usage when\n // a token count is actually present rather than `{ tokens: undefined }`.\n usage:\n typeof response.usage?.total_tokens === 'number'\n ? { tokens: response.usage.total_tokens }\n : undefined,\n response: { headers: {}, body: response },\n warnings: [],\n };\n };\n\n return model;\n };\n\n const provider = (modelId?: BasetenChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n return provider;\n}\n\nexport const baseten = createBaseten();\n"],"mappings":";;;;;AAEA,MAAa,UAAA;;;;;;;;;AC0Bb,MAAM,0BAA0B;AAyChC,MAAM,wBAAkE;CACtE,aAdyB,EAAE,OAAO,EAClC,OAAO,EAAE,MAAM,CACb,EAAE,OAAO,GACT,EAAE,OAAO;EACP,SAAS,EAAE,OAAO;EAClB,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ;EAC3B,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ;EACzB,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ;EACvB,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ;CAClD,CAAC,CACH,CAAC,EACH,CAGgC;CAC9B,iBA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AC9C,gBAAgB;GAIhB,sBAAsB,QAAQ,oBAC1B,OAAO,oBACP;EACN,CAAC;EAED,IAAI,CAAC,QAAQ,mBACX,OAAO;EAKT,MAAM,oBAAoB,IAAI,QAAQ,kBACpC,UAAU,QAAQ,YAAY,OAAO,GACrC,WAAW;GACT,QAAQ,QAAQ;GAChB,yBAAyB;GACzB,aAAa;EACf,CAAC,CACH;EAEA,MAAM,UAAU,OAAM,WAAU;GAC9B,IAAI,CAAC,OAAO,UAAU,CAAC,MAAM,QAAQ,OAAO,MAAM,GAChD,MAAM,IAAI,MAAM,2CAA2C;GAG7D,MAAM,WAAW,MAAM,kBAAkB,MACvC,OAAO,QAEP,WAAW,YACb;GAEA,OAAO;IACL,YAAY,SAAS,KAAK,KAAI,SAAQ,KAAK,SAAS;IAGpD,OACE,OAAO,SAAS,OAAO,iBAAiB,WACpC,EAAE,QAAQ,SAAS,MAAM,aAAa,IACtC,KAAA;IACN,UAAU;KAAE,SAAS,CAAC;KAAG,MAAM;IAAS;IACxC,UAAU,CAAC;GACb;EACF;EAEA,OAAO;CACT;CAEA,MAAM,YAAY,YAAiC,gBAAgB,OAAO;CAE1E,SAAS,uBAAuB;CAChC,SAAS,YAAY;CACrB,SAAS,gBAAgB;CACzB,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CACA,SAAS,iBAAiB;CAC1B,SAAS,qBAAqB;CAC9B,OAAO;AACT;AAEA,MAAa,UAAU,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/baseten",
3
- "version": "2.1.37",
3
+ "version": "2.1.39",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,15 +29,15 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.59",
33
- "@ai-sdk/provider": "4.0.19",
34
- "@ai-sdk/provider-utils": "5.0.51"
32
+ "@ai-sdk/openai-compatible": "3.0.61",
33
+ "@ai-sdk/provider": "4.0.21",
34
+ "@ai-sdk/provider-utils": "5.0.53"
35
35
  },
36
36
  "devDependencies": {
37
- "@ai-sdk/test-server": "2.0.2",
37
+ "@ai-sdk/test-server": "2.0.3",
38
38
  "@types/node": "22.19.19",
39
39
  "@vercel/ai-tsconfig": "0.0.0",
40
- "tsup": "^8.5.1",
40
+ "tsdown": "^0.23.0",
41
41
  "typescript": "5.8.3",
42
42
  "zod": "3.25.76"
43
43
  },
@@ -64,9 +64,9 @@
64
64
  "ai"
65
65
  ],
66
66
  "scripts": {
67
- "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
68
- "build:watch": "pnpm clean && tsup --watch",
69
- "clean": "del-cli dist docs *.tsbuildinfo",
67
+ "build": "pnpm clean && tsdown",
68
+ "build:watch": "pnpm clean && tsdown --watch",
69
+ "clean": "del-cli docs *.tsbuildinfo",
70
70
  "type-check": "tsc --build",
71
71
  "test": "pnpm test:node && pnpm test:edge",
72
72
  "test:update": "pnpm test:node -u",