@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/dist/index.mjs CHANGED
@@ -1612,16 +1612,13 @@ var openaiImageResponseSchema = z5.object({
1612
1612
  });
1613
1613
 
1614
1614
  // src/responses/openai-responses-language-model.ts
1615
- import {
1616
- InvalidArgumentError
1617
- } from "@ai-sdk/provider";
1618
1615
  import {
1619
1616
  combineHeaders as combineHeaders5,
1620
1617
  createEventSourceResponseHandler as createEventSourceResponseHandler3,
1621
1618
  createJsonResponseHandler as createJsonResponseHandler5,
1622
1619
  generateId as generateId2,
1623
- postJsonToApi as postJsonToApi5,
1624
- safeValidateTypes
1620
+ parseProviderOptions,
1621
+ postJsonToApi as postJsonToApi5
1625
1622
  } from "@ai-sdk/provider-utils";
1626
1623
  import { z as z6 } from "zod";
1627
1624
 
@@ -1865,7 +1862,7 @@ var OpenAIResponsesLanguageModel = class {
1865
1862
  providerMetadata,
1866
1863
  responseFormat
1867
1864
  }) {
1868
- var _a, _b, _c, _d;
1865
+ var _a, _b, _c;
1869
1866
  const warnings = [];
1870
1867
  const modelConfig = getResponsesModelConfig(this.modelId);
1871
1868
  const type = mode.type;
@@ -1904,19 +1901,12 @@ var OpenAIResponsesLanguageModel = class {
1904
1901
  systemMessageMode: modelConfig.systemMessageMode
1905
1902
  });
1906
1903
  warnings.push(...messageWarnings);
1907
- const parsedProviderOptions = providerMetadata != null ? safeValidateTypes({
1908
- value: providerMetadata,
1909
- schema: providerOptionsSchema
1910
- }) : { success: true, value: void 0 };
1911
- if (!parsedProviderOptions.success) {
1912
- throw new InvalidArgumentError({
1913
- argument: "providerOptions",
1914
- message: "invalid provider options",
1915
- cause: parsedProviderOptions.error
1916
- });
1917
- }
1918
- const openaiOptions = (_a = parsedProviderOptions.value) == null ? void 0 : _a.openai;
1919
- const isStrict = (_b = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _b : true;
1904
+ const openaiOptions = parseProviderOptions({
1905
+ provider: "openai",
1906
+ providerOptions: providerMetadata,
1907
+ schema: openaiResponsesProviderOptionsSchema
1908
+ });
1909
+ const isStrict = (_a = openaiOptions == null ? void 0 : openaiOptions.strictSchemas) != null ? _a : true;
1920
1910
  const baseArgs = {
1921
1911
  model: this.modelId,
1922
1912
  input: messages,
@@ -1928,7 +1918,7 @@ var OpenAIResponsesLanguageModel = class {
1928
1918
  format: responseFormat.schema != null ? {
1929
1919
  type: "json_schema",
1930
1920
  strict: isStrict,
1931
- name: (_c = responseFormat.name) != null ? _c : "response",
1921
+ name: (_b = responseFormat.name) != null ? _b : "response",
1932
1922
  description: responseFormat.description,
1933
1923
  schema: responseFormat.schema
1934
1924
  } : { type: "json_object" }
@@ -1940,6 +1930,7 @@ var OpenAIResponsesLanguageModel = class {
1940
1930
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
1941
1931
  store: openaiOptions == null ? void 0 : openaiOptions.store,
1942
1932
  user: openaiOptions == null ? void 0 : openaiOptions.user,
1933
+ instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
1943
1934
  // model-specific settings:
1944
1935
  ...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
1945
1936
  reasoning: { effort: openaiOptions == null ? void 0 : openaiOptions.reasoningEffort }
@@ -1990,7 +1981,7 @@ var OpenAIResponsesLanguageModel = class {
1990
1981
  format: mode.schema != null ? {
1991
1982
  type: "json_schema",
1992
1983
  strict: isStrict,
1993
- name: (_d = mode.name) != null ? _d : "response",
1984
+ name: (_c = mode.name) != null ? _c : "response",
1994
1985
  description: mode.description,
1995
1986
  schema: mode.schema
1996
1987
  } : { type: "json_object" }
@@ -2383,17 +2374,6 @@ function isResponseOutputItemAddedChunk(chunk) {
2383
2374
  function isResponseAnnotationAddedChunk(chunk) {
2384
2375
  return chunk.type === "response.output_text.annotation.added";
2385
2376
  }
2386
- var providerOptionsSchema = z6.object({
2387
- openai: z6.object({
2388
- metadata: z6.any().nullish(),
2389
- parallelToolCalls: z6.boolean().nullish(),
2390
- previousResponseId: z6.string().nullish(),
2391
- store: z6.boolean().nullish(),
2392
- user: z6.string().nullish(),
2393
- reasoningEffort: z6.string().nullish(),
2394
- strictSchemas: z6.boolean().nullish()
2395
- }).nullish()
2396
- });
2397
2377
  function getResponsesModelConfig(modelId) {
2398
2378
  if (modelId.startsWith("o")) {
2399
2379
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
@@ -2415,6 +2395,16 @@ function getResponsesModelConfig(modelId) {
2415
2395
  requiredAutoTruncation: false
2416
2396
  };
2417
2397
  }
2398
+ var openaiResponsesProviderOptionsSchema = z6.object({
2399
+ metadata: z6.any().nullish(),
2400
+ parallelToolCalls: z6.boolean().nullish(),
2401
+ previousResponseId: z6.string().nullish(),
2402
+ store: z6.boolean().nullish(),
2403
+ user: z6.string().nullish(),
2404
+ reasoningEffort: z6.string().nullish(),
2405
+ strictSchemas: z6.boolean().nullish(),
2406
+ instructions: z6.string().nullish()
2407
+ });
2418
2408
 
2419
2409
  // src/openai-tools.ts
2420
2410
  import { z as z7 } from "zod";