@ai-sdk/openai 4.0.0-beta.38 → 4.0.0-beta.39

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,19 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.0-beta.39
4
+
5
+ ### Patch Changes
6
+
7
+ - 58a2ad7: fix: more precise default message for tool execution denial
8
+ - f9acbc0: feat(provider/openai): add gpt-image-2 model support
9
+ - Updated dependencies [785fe16]
10
+ - Updated dependencies [67df0a0]
11
+ - Updated dependencies [befb78c]
12
+ - Updated dependencies [0458559]
13
+ - Updated dependencies [5852c0a]
14
+ - Updated dependencies [fc92055]
15
+ - @ai-sdk/provider-utils@5.0.0-beta.27
16
+
3
17
  ## 4.0.0-beta.38
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -42,9 +42,9 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
42
42
  }>;
43
43
  type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
44
44
 
45
- type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'chatgpt-image-latest' | (string & {});
45
+ type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
46
46
 
47
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
47
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
48
48
  /**
49
49
  * An object describing the specific action taken in this web search call.
50
50
  * Includes details on how the model used the web (search, open_page, find_in_page).
@@ -632,7 +632,7 @@ type OpenAIResponsesLogprobs = NonNullable<(OpenAIResponsesChunk & {
632
632
  type: 'response.output_text.delta';
633
633
  })['logprobs']> | null;
634
634
 
635
- declare const customToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<string, {
635
+ declare const customToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactory<string, {
636
636
  /**
637
637
  * An optional description of what the tool does.
638
638
  */
