@ai-sdk/openai 1.3.1 → 1.3.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,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 1.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 24befd8: feat (provider/openai): add instructions to providerOptions
8
+
9
+ ## 1.3.2
10
+
11
+ ### Patch Changes
12
+
13
+ - db15028: feat (provider/openai): expose type for validating OpenAI responses provider options
14
+
3
15
  ## 1.3.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -294,4 +294,34 @@ 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
+ instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
306
+ }, "strip", z.ZodTypeAny, {
307
+ user?: string | null | undefined;
308
+ store?: boolean | null | undefined;
309
+ metadata?: any;
310
+ reasoningEffort?: string | null | undefined;
311
+ parallelToolCalls?: boolean | null | undefined;
312
+ previousResponseId?: string | null | undefined;
313
+ strictSchemas?: boolean | null | undefined;
314
+ instructions?: string | null | undefined;
315
+ }, {
316
+ user?: string | null | undefined;
317
+ store?: boolean | null | undefined;
318
+ metadata?: any;
319
+ reasoningEffort?: string | null | undefined;
320
+ parallelToolCalls?: boolean | null | undefined;
321
+ previousResponseId?: string | null | undefined;
322
+ strictSchemas?: boolean | null | undefined;
323
+ instructions?: string | null | undefined;
324
+ }>;
325
+ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
326
+
327
+ export { type OpenAIProvider, type OpenAIProviderSettings, type OpenAIResponsesProviderOptions, createOpenAI, openai };
package/dist/index.d.ts CHANGED
@@ -294,4 +294,34 @@ 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
+ instructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
306
+ }, "strip", z.ZodTypeAny, {
307
+ user?: string | null | undefined;
308
+ store?: boolean | null | undefined;
309
+ metadata?: any;
310
+ reasoningEffort?: string | null | undefined;
311
+ parallelToolCalls?: boolean | null | undefined;
312
+ previousResponseId?: string | null | undefined;
313
+ strictSchemas?: boolean | null | undefined;
314
+ instructions?: string | null | undefined;
315
+ }, {
316
+ user?: string | null | undefined;
317
+ store?: boolean | null | undefined;
318
+ metadata?: any;
319
+ reasoningEffort?: string | null | undefined;
320
+ parallelToolCalls?: boolean | null | undefined;
321
+ previousResponseId?: string | null | undefined;
322
+ strictSchemas?: boolean | null | undefined;
323
+ instructions?: string | null | undefined;
324
+ }>;
325
+ type OpenAIResponsesProviderOptions = z.infer<typeof openaiResponsesProviderOptionsSchema>;
326
+
327
+ 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" }
@@ -1917,6 +1909,7 @@ var OpenAIResponsesLanguageModel = class {
1917
1909
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
1918
1910
  store: openaiOptions == null ? void 0 : openaiOptions.store,
1919
1911
  user: openaiOptions == null ? void 0 : openaiOptions.user,
1912
+ instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
1920
1913
  // model-specific settings:
1921
1914
  ...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
1922
1915
  reasoning: { effort: openaiOptions == null ? void 0 : openaiOptions.reasoningEffort }
@@ -1967,7 +1960,7 @@ var OpenAIResponsesLanguageModel = class {
1967
1960
  format: mode.schema != null ? {
1968
1961
  type: "json_schema",
1969
1962
  strict: isStrict,
1970
- name: (_d = mode.name) != null ? _d : "response",
1963
+ name: (_c = mode.name) != null ? _c : "response",
1971
1964
  description: mode.description,
1972
1965
  schema: mode.schema
1973
1966
  } : { type: "json_object" }
@@ -2360,17 +2353,6 @@ function isResponseOutputItemAddedChunk(chunk) {
2360
2353
  function isResponseAnnotationAddedChunk(chunk) {
2361
2354
  return chunk.type === "response.output_text.annotation.added";
2362
2355
  }
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
2356
  function getResponsesModelConfig(modelId) {
2375
2357
  if (modelId.startsWith("o")) {
2376
2358
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2392,6 +2374,16 @@ function getResponsesModelConfig(modelId) {
2392
2374
  requiredAutoTruncation: false
2393
2375
  };
2394
2376
  }
2377
+ var openaiResponsesProviderOptionsSchema = import_zod6.z.object({
2378
+ metadata: import_zod6.z.any().nullish(),
2379
+ parallelToolCalls: import_zod6.z.boolean().nullish(),
2380
+ previousResponseId: import_zod6.z.string().nullish(),
2381
+ store: import_zod6.z.boolean().nullish(),
2382
+ user: import_zod6.z.string().nullish(),
2383
+ reasoningEffort: import_zod6.z.string().nullish(),
2384
+ strictSchemas: import_zod6.z.boolean().nullish(),
2385
+ instructions: import_zod6.z.string().nullish()
2386
+ });
2395
2387
 
2396
2388
  // src/openai-tools.ts
2397
2389
  var import_zod7 = require("zod");