@ai-sdk/openai 2.0.0-beta.1 → 2.0.0-beta.3
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 +16 -0
- package/dist/index.d.mts +7 -26
- package/dist/index.d.ts +7 -26
- package/dist/index.js +347 -341
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -39
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +30 -204
- package/dist/internal/index.d.ts +30 -204
- package/dist/internal/index.js +347 -341
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +45 -39
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseProviderOptions,
|
|
12
12
|
postJsonToApi
|
|
13
13
|
} from "@ai-sdk/provider-utils";
|
|
14
|
-
import { z as z5 } from "zod";
|
|
14
|
+
import { z as z5 } from "zod/v4";
|
|
15
15
|
|
|
16
16
|
// src/convert-to-openai-chat-messages.ts
|
|
17
17
|
import {
|
|
@@ -224,7 +224,7 @@ function mapOpenAIFinishReason(finishReason) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/openai-chat-options.ts
|
|
227
|
-
import { z } from "zod";
|
|
227
|
+
import { z } from "zod/v4";
|
|
228
228
|
var openaiProviderOptions = z.object({
|
|
229
229
|
/**
|
|
230
230
|
* Modify the likelihood of specified tokens appearing in the completion.
|
|
@@ -267,11 +267,11 @@ var openaiProviderOptions = z.object({
|
|
|
267
267
|
/**
|
|
268
268
|
* Metadata to associate with the request.
|
|
269
269
|
*/
|
|
270
|
-
metadata: z.record(z.string()).optional(),
|
|
270
|
+
metadata: z.record(z.string().max(64), z.string().max(512)).optional(),
|
|
271
271
|
/**
|
|
272
272
|
* Parameters for prediction mode.
|
|
273
273
|
*/
|
|
274
|
-
prediction: z.record(z.any()).optional(),
|
|
274
|
+
prediction: z.record(z.string(), z.any()).optional(),
|
|
275
275
|
/**
|
|
276
276
|
* Whether to use structured outputs.
|
|
277
277
|
*
|
|
@@ -284,11 +284,17 @@ var openaiProviderOptions = z.object({
|
|
|
284
284
|
*
|
|
285
285
|
* @default 'auto'
|
|
286
286
|
*/
|
|
287
|
-
serviceTier: z.enum(["auto", "flex"]).optional()
|
|
287
|
+
serviceTier: z.enum(["auto", "flex"]).optional(),
|
|
288
|
+
/**
|
|
289
|
+
* Whether to use strict JSON schema validation.
|
|
290
|
+
*
|
|
291
|
+
* @default true
|
|
292
|
+
*/
|
|
293
|
+
strictJsonSchema: z.boolean().optional()
|
|
288
294
|
});
|
|
289
295
|
|
|
290
296
|
// src/openai-error.ts
|
|
291
|
-
import { z as z2 } from "zod";
|
|
297
|
+
import { z as z2 } from "zod/v4";
|
|
292
298
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
293
299
|
var openaiErrorDataSchema = z2.object({
|
|
294
300
|
error: z2.object({
|
|
@@ -313,7 +319,7 @@ import {
|
|
|
313
319
|
|
|
314
320
|
// src/tool/file-search.ts
|
|
315
321
|
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils";
|
|
316
|
-
import { z as z3 } from "zod";
|
|
322
|
+
import { z as z3 } from "zod/v4";
|
|
317
323
|
var fileSearchArgsSchema = z3.object({
|
|
318
324
|
/**
|
|
319
325
|
* List of vector store IDs to search through. If not provided, searches all available vector stores.
|
|
@@ -338,7 +344,7 @@ var fileSearch = createProviderDefinedToolFactory({
|
|
|
338
344
|
|
|
339
345
|
// src/tool/web-search-preview.ts
|
|
340
346
|
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory2 } from "@ai-sdk/provider-utils";
|
|
341
|
-
import { z as z4 } from "zod";
|
|
347
|
+
import { z as z4 } from "zod/v4";
|
|
342
348
|
var webSearchPreviewArgsSchema = z4.object({
|
|
343
349
|
/**
|
|
344
350
|
* Search context size to use for the web search.
|
|
@@ -383,7 +389,8 @@ var webSearchPreview = createProviderDefinedToolFactory2({
|
|
|
383
389
|
function prepareTools({
|
|
384
390
|
tools,
|
|
385
391
|
toolChoice,
|
|
386
|
-
structuredOutputs
|
|
392
|
+
structuredOutputs,
|
|
393
|
+
strictJsonSchema
|
|
387
394
|
}) {
|
|
388
395
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
389
396
|
const toolWarnings = [];
|
|
@@ -400,7 +407,7 @@ function prepareTools({
|
|
|
400
407
|
name: tool.name,
|
|
401
408
|
description: tool.description,
|
|
402
409
|
parameters: tool.inputSchema,
|
|
403
|
-
strict: structuredOutputs ?
|
|
410
|
+
strict: structuredOutputs ? strictJsonSchema : void 0
|
|
404
411
|
}
|
|
405
412
|
});
|
|
406
413
|
break;
|
|
@@ -492,7 +499,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
492
499
|
toolChoice,
|
|
493
500
|
providerOptions
|
|
494
501
|
}) {
|
|
495
|
-
var _a, _b, _c;
|
|
502
|
+
var _a, _b, _c, _d;
|
|
496
503
|
const warnings = [];
|
|
497
504
|
const openaiOptions = (_a = await parseProviderOptions({
|
|
498
505
|
provider: "openai",
|
|
@@ -520,6 +527,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
520
527
|
}
|
|
521
528
|
);
|
|
522
529
|
warnings.push(...messageWarnings);
|
|
530
|
+
const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
523
531
|
const baseArgs = {
|
|
524
532
|
// model id:
|
|
525
533
|
model: this.modelId,
|
|
@@ -535,18 +543,15 @@ var OpenAIChatLanguageModel = class {
|
|
|
535
543
|
top_p: topP,
|
|
536
544
|
frequency_penalty: frequencyPenalty,
|
|
537
545
|
presence_penalty: presencePenalty,
|
|
538
|
-
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ?
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
} : { type: "json_object" }
|
|
549
|
-
) : void 0,
|
|
546
|
+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
|
|
547
|
+
type: "json_schema",
|
|
548
|
+
json_schema: {
|
|
549
|
+
schema: responseFormat.schema,
|
|
550
|
+
strict: strictJsonSchema,
|
|
551
|
+
name: (_d = responseFormat.name) != null ? _d : "response",
|
|
552
|
+
description: responseFormat.description
|
|
553
|
+
}
|
|
554
|
+
} : { type: "json_object" } : void 0,
|
|
550
555
|
stop: stopSequences,
|
|
551
556
|
seed,
|
|
552
557
|
// openai specific settings:
|
|
@@ -645,7 +650,8 @@ var OpenAIChatLanguageModel = class {
|
|
|
645
650
|
} = prepareTools({
|
|
646
651
|
tools,
|
|
647
652
|
toolChoice,
|
|
648
|
-
structuredOutputs
|
|
653
|
+
structuredOutputs,
|
|
654
|
+
strictJsonSchema
|
|
649
655
|
});
|
|
650
656
|
return {
|
|
651
657
|
args: {
|
|
@@ -1078,7 +1084,7 @@ import {
|
|
|
1078
1084
|
parseProviderOptions as parseProviderOptions2,
|
|
1079
1085
|
postJsonToApi as postJsonToApi2
|
|
1080
1086
|
} from "@ai-sdk/provider-utils";
|
|
1081
|
-
import { z as z7 } from "zod";
|
|
1087
|
+
import { z as z7 } from "zod/v4";
|
|
1082
1088
|
|
|
1083
1089
|
// src/convert-to-openai-completion-prompt.ts
|
|
1084
1090
|
import {
|
|
@@ -1159,7 +1165,7 @@ ${user}:`]
|
|
|
1159
1165
|
}
|
|
1160
1166
|
|
|
1161
1167
|
// src/openai-completion-options.ts
|
|
1162
|
-
import { z as z6 } from "zod";
|
|
1168
|
+
import { z as z6 } from "zod/v4";
|
|
1163
1169
|
var openaiCompletionProviderOptions = z6.object({
|
|
1164
1170
|
/**
|
|
1165
1171
|
Echo back the prompt in addition to the completion.
|
|
@@ -1484,10 +1490,10 @@ import {
|
|
|
1484
1490
|
parseProviderOptions as parseProviderOptions3,
|
|
1485
1491
|
postJsonToApi as postJsonToApi3
|
|
1486
1492
|
} from "@ai-sdk/provider-utils";
|
|
1487
|
-
import { z as z9 } from "zod";
|
|
1493
|
+
import { z as z9 } from "zod/v4";
|
|
1488
1494
|
|
|
1489
1495
|
// src/openai-embedding-options.ts
|
|
1490
|
-
import { z as z8 } from "zod";
|
|
1496
|
+
import { z as z8 } from "zod/v4";
|
|
1491
1497
|
var openaiEmbeddingProviderOptions = z8.object({
|
|
1492
1498
|
/**
|
|
1493
1499
|
The number of dimensions the resulting output embeddings should have.
|
|
@@ -1575,7 +1581,7 @@ import {
|
|
|
1575
1581
|
createJsonResponseHandler as createJsonResponseHandler4,
|
|
1576
1582
|
postJsonToApi as postJsonToApi4
|
|
1577
1583
|
} from "@ai-sdk/provider-utils";
|
|
1578
|
-
import { z as z10 } from "zod";
|
|
1584
|
+
import { z as z10 } from "zod/v4";
|
|
1579
1585
|
|
|
1580
1586
|
// src/openai-image-settings.ts
|
|
1581
1587
|
var modelMaxImagesPerCall = {
|
|
@@ -1677,10 +1683,10 @@ import {
|
|
|
1677
1683
|
parseProviderOptions as parseProviderOptions4,
|
|
1678
1684
|
postFormDataToApi
|
|
1679
1685
|
} from "@ai-sdk/provider-utils";
|
|
1680
|
-
import { z as z12 } from "zod";
|
|
1686
|
+
import { z as z12 } from "zod/v4";
|
|
1681
1687
|
|
|
1682
1688
|
// src/openai-transcription-options.ts
|
|
1683
|
-
import { z as z11 } from "zod";
|
|
1689
|
+
import { z as z11 } from "zod/v4";
|
|
1684
1690
|
var openAITranscriptionProviderOptions = z11.object({
|
|
1685
1691
|
/**
|
|
1686
1692
|
* Additional information to include in the transcription response.
|
|
@@ -1871,7 +1877,7 @@ import {
|
|
|
1871
1877
|
parseProviderOptions as parseProviderOptions5,
|
|
1872
1878
|
postJsonToApi as postJsonToApi5
|
|
1873
1879
|
} from "@ai-sdk/provider-utils";
|
|
1874
|
-
import { z as z13 } from "zod";
|
|
1880
|
+
import { z as z13 } from "zod/v4";
|
|
1875
1881
|
var OpenAIProviderOptionsSchema = z13.object({
|
|
1876
1882
|
instructions: z13.string().nullish(),
|
|
1877
1883
|
speed: z13.number().min(0.25).max(4).default(1).nullish()
|
|
@@ -1985,7 +1991,7 @@ import {
|
|
|
1985
1991
|
parseProviderOptions as parseProviderOptions6,
|
|
1986
1992
|
postJsonToApi as postJsonToApi6
|
|
1987
1993
|
} from "@ai-sdk/provider-utils";
|
|
1988
|
-
import { z as z14 } from "zod";
|
|
1994
|
+
import { z as z14 } from "zod/v4";
|
|
1989
1995
|
|
|
1990
1996
|
// src/responses/convert-to-openai-responses-messages.ts
|
|
1991
1997
|
import {
|
|
@@ -2155,7 +2161,7 @@ import {
|
|
|
2155
2161
|
function prepareResponsesTools({
|
|
2156
2162
|
tools,
|
|
2157
2163
|
toolChoice,
|
|
2158
|
-
|
|
2164
|
+
strictJsonSchema
|
|
2159
2165
|
}) {
|
|
2160
2166
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
2161
2167
|
const toolWarnings = [];
|
|
@@ -2171,7 +2177,7 @@ function prepareResponsesTools({
|
|
|
2171
2177
|
name: tool.name,
|
|
2172
2178
|
description: tool.description,
|
|
2173
2179
|
parameters: tool.inputSchema,
|
|
2174
|
-
strict:
|
|
2180
|
+
strict: strictJsonSchema
|
|
2175
2181
|
});
|
|
2176
2182
|
break;
|
|
2177
2183
|
case "provider-defined":
|
|
@@ -2279,7 +2285,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2279
2285
|
providerOptions,
|
|
2280
2286
|
schema: openaiResponsesProviderOptionsSchema
|
|
2281
2287
|
});
|
|
2282
|
-
const
|
|
2288
|
+
const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
|
|
2283
2289
|
const baseArgs = {
|
|
2284
2290
|
model: this.modelId,
|
|
2285
2291
|
input: messages,
|
|
@@ -2290,7 +2296,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2290
2296
|
text: {
|
|
2291
2297
|
format: responseFormat.schema != null ? {
|
|
2292
2298
|
type: "json_schema",
|
|
2293
|
-
strict:
|
|
2299
|
+
strict: strictJsonSchema,
|
|
2294
2300
|
name: (_b = responseFormat.name) != null ? _b : "response",
|
|
2295
2301
|
description: responseFormat.description,
|
|
2296
2302
|
schema: responseFormat.schema
|
|
@@ -2353,7 +2359,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2353
2359
|
} = prepareResponsesTools({
|
|
2354
2360
|
tools,
|
|
2355
2361
|
toolChoice,
|
|
2356
|
-
|
|
2362
|
+
strictJsonSchema
|
|
2357
2363
|
});
|
|
2358
2364
|
return {
|
|
2359
2365
|
args: {
|
|
@@ -2958,7 +2964,7 @@ var openaiResponsesProviderOptionsSchema = z14.object({
|
|
|
2958
2964
|
store: z14.boolean().nullish(),
|
|
2959
2965
|
user: z14.string().nullish(),
|
|
2960
2966
|
reasoningEffort: z14.string().nullish(),
|
|
2961
|
-
|
|
2967
|
+
strictJsonSchema: z14.boolean().nullish(),
|
|
2962
2968
|
instructions: z14.string().nullish(),
|
|
2963
2969
|
reasoningSummary: z14.string().nullish(),
|
|
2964
2970
|
serviceTier: z14.enum(["auto", "flex"]).nullish()
|