@ai-sdk/openai 2.1.0-beta.9 → 3.0.0-beta.17

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
@@ -49,6 +49,7 @@ function convertToOpenAIChatMessages({
49
49
  prompt,
50
50
  systemMessageMode = "system"
51
51
  }) {
52
+ var _a;
52
53
  const messages = [];
53
54
  const warnings = [];
54
55
  for (const { role, content } of prompt) {
@@ -87,7 +88,7 @@ function convertToOpenAIChatMessages({
87
88
  messages.push({
88
89
  role: "user",
89
90
  content: content.map((part, index) => {
90
- var _a, _b, _c;
91
+ var _a2, _b, _c;
91
92
  switch (part.type) {
92
93
  case "text": {
93
94
  return { type: "text", text: part.text };
@@ -100,7 +101,7 @@ function convertToOpenAIChatMessages({
100
101
  image_url: {
101
102
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
102
103
  // OpenAI specific extension: image detail
103
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
104
+ detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
104
105
  }
105
106
  };
106
107
  } else if (part.mediaType.startsWith("audio/")) {
@@ -197,6 +198,9 @@ function convertToOpenAIChatMessages({
197
198
  case "error-text":
198
199
  contentValue = output.value;
199
200
  break;
201
+ case "execution-denied":
202
+ contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
203
+ break;
200
204
  case "content":
201
205
  case "json":
202
206
  case "error-json":
@@ -1601,9 +1605,13 @@ import { z as z8 } from "zod/v4";
1601
1605
  var modelMaxImagesPerCall = {
1602
1606
  "dall-e-3": 1,
1603
1607
  "dall-e-2": 10,
1604
- "gpt-image-1": 10
1608
+ "gpt-image-1": 10,
1609
+ "gpt-image-1-mini": 10
1605
1610
  };
1606
- var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1611
+ var hasDefaultResponseFormat = /* @__PURE__ */ new Set([
1612
+ "gpt-image-1",
1613
+ "gpt-image-1-mini"
1614
+ ]);
1607
1615
 
1608
1616
  // src/image/openai-image-model.ts
1609
1617
  var OpenAIImageModel = class {
@@ -1778,6 +1786,7 @@ var imageGenerationArgsSchema = z11.object({
1778
1786
  moderation: z11.enum(["auto"]).optional(),
1779
1787
  outputCompression: z11.number().int().min(0).max(100).optional(),
1780
1788
  outputFormat: z11.enum(["png", "jpeg", "webp"]).optional(),
1789
+ partialImages: z11.number().int().min(0).max(3).optional(),
1781
1790
  quality: z11.enum(["auto", "low", "medium", "high"]).optional(),
1782
1791
  size: z11.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
1783
1792
  }).strict();
@@ -1949,11 +1958,16 @@ var openaiTools = {
1949
1958
  *
1950
1959
  * Must have name `image_generation`.
1951
1960
  *
1952
- * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)
1953
- * @param quality - Rendering quality (e.g. low, medium, high)
1954
- * @param format - File output format
1955
- * @param compression - Compression level (0-100%) for JPEG and WebP formats
1956
- * @param background - Transparent or opaque
1961
+ * @param background - Background type for the generated image. One of 'auto', 'opaque', or 'transparent'.
1962
+ * @param inputFidelity - Input fidelity for the generated image. One of 'low' or 'high'.
1963
+ * @param inputImageMask - Optional mask for inpainting. Contains fileId and/or imageUrl.
1964
+ * @param model - The image generation model to use. Default: gpt-image-1.
1965
+ * @param moderation - Moderation level for the generated image. Default: 'auto'.
1966
+ * @param outputCompression - Compression level for the output image (0-100).
1967
+ * @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
1968
+ * @param partialImages - Number of partial images to generate in streaming mode (0-3).
1969
+ * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
1970
+ * @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
1957
1971
  */
1958
1972
  imageGeneration,
1959
1973
  /**
@@ -2021,7 +2035,7 @@ async function convertToOpenAIResponsesInput({
2021
2035
  store,
2022
2036
  hasLocalShellTool = false
2023
2037
  }) {
2024
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2038
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2025
2039
  const input = [];
2026
2040
  const warnings = [];
2027
2041
  for (const { role, content } of prompt) {
@@ -2224,6 +2238,9 @@ async function convertToOpenAIResponsesInput({
2224
2238
  case "error-text":
2225
2239
  contentValue = output.value;
2226
2240
  break;
2241
+ case "execution-denied":
2242
+ contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
2243
+ break;
2227
2244
  case "content":
2228
2245
  case "json":
2229
2246
  case "error-json":
@@ -2355,11 +2372,12 @@ function prepareResponsesTools({
2355
2372
  image_url: args.inputImageMask.imageUrl
2356
2373
  } : void 0,
2357
2374
  model: args.model,
2358
- size: args.size,
2359
- quality: args.quality,
2360
2375
  moderation: args.moderation,
2376
+ partial_images: args.partialImages,
2377
+ quality: args.quality,
2378
+ output_compression: args.outputCompression,
2361
2379
  output_format: args.outputFormat,
2362
- output_compression: args.outputCompression
2380
+ size: args.size
2363
2381
  });
2364
2382
  break;
2365
2383
  }
@@ -3095,7 +3113,8 @@ var OpenAIResponsesLanguageModel = class {
3095
3113
  controller.enqueue({
3096
3114
  type: "tool-input-start",
3097
3115
  id: value.item.id,
3098
- toolName: webSearchToolName != null ? webSearchToolName : "web_search"
3116
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3117
+ providerExecuted: true
3099
3118
  });
3100
3119
  } else if (value.item.type === "computer_call") {
3101
3120
  ongoingToolCalls[value.output_index] = {
@@ -3105,7 +3124,8 @@ var OpenAIResponsesLanguageModel = class {
3105
3124
  controller.enqueue({
3106
3125
  type: "tool-input-start",
3107
3126
  id: value.item.id,
3108
- toolName: "computer_use"
3127
+ toolName: "computer_use",
3128
+ providerExecuted: true
3109
3129
  });
3110
3130
  } else if (value.item.type === "code_interpreter_call") {
3111
3131
  ongoingToolCalls[value.output_index] = {
@@ -3118,7 +3138,8 @@ var OpenAIResponsesLanguageModel = class {
3118
3138
  controller.enqueue({
3119
3139
  type: "tool-input-start",
3120
3140
  id: value.item.id,
3121
- toolName: "code_interpreter"
3141
+ toolName: "code_interpreter",
3142
+ providerExecuted: true
3122
3143
  });
3123
3144
  controller.enqueue({
3124
3145
  type: "tool-input-delta",
@@ -3318,6 +3339,17 @@ var OpenAIResponsesLanguageModel = class {
3318
3339
  delta: value.delta
3319
3340
  });
3320
3341
  }
3342
+ } else if (isResponseImageGenerationCallPartialImageChunk(value)) {
3343
+ controller.enqueue({
3344
+ type: "tool-result",
3345
+ toolCallId: value.item_id,
3346
+ toolName: "image_generation",
3347
+ result: {
3348
+ result: value.partial_image_b64
3349
+ },
3350
+ providerExecuted: true,
3351
+ preliminary: true
3352
+ });
3321
3353
  } else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
3322
3354
  const toolCall = ongoingToolCalls[value.output_index];
3323
3355
  if (toolCall != null) {
@@ -3590,6 +3622,12 @@ var responseFunctionCallArgumentsDeltaSchema = z16.object({
3590
3622
  output_index: z16.number(),
3591
3623
  delta: z16.string()
3592
3624
  });
3625
+ var responseImageGenerationCallPartialImageSchema = z16.object({
3626
+ type: z16.literal("response.image_generation_call.partial_image"),
3627
+ item_id: z16.string(),
3628
+ output_index: z16.number(),
3629
+ partial_image_b64: z16.string()
3630
+ });
3593
3631
  var responseCodeInterpreterCallCodeDeltaSchema = z16.object({
3594
3632
  type: z16.literal("response.code_interpreter_call_code.delta"),
3595
3633
  item_id: z16.string(),
@@ -3639,6 +3677,7 @@ var openaiResponsesChunkSchema = z16.union([
3639
3677
  responseOutputItemAddedSchema,
3640
3678
  responseOutputItemDoneSchema,
3641
3679
  responseFunctionCallArgumentsDeltaSchema,
3680
+ responseImageGenerationCallPartialImageSchema,
3642
3681
  responseCodeInterpreterCallCodeDeltaSchema,
3643
3682
  responseCodeInterpreterCallCodeDoneSchema,
3644
3683
  responseAnnotationAddedSchema,
@@ -3666,6 +3705,9 @@ function isResponseCreatedChunk(chunk) {
3666
3705
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
3667
3706
  return chunk.type === "response.function_call_arguments.delta";
3668
3707
  }
3708
+ function isResponseImageGenerationCallPartialImageChunk(chunk) {
3709
+ return chunk.type === "response.image_generation_call.partial_image";
3710
+ }
3669
3711
  function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
3670
3712
  return chunk.type === "response.code_interpreter_call_code.delta";
3671
3713
  }
@@ -3782,7 +3824,7 @@ var OpenAISpeechModel = class {
3782
3824
  constructor(modelId, config) {
3783
3825
  this.modelId = modelId;
3784
3826
  this.config = config;
3785
- this.specificationVersion = "v2";
3827
+ this.specificationVersion = "v3";
3786
3828
  }
3787
3829
  get provider() {
3788
3830
  return this.config.provider;
@@ -3980,7 +4022,7 @@ var OpenAITranscriptionModel = class {
3980
4022
  constructor(modelId, config) {
3981
4023
  this.modelId = modelId;
3982
4024
  this.config = config;
3983
- this.specificationVersion = "v2";
4025
+ this.specificationVersion = "v3";
3984
4026
  }
3985
4027
  get provider() {
3986
4028
  return this.config.provider;
@@ -4110,7 +4152,7 @@ var openaiTranscriptionResponseSchema = z19.object({
4110
4152
  });
4111
4153
 
4112
4154
  // src/version.ts
4113
- var VERSION = true ? "2.1.0-beta.9" : "0.0.0-test";
4155
+ var VERSION = true ? "3.0.0-beta.17" : "0.0.0-test";
4114
4156
 
4115
4157
  // src/openai-provider.ts
4116
4158
  function createOpenAI(options = {}) {