@ai-sdk/openai 2.0.0-beta.2 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 2.0.0-beta.3
4
+
5
+ ### Major Changes
6
+
7
+ - efc3a62: fix (provider/openai): default strict mode to false
8
+
3
9
  ## 2.0.0-beta.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -64,7 +64,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
64
64
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
65
65
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
66
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
- strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
67
+ strictJsonSchema: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
68
68
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
69
  reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
70
  serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
package/dist/index.d.ts CHANGED
@@ -64,7 +64,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
64
64
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
65
65
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
66
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
- strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
67
+ strictJsonSchema: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
68
68
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
69
  reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
70
  serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
package/dist/index.js CHANGED
@@ -302,7 +302,13 @@ var openaiProviderOptions = import_v4.z.object({
302
302
  *
303
303
  * @default 'auto'
304
304
  */
305
- serviceTier: import_v4.z.enum(["auto", "flex"]).optional()
305
+ serviceTier: import_v4.z.enum(["auto", "flex"]).optional(),
306
+ /**
307
+ * Whether to use strict JSON schema validation.
308
+ *
309
+ * @default true
310
+ */
311
+ strictJsonSchema: import_v4.z.boolean().optional()
306
312
  });
307
313
 
308
314
  // src/openai-error.ts
@@ -399,7 +405,8 @@ var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFacto
399
405
  function prepareTools({
400
406
  tools,
401
407
  toolChoice,
402
- structuredOutputs
408
+ structuredOutputs,
409
+ strictJsonSchema
403
410
  }) {
404
411
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
405
412
  const toolWarnings = [];
@@ -416,7 +423,7 @@ function prepareTools({
416
423
  name: tool.name,
417
424
  description: tool.description,
418
425
  parameters: tool.inputSchema,
419
- strict: structuredOutputs ? true : void 0
426
+ strict: structuredOutputs ? strictJsonSchema : void 0
420
427
  }
421
428
  });
422
429
  break;
@@ -508,7 +515,7 @@ var OpenAIChatLanguageModel = class {
508
515
  toolChoice,
509
516
  providerOptions
510
517
  }) {
511
- var _a, _b, _c;
518
+ var _a, _b, _c, _d;
512
519
  const warnings = [];
513
520
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
514
521
  provider: "openai",
@@ -536,6 +543,7 @@ var OpenAIChatLanguageModel = class {
536
543
  }
537
544
  );
538
545
  warnings.push(...messageWarnings);
546
+ const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
539
547
  const baseArgs = {
540
548
  // model id:
541
549
  model: this.modelId,
@@ -551,18 +559,15 @@ var OpenAIChatLanguageModel = class {
551
559
  top_p: topP,
552
560
  frequency_penalty: frequencyPenalty,
553
561
  presence_penalty: presencePenalty,
554
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
555
- // TODO convert into provider option
556
- structuredOutputs && responseFormat.schema != null ? {
557
- type: "json_schema",
558
- json_schema: {
559
- schema: responseFormat.schema,
560
- strict: true,
561
- name: (_c = responseFormat.name) != null ? _c : "response",
562
- description: responseFormat.description
563
- }
564
- } : { type: "json_object" }
565
- ) : void 0,
562
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
563
+ type: "json_schema",
564
+ json_schema: {
565
+ schema: responseFormat.schema,
566
+ strict: strictJsonSchema,
567
+ name: (_d = responseFormat.name) != null ? _d : "response",
568
+ description: responseFormat.description
569
+ }
570
+ } : { type: "json_object" } : void 0,
566
571
  stop: stopSequences,
567
572
  seed,
568
573
  // openai specific settings:
@@ -661,7 +666,8 @@ var OpenAIChatLanguageModel = class {
661
666
  } = prepareTools({
662
667
  tools,
663
668
  toolChoice,
664
- structuredOutputs
669
+ structuredOutputs,
670
+ strictJsonSchema
665
671
  });
666
672
  return {
667
673
  args: {
@@ -2028,7 +2034,7 @@ var import_provider7 = require("@ai-sdk/provider");
2028
2034
  function prepareResponsesTools({
2029
2035
  tools,
2030
2036
  toolChoice,
2031
- strict
2037
+ strictJsonSchema
2032
2038
  }) {
2033
2039
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
2034
2040
  const toolWarnings = [];
@@ -2044,7 +2050,7 @@ function prepareResponsesTools({
2044
2050
  name: tool.name,
2045
2051
  description: tool.description,
2046
2052
  parameters: tool.inputSchema,
2047
- strict: strict ? true : void 0
2053
+ strict: strictJsonSchema
2048
2054
  });
2049
2055
  break;
2050
2056
  case "provider-defined":
@@ -2152,7 +2158,7 @@ var OpenAIResponsesLanguageModel = class {
2152
2158
  providerOptions,
2153
2159
  schema: openaiResponsesProviderOptionsSchema
2154
2160
  });
2155
- const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
2161
+ const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2156
2162
  const baseArgs = {
2157
2163
  model: this.modelId,
2158
2164
  input: messages,
@@ -2163,7 +2169,7 @@ var OpenAIResponsesLanguageModel = class {
2163
2169
  text: {
2164
2170
  format: responseFormat.schema != null ? {
2165
2171
  type: "json_schema",
2166
- strict: isStrict,
2172
+ strict: strictJsonSchema,
2167
2173
  name: (_b = responseFormat.name) != null ? _b : "response",
2168
2174
  description: responseFormat.description,
2169
2175
  schema: responseFormat.schema
@@ -2226,7 +2232,7 @@ var OpenAIResponsesLanguageModel = class {
2226
2232
  } = prepareResponsesTools({
2227
2233
  tools,
2228
2234
  toolChoice,
2229
- strict: isStrict
2235
+ strictJsonSchema
2230
2236
  });
2231
2237
  return {
2232
2238
  args: {
@@ -2831,7 +2837,7 @@ var openaiResponsesProviderOptionsSchema = import_v413.z.object({
2831
2837
  store: import_v413.z.boolean().nullish(),
2832
2838
  user: import_v413.z.string().nullish(),
2833
2839
  reasoningEffort: import_v413.z.string().nullish(),
2834
- strictSchemas: import_v413.z.boolean().nullish(),
2840
+ strictJsonSchema: import_v413.z.boolean().nullish(),
2835
2841
  instructions: import_v413.z.string().nullish(),
2836
2842
  reasoningSummary: import_v413.z.string().nullish(),
2837
2843
  serviceTier: import_v413.z.enum(["auto", "flex"]).nullish()