@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.
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV2CallOptions, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV3CallOptions, TranscriptionModelV3, SpeechModelV3 } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import { z } from 'zod/v4';
@@ -161,7 +161,7 @@ declare const openAITranscriptionProviderOptions: z.ZodObject<{
161
161
  }, z.core.$strip>;
162
162
  type OpenAITranscriptionProviderOptions = z.infer<typeof openAITranscriptionProviderOptions>;
163
163
 
164
- type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV2CallOptions, 'providerOptions'> & {
164
+ type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV3CallOptions, 'providerOptions'> & {
165
165
  providerOptions?: {
166
166
  openai?: OpenAITranscriptionProviderOptions;
167
167
  };
@@ -171,14 +171,14 @@ interface OpenAITranscriptionModelConfig extends OpenAIConfig {
171
171
  currentDate?: () => Date;
172
172
  };
173
173
  }
174
- declare class OpenAITranscriptionModel implements TranscriptionModelV2 {
174
+ declare class OpenAITranscriptionModel implements TranscriptionModelV3 {
175
175
  readonly modelId: OpenAITranscriptionModelId;
176
176
  private readonly config;
177
- readonly specificationVersion = "v2";
177
+ readonly specificationVersion = "v3";
178
178
  get provider(): string;
179
179
  constructor(modelId: OpenAITranscriptionModelId, config: OpenAITranscriptionModelConfig);
180
180
  private getArgs;
181
- doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV2['doGenerate']>>>;
181
+ doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>>;
182
182
  }
183
183
 
184
184
  type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string & {});
@@ -193,14 +193,14 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
193
193
  currentDate?: () => Date;
194
194
  };
195
195
  }
