@ai-sdk/openai 1.3.0 → 1.3.2

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,18 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 1.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - db15028: feat (provider/openai): expose type for validating OpenAI responses provider options
8
+
9
+ ## 1.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [f10f0fa]
14
+ - @ai-sdk/provider-utils@2.2.1
15
+
3
16
  ## 1.3.0
4
17
 
5
18
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -294,4 +294,31 @@ Default OpenAI provider instance. It uses 'strict' compatibility mode.
294
294
  */
295
295
  declare const openai: OpenAIProvider;
296
296
 
297
- export { type OpenAIProvider, type OpenAIProviderSettings, createOpenAI, openai };
297
+ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
298
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
299
+ parallelToolCalls: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
300
+ previousResponseId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
301
+ store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
302
+ user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
303
+ reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
304
+ strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
305
+ }, "strip", z.ZodTypeAny, {
306
+ user?: string | null | undefined;
307
+ store?: boolean | null | undefined;
308
+ metadata?: any;
309
+ reasoningEffort?: string | null | undefined;
310
+ parallelToolCalls?: boolean | null | undefined;
311
+ previousResponseId?: string | null | undefined;
312
+ strictSchemas?: boolean | null | undefined;
313
+ }, {
314
+ user?: string | null | undefined;
315
+ store?: boolean | null | undefined;
316
+ metadata?: any;
317
+ reasoningEffort?: string | null | undefined;
318
+ parallelToolCalls?: boolean | null | undefined;
319
+ previousResponseId?: string | null | undefined;
320
+ strictSchemas?: boolean | null | undefined;
321
+ }>;
322
+ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
323
+
324
+ export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, createOpenAI, openai };
package/dist/index.d.ts CHANGED
@@ -294,4 +294,31 @@ Default OpenAI provider instance. It uses 'strict' compatibility mode.
294
294
  */
295
295
  declare const openai: OpenAIProvider;
296
296
 
297
- export { type OpenAIProvider, type OpenAIProviderSettings, createOpenAI, openai };
297
+ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
298
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
299
+ parallelToolCalls: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
300
+ previousResponseId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
301
+ store: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
302
+ user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
303
+ reasoningEffort: z.ZodOptional<z.ZodNullable<z.ZodString>>;
304
+ strictSchemas: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
305
+ }, "strip", z.ZodTypeAny, {
306
+ user?: string | null | undefined;
307
+ store?: boolean | null | undefined;
308
+ metadata?: any;
309
+ reasoningEffort?: string | null | undefined;
310
+ parallelToolCalls?: boolean | null | undefined;
311
+ previousResponseId?: string | null | undefined;
312
+ strictSchemas?: boolean | null | undefined;
313
+ }, {
314
+ user?: string | null | undefined;
315
+ store?: boolean | null | undefined;
316
+ metadata?: any;
317
+ reasoningEffort?: string | null | undefined;
318
+ parallelToolCalls?: boolean | null | undefined;
319
+ previousResponseId?: string | null | undefined;
320
+ strictSchemas?: boolean | null | undefined;
321
+ }>;
322
+ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
323
+
324
+ export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, createOpenAI, openai };
package/dist/index.js CHANGED
@@ -1602,7 +1602,6 @@ var openaiImageResponseSchema = import_zod5.z.object({
1602
1602
  });
1603
1603
 
1604
1604
  // src/responses/openai-responses-language-model.ts
1605
- var import_provider9 = require("@ai-sdk/provider");
1606
1605
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1607
1606
  var import_zod6 = require("zod");
1608
1607
 
@@ -1842,7 +1841,7 @@ var OpenAIResponsesLanguageModel = class {
1842
1841
  providerMetadata,
1843
1842
  responseFormat
1844
1843
  }) {
1845
- var _a, _b, _c, _d;
1844
+ var _a, _b, _c;
1846
1845
  const warnings = [];
1847
1846
  const modelConfig = getResponsesModelConfig(this.modelId);
1848
1847
  const type = mode.type;
@@ -1881,19 +1880,12 @@ var OpenAIResponsesLanguageModel = class {
1881
1880
  systemMessageMode: modelConfig.systemMessageMode
1882
1881
  });
