@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.
@@ -22,6 +22,7 @@ declare const openaiProviderOptions: z.ZodObject<{
22
22
  auto: "auto";
23
23
  flex: "flex";
24
24
  }>>;
25
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
25
26
  }, z.core.$strip>;
26
27
  type OpenAIProviderOptions = z.infer<typeof openaiProviderOptions>;
27
28
 
@@ -203,7 +204,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
203
204
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
204
205
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
206
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
206
- strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
207
+ strictJsonSchema: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
207
208
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
209
  reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
209
210
  serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
@@ -22,6 +22,7 @@ declare const openaiProviderOptions: z.ZodObject<{
22
22
  auto: "auto";
23
23
  flex: "flex";
24
24
  }>>;
25
+ strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
25
26
  }, z.core.$strip>;
26
27
  type OpenAIProviderOptions = z.infer<typeof openaiProviderOptions>;
27
28
 
@@ -203,7 +204,7 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
203
204
  store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
204
205
  user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
206
  reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
206
- strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
207
+ strictJsonSchema: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
207
208
  instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
209
  reasoningSummary: z.ZodOptional<z.ZodNullable<z.ZodString>>;
209
210
  serviceTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
@@ -310,7 +310,13 @@ var openaiProviderOptions = import_v4.z.object({
310
310
  *
311
311
  * @default 'auto'
312
312
  */
313
- serviceTier: import_v4.z.enum(["auto", "flex"]).optional()
313
+ serviceTier: import_v4.z.enum(["auto", "flex"]).optional(),
314
+ /**
315
+ * Whether to use strict JSON schema validation.
316
+ *
317
+ * @default true
318
+ */
319
+ strictJsonSchema: import_v4.z.boolean().optional()
314
320
  });
315
321
 
316
322
  // src/openai-error.ts
@@ -407,7 +413,8 @@ var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFacto
407
413
  function prepareTools({
408
414
  tools,
409
415
  toolChoice,
410
- structuredOutputs
416
+ structuredOutputs,
417
+ strictJsonSchema
411
418
  }) {
412
419
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
413
420
  const toolWarnings = [];
@@ -424,7 +431,7 @@ function prepareTools({
424
431
  name: tool.name,
425
432
  description: tool.description,
426
433
  parameters: tool.inputSchema,
427
- strict: structuredOutputs ? true : void 0
434
+ strict: structuredOutputs ? strictJsonSchema : void 0
428
435
  }
429
436
  });
430
437
  break;
@@ -516,7 +523,7 @@ var OpenAIChatLanguageModel = class {
516
523
  toolChoice,
517
524
  providerOptions
518
525
  }) {
519
- var _a, _b, _c;
526
+ var _a, _b, _c, _d;
520
527
  const warnings = [];
521
528
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
522
529
  provider: "openai",
@@ -544,6 +551,7 @@ var OpenAIChatLanguageModel = class {
544
551
  }
545
552
  );
546
553
  warnings.push(...messageWarnings);
554
+ const strictJsonSchema = (_c = openaiOptions.strictJsonSchema) != null ? _c : false;
547
555
  const baseArgs = {
548
556
  // model id:
549
557
  model: this.modelId,
@@ -559,18 +567,15 @@ var OpenAIChatLanguageModel = class {
559
567
  top_p: topP,
560
568
  frequency_penalty: frequencyPenalty,
561
569
  presence_penalty: presencePenalty,
562
- response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
563
- // TODO convert into provider option
564
- structuredOutputs && responseFormat.schema != null ? {
565
- type: "json_schema",
566
- json_schema: {
567
- schema: responseFormat.schema,
568
- strict: true,
569
- name: (_c = responseFormat.name) != null ? _c : "response",
570
- description: responseFormat.description
571
- }
572
- } : { type: "json_object" }
573
- ) : void 0,
570
+ response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? structuredOutputs && responseFormat.schema != null ? {
571
+ type: "json_schema",
572
+ json_schema: {
573
+ schema: responseFormat.schema,
574
+ strict: strictJsonSchema,
575
+ name: (_d = responseFormat.name) != null ? _d : "response",
576
+ description: responseFormat.description
577
+ }
578
+ } : { type: "json_object" } : void 0,
574
579
  stop: stopSequences,
575
580
  seed,
576
581
  // openai specific settings:
@@ -669,7 +674,8 @@ var OpenAIChatLanguageModel = class {
669
674
  } = prepareTools({
670
675
  tools,
671
676
  toolChoice,
672
- structuredOutputs
677
+ structuredOutputs,
678
+ strictJsonSchema
673
679
  });
674
680
  return {
675
681
  args: {
@@ -2137,7 +2143,7 @@ var import_provider7 = require("@ai-sdk/provider");
2137
2143
  function prepareResponsesTools({
2138
2144
  tools,
2139
2145
  toolChoice,
2140
- strict
2146
+ strictJsonSchema
2141
2147
  }) {
2142
2148
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
2143
2149
  const toolWarnings = [];
@@ -2153,7 +2159,7 @@ function prepareResponsesTools({
2153
2159
  name: tool.name,
2154
2160
  description: tool.description,
2155
2161
  parameters: tool.inputSchema,
2156
- strict: strict ? true : void 0
2162
+ strict: strictJsonSchema
2157
2163
  });
2158
2164
  break;
2159
2165
  case "provider-defined":
@@ -2261,7 +2267,7 @@ var OpenAIResponsesLanguageModel = class {
2261
2267
  providerOptions,
2262
2268
  schema: openaiResponsesProviderOptionsSchema
2263
2269
  });
2264
- const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
2270
+ const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2265
2271
  const baseArgs = {
2266
2272
  model: this.modelId,
2267
2273
  input: messages,
@@ -2272,7 +2278,7 @@ var OpenAIResponsesLanguageModel = class {
2272
2278
  text: {
2273
2279
  format: responseFormat.schema != null ? {
2274
2280
  type: "json_schema",
2275
- strict: isStrict,
2281
+ strict: strictJsonSchema,
2276
2282
  name: (_b = responseFormat.name) != null ? _b : "response",
2277
2283
  description: responseFormat.description,
2278
2284
  schema: responseFormat.schema
@@ -2335,7 +2341,7 @@ var OpenAIResponsesLanguageModel = class {
2335
2341
  } = prepareResponsesTools({
2336
2342
  tools,
2337
2343
  toolChoice,
2338
- strict: isStrict
2344
+ strictJsonSchema
2339
2345
  });
2340
2346
  return {
2341
2347
  args: {
@@ -2940,7 +2946,7 @@ var openaiResponsesProviderOptionsSchema = import_v414.z.object({
2940
2946
  store: import_v414.z.boolean().nullish(),
2941
2947
  user: import_v414.z.string().nullish(),
2942
2948
  reasoningEffort: import_v414.z.string().nullish(),
2943
- strictSchemas: import_v414.z.boolean().nullish(),
2949
+ strictJsonSchema: import_v414.z.boolean().nullish(),
2944
2950
  instructions: import_v414.z.string().nullish(),
2945
2951
  reasoningSummary: import_v414.z.string().nullish(),
2946
2952
  serviceTier: import_v414.z.enum(["auto", "flex"]).nullish()