@ai-sdk/openai 2.1.0-beta.10 → 2.1.0-beta.12

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.
@@ -41,6 +41,7 @@ function convertToOpenAIChatMessages({
41
41
  prompt,
42
42
  systemMessageMode = "system"
43
43
  }) {
44
+ var _a;
44
45
  const messages = [];
45
46
  const warnings = [];
46
47
  for (const { role, content } of prompt) {
@@ -79,7 +80,7 @@ function convertToOpenAIChatMessages({
79
80
  messages.push({
80
81
  role: "user",
81
82
  content: content.map((part, index) => {
82
- var _a, _b, _c;
83
+ var _a2, _b, _c;
83
84
  switch (part.type) {
84
85
  case "text": {
85
86
  return { type: "text", text: part.text };
@@ -92,7 +93,7 @@ function convertToOpenAIChatMessages({
92
93
  image_url: {
93
94
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
94
95
  // OpenAI specific extension: image detail
95
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
96
+ detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
96
97
  }
97
98
  };
98
99
  } else if (part.mediaType.startsWith("audio/")) {
@@ -189,6 +190,9 @@ function convertToOpenAIChatMessages({
189
190
  case "error-text":
190
191
  contentValue = output.value;
191
192
  break;
193
+ case "execution-denied":
194
+ contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
195
+ break;
192
196
  case "content":
193
197
  case "json":
194
198
  case "error-json":
@@ -1783,7 +1787,7 @@ var OpenAITranscriptionModel = class {
1783
1787
  constructor(modelId, config) {
1784
1788
  this.modelId = modelId;
1785
1789
  this.config = config;
1786
- this.specificationVersion = "v2";
1790
+ this.specificationVersion = "v3";
1787
1791
  }
1788
1792
  get provider() {
1789
1793
  return this.config.provider;
@@ -1928,7 +1932,7 @@ var OpenAISpeechModel = class {
1928
1932
  constructor(modelId, config) {
1929
1933
  this.modelId = modelId;
1930
1934
  this.config = config;
1931
- this.specificationVersion = "v2";
1935
+ this.specificationVersion = "v3";
1932
1936
  }
1933
1937
  get provider() {
1934
1938
  return this.config.provider;
@@ -2080,7 +2084,7 @@ async function convertToOpenAIResponsesInput({
2080
2084
  store,
2081
2085
  hasLocalShellTool = false
2082
2086
  }) {
2083
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2087
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2084
2088
  const input = [];
2085
2089
  const warnings = [];
2086
2090
  for (const { role, content } of prompt) {
@@ -2283,6 +2287,9 @@ async function convertToOpenAIResponsesInput({
2283
2287
  case "error-text":
2284
2288
  contentValue = output.value;
2285
2289
  break;
2290
+ case "execution-denied":
2291
+ contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
2292
+ break;
2286
2293
  case "content":
2287
2294
  case "json":
2288
2295
  case "error-json":
@@ -2519,6 +2526,7 @@ var imageGenerationArgsSchema = z18.object({
2519
2526
  moderation: z18.enum(["auto"]).optional(),
2520
2527
  outputCompression: z18.number().int().min(0).max(100).optional(),
2521
2528
  outputFormat: z18.enum(["png", "jpeg", "webp"]).optional(),
2529
+ partialImages: z18.number().int().min(0).max(3).optional(),
2522
2530
  quality: z18.enum(["auto", "low", "medium", "high"]).optional(),
2523
2531
  size: z18.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2524
2532
  }).strict();
@@ -2618,11 +2626,12 @@ function prepareResponsesTools({
2618
2626
  image_url: args.inputImageMask.imageUrl
2619
2627
  } : void 0,
2620
2628
  model: args.model,
2621
- size: args.size,
2622
- quality: args.quality,
2623
2629
  moderation: args.moderation,
2630
+ partial_images: args.partialImages,
2631
+ quality: args.quality,
2632
+ output_compression: args.outputCompression,
2624
2633
  output_format: args.outputFormat,
2625
- output_compression: args.outputCompression
2634
+ size: args.size
2626
2635
  });
2627
2636
  break;
2628
2637
  }
@@ -3581,6 +3590,17 @@ var OpenAIResponsesLanguageModel = class {
3581
3590
  delta: value.delta
3582
3591
  });
3583
3592
  }
3593
+ } else if (isResponseImageGenerationCallPartialImageChunk(value)) {
3594
+ controller.enqueue({
3595
+ type: "tool-result",
3596
+ toolCallId: value.item_id,
3597
+ toolName: "image_generation",
3598
+ result: {
3599
+ result: value.partial_image_b64
3600
+ },
3601
+ providerExecuted: true,
3602
+ preliminary: true
3603
+ });
3584
3604
  } else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
3585
3605
  const toolCall = ongoingToolCalls[value.output_index];
3586
3606
  if (toolCall != null) {
@@ -3853,6 +3873,12 @@ var responseFunctionCallArgumentsDeltaSchema = z19.object({
3853
3873
  output_index: z19.number(),
3854
3874
  delta: z19.string()
3855
3875
  });
3876
+ var responseImageGenerationCallPartialImageSchema = z19.object({
3877
+ type: z19.literal("response.image_generation_call.partial_image"),
3878
+ item_id: z19.string(),
3879
+ output_index: z19.number(),
3880
+ partial_image_b64: z19.string()
3881
+ });
3856
3882
  var responseCodeInterpreterCallCodeDeltaSchema = z19.object({
3857
3883
  type: z19.literal("response.code_interpreter_call_code.delta"),
3858
3884
  item_id: z19.string(),
@@ -3902,6 +3928,7 @@ var openaiResponsesChunkSchema = z19.union([
3902
3928
  responseOutputItemAddedSchema,
3903
3929
  responseOutputItemDoneSchema,
3904
3930
  responseFunctionCallArgumentsDeltaSchema,
3931
+ responseImageGenerationCallPartialImageSchema,
3905
3932
  responseCodeInterpreterCallCodeDeltaSchema,
3906
3933
  responseCodeInterpreterCallCodeDoneSchema,
3907
3934
  responseAnnotationAddedSchema,
@@ -3929,6 +3956,9 @@ function isResponseCreatedChunk(chunk) {
3929
3956
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
3930
3957
  return chunk.type === "response.function_call_arguments.delta";
3931
3958
  }
3959
+ function isResponseImageGenerationCallPartialImageChunk(chunk) {
3960
+ return chunk.type === "response.image_generation_call.partial_image";
3961
+ }
3932
3962
  function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
3933
3963
  return chunk.type === "response.code_interpreter_call_code.delta";
3934
3964
  }