196
- declare class OpenAISpeechModel implements SpeechModelV2 {
196
+ declare class OpenAISpeechModel implements SpeechModelV3 {
197
197
  readonly modelId: OpenAISpeechModelId;
198
198
  private readonly config;
199
- readonly specificationVersion = "v2";
199
+ readonly specificationVersion = "v3";
200
200
  get provider(): string;
201
201
  constructor(modelId: OpenAISpeechModelId, config: OpenAISpeechModelConfig);
202
202
  private getArgs;
203
- doGenerate(options: Parameters<SpeechModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV2['doGenerate']>>>;
203
+ doGenerate(options: Parameters<SpeechModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>>;
204
204
  }
205
205
 
206
206
  type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
@@ -482,6 +482,7 @@ declare const imageGenerationArgsSchema: z.ZodObject<{
482
482
  jpeg: "jpeg";
483
483
  webp: "webp";
484
484
  }>>;
485
+ partialImages: z.ZodOptional<z.ZodNumber>;
485
486
  quality: z.ZodOptional<z.ZodEnum<{
486
487
  low: "low";
487
488
  medium: "medium";
@@ -538,6 +539,10 @@ type ImageGenerationArgs = {
538
539
  * Default: png
539
540
  */
540
541
  outputFormat?: 'png' | 'jpeg' | 'webp';
542
+ /**
543
+ * Number of partial images to generate in streaming mode, from 0 (default value) to 3.
544
+ */
545
+ partialImages?: number;
541
546
  /**
542
547
  * The quality of the generated image.
543
548
  * One of low, medium, high, or auto. Default: auto.
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV2CallOptions, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV3CallOptions, TranscriptionModelV3, SpeechModelV3 } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
4
  import { z } from 'zod/v4';
@@ -161,7 +161,7 @@ declare const openAITranscriptionProviderOptions: z.ZodObject<{
161
161
  }, z.core.$strip>;
162
162
  type OpenAITranscriptionProviderOptions = z.infer<typeof openAITranscriptionProviderOptions>;
163
163
 
164
- type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV2CallOptions, 'providerOptions'> & {
164
+ type OpenAITranscriptionCallOptions = Omit<TranscriptionModelV3CallOptions, 'providerOptions'> & {
165
165
  providerOptions?: {
166
166
  openai?: OpenAITranscriptionProviderOptions;
167
167
  };
@@ -171,14 +171,14 @@ interface OpenAITranscriptionModelConfig extends OpenAIConfig {
171
171
  currentDate?: () => Date;
172
172
  };
173
173
  }
174
- declare class OpenAITranscriptionModel implements TranscriptionModelV2 {
174
+ declare class OpenAITranscriptionModel implements TranscriptionModelV3 {
175
175
  readonly modelId: OpenAITranscriptionModelId;
176
176
  private readonly config;
177
- readonly specificationVersion = "v2";
177
+ readonly specificationVersion = "v3";
178
178
  get provider(): string;
179
179
  constructor(modelId: OpenAITranscriptionModelId, config: OpenAITranscriptionModelConfig);
180
180
  private getArgs;
181
- doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV2['doGenerate']>>>;
181
+ doGenerate(options: OpenAITranscriptionCallOptions): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>>;
182
182
  }
183
183
 
184
184
  type OpenAISpeechModelId = 'tts-1' | 'tts-1-hd' | 'gpt-4o-mini-tts' | (string & {});
@@ -193,14 +193,14 @@ interface OpenAISpeechModelConfig extends OpenAIConfig {
193
193
  currentDate?: () => Date;
194
194
  };
195
195
  }
196
- declare class OpenAISpeechModel implements SpeechModelV2 {
196
+ declare class OpenAISpeechModel implements SpeechModelV3 {
197
197
  readonly modelId: OpenAISpeechModelId;
198
198
  private readonly config;
199
- readonly specificationVersion = "v2";
199
+ readonly specificationVersion = "v3";
200
200
  get provider(): string;
201
201
  constructor(modelId: OpenAISpeechModelId, config: OpenAISpeechModelConfig);
202
202
  private getArgs;
203
- doGenerate(options: Parameters<SpeechModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV2['doGenerate']>>>;
203
+ doGenerate(options: Parameters<SpeechModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>>;
204
204
  }
205
205
 
206
206
  type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'gpt-5' | 'gpt-5-2025-08-07' | 'gpt-5-mini' | 'gpt-5-mini-2025-08-07' | 'gpt-5-nano' | 'gpt-5-nano-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-4.1' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4' | 'gpt-4-0613' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
@@ -482,6 +482,7 @@ declare const imageGenerationArgsSchema: z.ZodObject<{
482
482
  jpeg: "jpeg";
483
483
  webp: "webp";
484
484
  }>>;
485
+ partialImages: z.ZodOptional<z.ZodNumber>;
485
486
  quality: z.ZodOptional<z.ZodEnum<{
486
487
  low: "low";
487
488
  medium: "medium";
@@ -538,6 +539,10 @@ type ImageGenerationArgs = {
538
539
  * Default: png
539
540
  */
540
541
  outputFormat?: 'png' | 'jpeg' | 'webp';
542
+ /**
543
+ * Number of partial images to generate in streaming mode, from 0 (default value) to 3.
544
+ */
545
+ partialImages?: number;
541
546
  /**
542
547
  * The quality of the generated image.
543
548
  * One of low, medium, high, or auto. Default: auto.
@@ -78,6 +78,7 @@ function convertToOpenAIChatMessages({
78
78
  prompt,
79
79
  systemMessageMode = "system"
80
80
  }) {
81
+ var _a;
81
82
  const messages = [];
82
83
  const warnings = [];
83
84
  for (const { role, content } of prompt) {
@@ -116,7 +117,7 @@ function convertToOpenAIChatMessages({
116
117
  messages.push({
117
118
  role: "user",
118
119
  content: content.map((part, index) => {
119
- var _a, _b, _c;
120
+ var _a2, _b, _c;
120
121
  switch (part.type) {
121
122
  case "text": {
122
123
  return { type: "text", text: part.text };
@@ -129,7 +130,7 @@ function convertToOpenAIChatMessages({
129
130
  image_url: {
130
131
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
131
132
  // OpenAI specific extension: image detail
132
- detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
133
+ detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
133
134
  }
134
135
  };
135
136
  } else if (part.mediaType.startsWith("audio/")) {
@@ -226,6 +227,9 @@ function convertToOpenAIChatMessages({
226
227
  case "error-text":
227
228
  contentValue = output.value;
228
229
  break;
230
+ case "execution-denied":
231
+ contentValue = (_a = output.reason) != null ? _a : "Tool execution denied.";
232
+ break;
229
233
  case "content":
230
234
  case "json":
231
235
  case "error-json":
@@ -1791,7 +1795,7 @@ var OpenAITranscriptionModel = class {
1791
1795
  constructor(modelId, config) {
1792
1796
  this.modelId = modelId;
1793
1797
  this.config = config;
1794
- this.specificationVersion = "v2";
1798
+ this.specificationVersion = "v3";
1795
1799
  }
1796
1800
  get provider() {
1797
1801
  return this.config.provider;
@@ -1931,7 +1935,7 @@ var OpenAISpeechModel = class {
1931
1935
  constructor(modelId, config) {
1932
1936
  this.modelId = modelId;
1933
1937
  this.config = config;
1934
- this.specificationVersion = "v2";
1938
+ this.specificationVersion = "v3";
1935
1939
  }
1936
1940
  get provider() {
1937
1941
  return this.config.provider;
@@ -2072,7 +2076,7 @@ async function convertToOpenAIResponsesInput({
2072
2076
  store,
2073
2077
  hasLocalShellTool = false
2074
2078
  }) {
2075
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2079
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2076
2080
  const input = [];
2077
2081
  const warnings = [];
2078
2082
  for (const { role, content } of prompt) {
@@ -2275,6 +2279,9 @@ async function convertToOpenAIResponsesInput({
2275
2279
  case "error-text":
2276
2280
  contentValue = output.value;
2277
2281
  break;
2282
+ case "execution-denied":
2283
+ contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
2284
+ break;
2278
2285
  case "content":
2279
2286
  case "json":
2280
2287
  case "error-json":
@@ -2509,6 +2516,7 @@ var imageGenerationArgsSchema = import_v418.z.object({
2509
2516
  moderation: import_v418.z.enum(["auto"]).optional(),
2510
2517
  outputCompression: import_v418.z.number().int().min(0).max(100).optional(),
2511
2518
  outputFormat: import_v418.z.enum(["png", "jpeg", "webp"]).optional(),
2519
+ partialImages: import_v418.z.number().int().min(0).max(3).optional(),
2512
2520
  quality: import_v418.z.enum(["auto", "low", "medium", "high"]).optional(),
2513
2521
  size: import_v418.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2514
2522
  }).strict();
@@ -2608,11 +2616,12 @@ function prepareResponsesTools({
2608
2616
  image_url: args.inputImageMask.imageUrl
2609
2617
  } : void 0,
2610
2618
  model: args.model,
2611
- size: args.size,
2612
- quality: args.quality,
2613
2619
  moderation: args.moderation,
2620
+ partial_images: args.partialImages,
2621
+ quality: args.quality,
2622
+ output_compression: args.outputCompression,
2614
2623
  output_format: args.outputFormat,
2615
- output_compression: args.outputCompression
2624
+ size: args.size
2616
2625
  });
2617
2626
  break;
2618
2627
  }
@@ -3571,6 +3580,17 @@ var OpenAIResponsesLanguageModel = class {
3571
3580
  delta: value.delta
3572
3581
  });
3573
3582
  }
3583
+ } else if (isResponseImageGenerationCallPartialImageChunk(value)) {
3584
+ controller.enqueue({
3585
+ type: "tool-result",
3586
+ toolCallId: value.item_id,
3587
+ toolName: "image_generation",
3588
+ result: {
3589
+ result: value.partial_image_b64
3590
+ },
3591
+ providerExecuted: true,
3592
+ preliminary: true
3593
+ });
3574
3594
  } else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
3575
3595
  const toolCall = ongoingToolCalls[value.output_index];
3576
3596
  if (toolCall != null) {
@@ -3843,6 +3863,12 @@ var responseFunctionCallArgumentsDeltaSchema = import_v419.z.object({
3843
3863
  output_index: import_v419.z.number(),
3844
3864
  delta: import_v419.z.string()
3845
3865
  });
3866
+ var responseImageGenerationCallPartialImageSchema = import_v419.z.object({
3867
+ type: import_v419.z.literal("response.image_generation_call.partial_image"),
3868
+ item_id: import_v419.z.string(),
3869
+ output_index: import_v419.z.number(),
3870
+ partial_image_b64: import_v419.z.string()
3871
+ });
3846
3872
  var responseCodeInterpreterCallCodeDeltaSchema = import_v419.z.object({
3847
3873
  type: import_v419.z.literal("response.code_interpreter_call_code.delta"),
3848
3874
  item_id: import_v419.z.string(),
@@ -3892,6 +3918,7 @@ var openaiResponsesChunkSchema = import_v419.z.union([
3892
3918
  responseOutputItemAddedSchema,
3893
3919
  responseOutputItemDoneSchema,
3894
3920
  responseFunctionCallArgumentsDeltaSchema,
3921
+ responseImageGenerationCallPartialImageSchema,
3895
3922
  responseCodeInterpreterCallCodeDeltaSchema,
3896
3923
  responseCodeInterpreterCallCodeDoneSchema,
3897
3924
  responseAnnotationAddedSchema,
@@ -3919,6 +3946,9 @@ function isResponseCreatedChunk(chunk) {
3919
3946
  function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
3920
3947
  return chunk.type === "response.function_call_arguments.delta";
3921
3948
  }
3949
+ function isResponseImageGenerationCallPartialImageChunk(chunk) {
3950
+ return chunk.type === "response.image_generation_call.partial_image";
3951
+ }
3922
3952
  function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
3923
3953
  return chunk.type === "response.code_interpreter_call_code.delta";
3924
3954
  }