1883
1882
  warnings.push(...messageWarnings);
1884
- const parsedProviderOptions = providerMetadata != null ? (0, import_provider_utils8.safeValidateTypes)({
1885
- value: providerMetadata,
1886
- schema: providerOptionsSchema
1887
- }) : { success: true, value: void 0 };
1888
- if (!parsedProviderOptions.success) {
1889
- throw new import_provider9.InvalidArgumentError({
1890
- argument: "providerOptions",
1891
- message: "invalid provider options",
1892
- cause: parsedProviderOptions.error
1893
- });
1894
- }
1895
- const openaiOptions = (_a = parsedProviderOptions.value) == null ? void 0 : _a.openai;
1896
- const isStrict = (_b = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _b : true;
1883
+ const openaiOptions = (0, import_provider_utils8.parseProviderOptions)({
1884
+ provider: "openai",
1885
+ providerOptions: providerMetadata,
1886
+ schema: openaiResponsesProviderOptionsSchema
1887
+ });
1888
+ const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
1897
1889
  const baseArgs = {
1898
1890
  model: this.modelId,
1899
1891
  input: messages,
@@ -1905,7 +1897,7 @@ var OpenAIResponsesLanguageModel = class {
1905
1897
  format: responseFormat.schema != null ? {
1906
1898
  type: "json_schema",
1907
1899
  strict: isStrict,
1908
- name: (_c = responseFormat.name) != null ? _c : "response",
1900
+ name: (_b = responseFormat.name) != null ? _b : "response",
1909
1901
  description: responseFormat.description,
1910
1902
  schema: responseFormat.schema
1911
1903
  } : { type: "json_object" }
@@ -1967,7 +1959,7 @@ var OpenAIResponsesLanguageModel = class {
1967
1959
  format: mode.schema != null ? {
1968
1960
  type: "json_schema",
1969
1961
  strict: isStrict,
1970
- name: (_d = mode.name) != null ? _d : "response",
1962
+ name: (_c = mode.name) != null ? _c : "response",
1971
1963
  description: mode.description,
1972
1964
  schema: mode.schema
1973
1965
  } : { type: "json_object" }
@@ -2360,17 +2352,6 @@ function isResponseOutputItemAddedChunk(chunk) {
2360
2352
  function isResponseAnnotationAddedChunk(chunk) {
2361
2353
  return chunk.type === "response.output_text.annotation.added";
2362
2354
  }
2363
- var providerOptionsSchema = import_zod6.z.object({
2364
- openai: import_zod6.z.object({
2365
- metadata: import_zod6.z.any().nullish(),
2366
- parallelToolCalls: import_zod6.z.boolean().nullish(),
2367
- previousResponseId: import_zod6.z.string().nullish(),
2368
- store: import_zod6.z.boolean().nullish(),
2369
- user: import_zod6.z.string().nullish(),
2370
- reasoningEffort: import_zod6.z.string().nullish(),
2371
- strictSchemas: import_zod6.z.boolean().nullish()
2372
- }).nullish()
2373
- });
2374
2355
  function getResponsesModelConfig(modelId) {
2375
2356
  if (modelId.startsWith("o")) {
2376
2357
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2392,6 +2373,15 @@ function getResponsesModelConfig(modelId) {
2392
2373
  requiredAutoTruncation: false
2393
2374
  };
2394
2375
  }
2376
+ var openaiResponsesProviderOptionsSchema = import_zod6.z.object({
2377
+ metadata: import_zod6.z.any().nullish(),
2378
+ parallelToolCalls: import_zod6.z.boolean().nullish(),
2379
+ previousResponseId: import_zod6.z.string().nullish(),
2380
+ store: import_zod6.z.boolean().nullish(),
2381
+ user: import_zod6.z.string().nullish(),
2382
+ reasoningEffort: import_zod6.z.string().nullish(),
2383
+ strictSchemas: import_zod6.z.boolean().nullish()
2384
+ });
2395
2385
 
2396
2386
  // src/openai-tools.ts
2397
2387
  var import_zod7 = require("zod");