@@ -689,7 +689,7 @@ declare const openaiTools: {
689
689
  * enabling iterative, multi-step code editing workflows.
690
690
  *
691
691
  */
692
- applyPatch: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
692
+ applyPatch: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
693
693
  callId: string;
694
694
  operation: ApplyPatchOperation;
695
695
  }, {
@@ -738,7 +738,7 @@ declare const openaiTools: {
738
738
  * @param ranking - The ranking options to use for the file search.
739
739
  * @param filters - The filters to use for the file search.
740
740
  */
741
- fileSearch: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
741
+ fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
742
742
  queries: string[];
743
743
  results: null | {
744
744
  attributes: Record<string, unknown>;
@@ -795,7 +795,7 @@ declare const openaiTools: {
795
795
  *
796
796
  * Supported models: `gpt-5-codex`
797
797
  */
798
- localShell: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
798
+ localShell: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
799
799
  action: {
800
800
  type: "exec";
801
801
  command: string[];
@@ -818,7 +818,7 @@ declare const openaiTools: {
818
818
  * execution or add strict allow-/deny-lists before forwarding a command to
819
819
  * the system shell.
820
820
  */
821
- shell: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
821
+ shell: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
822
822
  action: {
823
823
  commands: string[];
824
824
  timeoutMs?: number;
@@ -870,7 +870,21 @@ declare const openaiTools: {
870
870
  containerId: string;
871
871
  } | {
872
872
  type?: "local";
873
- skills?: Array<{
873
+ skills
874
+ /**
875
+ * Web search allows models to access up-to-date information from the internet
876
+ * and provide answers with sourced citations.
877
+ *
878
+ * @param searchContextSize - The search context size to use for the web search.
879
+ * @param userLocation - The user location to use for the web search.
880
+ */
881
+ ? /**
882
+ * Web search allows models to access up-to-date information from the internet
883
+ * and provide answers with sourced citations.
884
+ *
885
+ * @param searchContextSize - The search context size to use for the web search.
886
+ * @param userLocation - The user location to use for the web search.
887
+ */: Array<{
874
888
  name: string;
875
889
  description: string;
876
890
  path: string;
@@ -884,7 +898,7 @@ declare const openaiTools: {
884
898
  * @param searchContextSize - The search context size to use for the web search.
885
899
  * @param userLocation - The user location to use for the web search.
886
900
  */
887
- webSearchPreview: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
901
+ webSearchPreview: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
888
902
  action?: {
889
903
  type: "search";
890
904
  query?: string;
@@ -980,7 +994,7 @@ declare const openaiTools: {
980
994
  * in the tools array. The model will use tool search to load these tools
981
995
  * when it determines they are needed.
982
996
  */
983
- toolSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
997
+ toolSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<{
984
998
  arguments?: unknown;
985
999
  call_id?: string | null;
986
1000
  }, {
package/dist/index.js CHANGED
@@ -274,7 +274,7 @@ function convertToOpenAIChatMessages({
274
274
  contentValue = output.value;
275
275
  break;
276
276
  case "execution-denied":
277
- contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
277
+ contentValue = (_a = output.reason) != null ? _a : "Tool call execution denied.";
278
278
  break;
279
279
  case "content":
280
280
  case "json":
@@ -955,10 +955,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
955
955
  abortSignal: options.abortSignal,
956
956
  fetch: this.config.fetch
957
957
  });
958
- const toolCallTracker = new StreamingToolCallTracker({
959
- generateId,
960
- typeValidation: "if-present"
961
- });
958
+ let toolCallTracker;
962
959
  let finishReason = {
963
960
  unified: "other",
964
961
  raw: void 0
@@ -971,6 +968,10 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
971
968
  stream: response.pipeThrough(
972
969
  new TransformStream({
973
970
  start(controller) {
971
+ toolCallTracker = new StreamingToolCallTracker(controller, {
972
+ generateId,
973
+ typeValidation: "if-present"
974
+ });
974
975
  controller.enqueue({ type: "stream-start", warnings });
975
976
  },
976
977
  transform(chunk, controller) {
@@ -1035,10 +1036,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1035
1036
  }
1036
1037
  if (delta.tool_calls != null) {
1037
1038
  for (const toolCallDelta of delta.tool_calls) {
1038
- toolCallTracker.processDelta(
1039
- toolCallDelta,
1040
- controller.enqueue.bind(controller)
1041
- );
1039
+ toolCallTracker.processDelta(toolCallDelta);
1042
1040
  }
1043
1041
  }
1044
1042
  if (delta.annotations != null) {
@@ -1057,7 +1055,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1057
1055
  if (isActiveText) {
1058
1056
  controller.enqueue({ type: "text-end", id: "0" });
1059
1057
  }
1060
- toolCallTracker.flush(controller.enqueue.bind(controller));
1058
+ toolCallTracker.flush();
1061
1059
  controller.enqueue({
1062
1060
  type: "finish",
1063
1061
  finishReason,
@@ -1854,13 +1852,15 @@ var modelMaxImagesPerCall = {
1854
1852
  "gpt-image-1": 10,
1855
1853
  "gpt-image-1-mini": 10,
1856
1854
  "gpt-image-1.5": 10,
1855
+ "gpt-image-2": 10,
1857
1856
  "chatgpt-image-latest": 10
1858
1857
  };
1859
1858
  var defaultResponseFormatPrefixes = [
1860
1859
  "chatgpt-image-",
1861
1860
  "gpt-image-1-mini",
1862
1861
  "gpt-image-1.5",
1863
- "gpt-image-1"
1862
+ "gpt-image-1",
1863
+ "gpt-image-2"
1864
1864
  ];
1865
1865
  function hasDefaultResponseFormat(modelId) {
1866
1866
  return defaultResponseFormatPrefixes.some(
@@ -2072,7 +2072,7 @@ async function fileToBlob(file) {
2072
2072
 
2073
2073
  // src/tool/apply-patch.ts
2074
2074
  import {
2075
- createProviderToolFactoryWithOutputSchema,
2075
+ createProviderDefinedToolFactoryWithOutputSchema,
2076
2076
  lazySchema as lazySchema10,
2077
2077
  zodSchema as zodSchema10
2078
2078
  } from "@ai-sdk/provider-utils";
@@ -2109,7 +2109,7 @@ var applyPatchOutputSchema = lazySchema10(
2109
2109
  )
2110
2110
  );
2111
2111
  var applyPatchArgsSchema = lazySchema10(() => zodSchema10(z11.object({})));
2112
- var applyPatchToolFactory = createProviderToolFactoryWithOutputSchema({
2112
+ var applyPatchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
2113
2113
  id: "openai.apply_patch",
2114
2114
  inputSchema: applyPatchInputSchema,
2115
2115
  outputSchema: applyPatchOutputSchema
@@ -2118,7 +2118,7 @@ var applyPatch = applyPatchToolFactory;
2118
2118
 
2119
2119
  // src/tool/code-interpreter.ts
2120
2120
  import {
2121
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
2121
+ createProviderExecutedToolFactory,
2122
2122
  lazySchema as lazySchema11,
2123
2123
  zodSchema as zodSchema11
2124
2124
  } from "@ai-sdk/provider-utils";
@@ -2155,7 +2155,7 @@ var codeInterpreterArgsSchema = lazySchema11(
2155
2155
  })
2156
2156
  )
2157
2157
  );
2158
- var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema2({
2158
+ var codeInterpreterToolFactory = createProviderExecutedToolFactory({
2159
2159
  id: "openai.code_interpreter",
2160
2160
  inputSchema: codeInterpreterInputSchema,
2161
2161
  outputSchema: codeInterpreterOutputSchema
@@ -2166,7 +2166,7 @@ var codeInterpreter = (args = {}) => {
2166
2166
 
2167
2167
  // src/tool/custom.ts
2168
2168
  import {
2169
- createProviderToolFactory,
2169
+ createProviderDefinedToolFactory,
2170
2170
  lazySchema as lazySchema12,
2171
2171
  zodSchema as zodSchema12
2172
2172
  } from "@ai-sdk/provider-utils";
@@ -2189,7 +2189,7 @@ var customArgsSchema = lazySchema12(
2189
2189
  )
2190
2190
  );
2191
2191
  var customInputSchema = lazySchema12(() => zodSchema12(z13.string()));
2192
- var customToolFactory = createProviderToolFactory({
2192
+ var customToolFactory = createProviderDefinedToolFactory({
2193
2193
  id: "openai.custom",
2194
2194
  inputSchema: customInputSchema
2195
2195
  });
@@ -2197,7 +2197,7 @@ var customTool = (args) => customToolFactory(args);
2197
2197
 
2198
2198
  // src/tool/file-search.ts
2199
2199
  import {
2200
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
2200
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory2,
2201
2201
  lazySchema as lazySchema13,
2202
2202
  zodSchema as zodSchema13
2203
2203
  } from "@ai-sdk/provider-utils";
@@ -2242,7 +2242,7 @@ var fileSearchOutputSchema = lazySchema13(
2242
2242
  })
2243
2243
  )
2244
2244
  );
2245
- var fileSearch = createProviderToolFactoryWithOutputSchema3({
2245
+ var fileSearch = createProviderExecutedToolFactory2({
2246
2246
  id: "openai.file_search",
2247
2247
  inputSchema: z14.object({}),
2248
2248
  outputSchema: fileSearchOutputSchema
@@ -2250,7 +2250,7 @@ var fileSearch = createProviderToolFactoryWithOutputSchema3({
2250
2250
 
2251
2251
  // src/tool/image-generation.ts
2252
2252
  import {
2253
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
2253
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory3,
2254
2254
  lazySchema as lazySchema14,
2255
2255
  zodSchema as zodSchema14
2256
2256
  } from "@ai-sdk/provider-utils";
@@ -2278,7 +2278,7 @@ var imageGenerationInputSchema = lazySchema14(() => zodSchema14(z15.object({})))
2278
2278
  var imageGenerationOutputSchema = lazySchema14(
2279
2279
  () => zodSchema14(z15.object({ result: z15.string() }))
2280
2280
  );
2281
- var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema4({
2281
+ var imageGenerationToolFactory = createProviderExecutedToolFactory3({
2282
2282
  id: "openai.image_generation",
2283
2283
  inputSchema: imageGenerationInputSchema,
2284
2284
  outputSchema: imageGenerationOutputSchema
@@ -2289,7 +2289,7 @@ var imageGeneration = (args = {}) => {
2289
2289
 
2290
2290
  // src/tool/local-shell.ts
2291
2291
  import {
2292
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
2292
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
2293
2293
  lazySchema as lazySchema15,
2294
2294
  zodSchema as zodSchema15
2295
2295
  } from "@ai-sdk/provider-utils";
@@ -2311,7 +2311,7 @@ var localShellInputSchema = lazySchema15(
2311
2311
  var localShellOutputSchema = lazySchema15(
2312
2312
  () => zodSchema15(z16.object({ output: z16.string() }))
2313
2313
  );
2314
- var localShell = createProviderToolFactoryWithOutputSchema5({
2314
+ var localShell = createProviderDefinedToolFactoryWithOutputSchema2({
2315
2315
  id: "openai.local_shell",
2316
2316
  inputSchema: localShellInputSchema,
2317
2317
  outputSchema: localShellOutputSchema
@@ -2319,7 +2319,7 @@ var localShell = createProviderToolFactoryWithOutputSchema5({
2319
2319
 
2320
2320
  // src/tool/shell.ts
2321
2321
  import {
2322
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
2322
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
2323
2323
  lazySchema as lazySchema16,
2324
2324
  zodSchema as zodSchema16
2325
2325
  } from "@ai-sdk/provider-utils";
@@ -2412,7 +2412,7 @@ var shellArgsSchema = lazySchema16(
2412
2412
  })
2413
2413
  )
2414
2414
  );
2415
- var shell = createProviderToolFactoryWithOutputSchema6({
2415
+ var shell = createProviderDefinedToolFactoryWithOutputSchema3({
2416
2416
  id: "openai.shell",
2417
2417
  inputSchema: shellInputSchema,
2418
2418
  outputSchema: shellOutputSchema
@@ -2420,7 +2420,7 @@ var shell = createProviderToolFactoryWithOutputSchema6({
2420
2420
 
2421
2421
  // src/tool/tool-search.ts
2422
2422
  import {
2423
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
2423
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
2424
2424
  lazySchema as lazySchema17,
2425
2425
  zodSchema as zodSchema17
2426
2426
  } from "@ai-sdk/provider-utils";
@@ -2449,7 +2449,7 @@ var toolSearchOutputSchema = lazySchema17(
2449
2449
  })
2450
2450
  )
2451
2451
  );
2452
- var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema7({
2452
+ var toolSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
2453
2453
  id: "openai.tool_search",
2454
2454
  inputSchema: toolSearchInputSchema,
2455
2455
  outputSchema: toolSearchOutputSchema
@@ -2458,7 +2458,7 @@ var toolSearch = (args = {}) => toolSearchToolFactory(args);
2458
2458
 
2459
2459
  // src/tool/web-search.ts
2460
2460
  import {
2461
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
2461
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory4,
2462
2462
  lazySchema as lazySchema18,
2463
2463
  zodSchema as zodSchema18
2464
2464
  } from "@ai-sdk/provider-utils";
@@ -2507,7 +2507,7 @@ var webSearchOutputSchema = lazySchema18(
2507
2507
  })
2508
2508
  )
2509
2509
  );
2510
- var webSearchToolFactory = createProviderToolFactoryWithOutputSchema8({
2510
+ var webSearchToolFactory = createProviderExecutedToolFactory4({
2511
2511
  id: "openai.web_search",
2512
2512
  inputSchema: webSearchInputSchema,
2513
2513
  outputSchema: webSearchOutputSchema
@@ -2516,7 +2516,7 @@ var webSearch = (args = {}) => webSearchToolFactory(args);
2516
2516
 
2517
2517
  // src/tool/web-search-preview.ts
2518
2518
  import {
2519
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
2519
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory5,
2520
2520
  lazySchema as lazySchema19,
2521
2521
  zodSchema as zodSchema19
2522
2522
  } from "@ai-sdk/provider-utils";
@@ -2559,7 +2559,7 @@ var webSearchPreviewOutputSchema = lazySchema19(
2559
2559
  })
2560
2560
  )
2561
2561
  );
2562
- var webSearchPreview = createProviderToolFactoryWithOutputSchema9({
2562
+ var webSearchPreview = createProviderExecutedToolFactory5({
2563
2563
  id: "openai.web_search_preview",
2564
2564
  inputSchema: webSearchPreviewInputSchema,
2565
2565
  outputSchema: webSearchPreviewOutputSchema
@@ -2567,7 +2567,7 @@ var webSearchPreview = createProviderToolFactoryWithOutputSchema9({
2567
2567
 
2568
2568
  // src/tool/mcp.ts
2569
2569
  import {
2570
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
2570
+ createProviderExecutedToolFactory as createProviderExecutedToolFactory6,
2571
2571
  lazySchema as lazySchema20,
2572
2572
  zodSchema as zodSchema20
2573
2573
  } from "@ai-sdk/provider-utils";
@@ -2625,7 +2625,7 @@ var mcpOutputSchema = lazySchema20(
2625
2625
  })
2626
2626
  )
2627
2627
  );
2628
- var mcpToolFactory = createProviderToolFactoryWithOutputSchema10({
2628
+ var mcpToolFactory = createProviderExecutedToolFactory6({
2629
2629
  id: "openai.mcp",
2630
2630
  inputSchema: mcpInputSchema,
2631
2631
  outputSchema: mcpOutputSchema
@@ -3327,7 +3327,7 @@ async function convertToOpenAIResponsesInput({
3327
3327
  outputValue = output.value;
3328
3328
  break;
3329
3329
  case "execution-denied":
3330
- outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
3330
+ outputValue = (_q = output.reason) != null ? _q : "Tool call execution denied.";
3331
3331
  break;
3332
3332
  case "json":
3333
3333
  case "error-json":
@@ -3388,7 +3388,7 @@ async function convertToOpenAIResponsesInput({
3388
3388
  contentValue = output.value;
3389
3389
  break;
3390
3390
  case "execution-denied":
3391
- contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
3391
+ contentValue = (_r = output.reason) != null ? _r : "Tool call execution denied.";
3392
3392
  break;
3393
3393
  case "json":
3394
3394
  case "error-json":
@@ -7069,7 +7069,7 @@ var OpenAISkills = class {
7069
7069
  };
7070
7070
 
7071
7071
  // src/version.ts
7072
- var VERSION = true ? "4.0.0-beta.38" : "0.0.0-test";
7072
+ var VERSION = true ? "4.0.0-beta.39" : "0.0.0-test";
7073
7073
 
7074
7074
  // src/openai-provider.ts
7075
7075
  function createOpenAI(options = {}) {