@ai-sdk/openai 4.0.72 → 4.0.74

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.
@@ -4,13 +4,13 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { InferSchema, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, FetchFunction, WebSocketConstructor, EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';
5
5
  import { z } from 'zod/v4';
6
6
 
7
- type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | '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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | (string & {});
7
+ type OpenAIChatModelId = 'o1' | 'o1-2024-12-17' | 'o3-mini' | 'o3-mini-2025-01-31' | 'o3' | 'o3-2025-04-16' | 'o4-mini' | 'o4-mini-2025-04-16' | '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-audio-preview' | 'gpt-4o-audio-preview-2024-12-17' | 'gpt-4o-audio-preview-2025-06-03' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini-audio-preview' | 'gpt-4o-mini-audio-preview-2024-12-17' | 'gpt-4o-search-preview' | 'gpt-4o-search-preview-2025-03-11' | 'gpt-4o-mini-search-preview' | 'gpt-4o-mini-search-preview-2025-03-11' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-16k' | '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.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.3-chat-latest' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6-luna' | 'gpt-6-sol' | (string & {});
8
8
  declare const openaiLanguageModelChatOptions: _ai_sdk_provider_utils.LazySchema<{
9
9
  logitBias?: Record<number, number> | undefined;
10
10
  logprobs?: number | boolean | undefined;
11
11
  parallelToolCalls?: boolean | undefined;
12
12
  user?: string | undefined;
13
- reasoningEffort?: "low" | "medium" | "high" | "xhigh" | "max" | "none" | "minimal" | undefined;
13
+ reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh" | "max" | "minimal" | undefined;
14
14
  maxCompletionTokens?: number | undefined;
15
15
  store?: boolean | undefined;
16
16
  metadata?: Record<string, string> | undefined;
@@ -920,8 +920,8 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
920
920
  sequence_number: number;
921
921
  error: {
922
922
  type: string;
923
- code: string;
924
923
  message: string;
924
+ code?: string | null | undefined;
925
925
  param?: string | null | undefined;
926
926
  };
927
927
  } | {
@@ -1849,7 +1849,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
1849
1849
  }>;
1850
1850
  }, {}>;
1851
1851
 
1852
- type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
1852
+ type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-6-luna' | 'gpt-6-sol' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
1853
1853
 
1854
1854
  declare const openaiResponsesSupportedUrls: Record<string, RegExp[]>;
1855
1855
  declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
@@ -1875,7 +1875,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1875
1875
  webSearchToolName: string | undefined;
1876
1876
  args: {
1877
1877
  tools: OpenAIResponsesTool[] | undefined;
1878
- tool_choice: "auto" | "none" | "required" | {
1878
+ tool_choice: "none" | "auto" | "required" | {
1879
1879
  type: "file_search";
1880
1880
  } | {
1881
1881
  type: "web_search_preview";
@@ -43,6 +43,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
43
43
  const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
44
44
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
45
45
  const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
46
+ const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
46
47
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
47
48
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
48
49
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
@@ -53,7 +54,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
53
54
  supportsPriorityProcessing,
54
55
  supportsConfigurationUpdate: isGpt6OrLaterModel,
55
56
  supportsAsyncToolCalling: isGpt6OrLaterModel,
56
- supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
57
+ supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
57
58
  isReasoningModel,
58
59
  systemMessageMode,
59
60
  supportsNonReasoningParameters
@@ -643,6 +644,9 @@ var openaiChatResponseSchema = lazySchema(
643
644
  message: z2.object({
644
645
  role: z2.literal("assistant").nullish(),
645
646
  content: z2.string().nullish(),
647
+ audio: z2.object({
648
+ transcript: z2.string().nullish()
649
+ }).nullish(),
646
650
  tool_calls: z2.array(
647
651
  z2.object({
648
652
  id: z2.string().nullish(),
@@ -1363,7 +1367,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1363
1367
  };
1364
1368
  }
1365
1369
  async doGenerate(options) {
1366
- var _a2, _b, _c, _d, _e, _f, _g;
1370
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1367
1371
  const { args: body, warnings } = await this.getArgs(options);
1368
1372
  const {
1369
1373
  responseHeaders,
@@ -1391,11 +1395,11 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1391
1395
  });
1392
1396
  }
1393
1397
  const content = [];
1394
- const text = choice.message.content;
1398
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_c = choice.message.audio) == null ? void 0 : _c.transcript;
1395
1399
  if (text != null && text.length > 0) {
1396
1400
  content.push({ type: "text", text });
1397
1401
  }
1398
- for (const toolCall of (_c = choice.message.tool_calls) != null ? _c : []) {
1402
+ for (const toolCall of (_d = choice.message.tool_calls) != null ? _d : []) {
1399
1403
  content.push({
1400
1404
  type: "tool-call",
1401
1405
  toolCallId: toolCall.id || generateId(),
@@ -1403,7 +1407,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1403
1407
  input: toolCall.function.arguments
1404
1408
  });
1405
1409
  }
1406
- for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
1410
+ for (const annotation of (_e = choice.message.annotations) != null ? _e : []) {
1407
1411
  content.push({
1408
1412
  type: "source",
1409
1413
  sourceType: "url",
@@ -1412,7 +1416,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1412
1416
  title: annotation.url_citation.title
1413
1417
  });
1414
1418
  }
1415
- const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
1419
+ const completionTokenDetails = (_f = response.usage) == null ? void 0 : _f.completion_tokens_details;
1416
1420
  const providerMetadata = { openai: {} };
1417
1421
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
1418
1422
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -1420,14 +1424,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1420
1424
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
1421
1425
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
1422
1426
  }
1423
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
1427
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
1424
1428
  providerMetadata.openai.logprobs = choice.logprobs.content;
1425
1429
  }
1426
1430
  return {
1427
1431
  content,
1428
1432
  finishReason: {
1429
1433
  unified: mapOpenAIFinishReason(choice.finish_reason),
1430
- raw: (_g = choice.finish_reason) != null ? _g : void 0
1434
+ raw: (_h = choice.finish_reason) != null ? _h : void 0
1431
1435
  },
1432
1436
  usage: convertOpenAIChatUsage(response.usage),
1433
1437
  request: { body },
@@ -5175,7 +5179,7 @@ var openaiResponsesNestedErrorChunkSchema = z20.object({
5175
5179
  sequence_number: z20.number(),
5176
5180
  error: z20.object({
5177
5181
  type: z20.string(),
5178
- code: z20.string(),
5182
+ code: z20.string().nullish(),
5179
5183
  message: z20.string(),
5180
5184
  param: z20.string().nullish()
5181
5185
  })
@@ -6137,7 +6141,9 @@ var openaiResponsesReasoningModelIds = [
6137
6141
  "gpt-5.6-luna",
6138
6142
  "gpt-5.6-sol",
6139
6143
  "gpt-5.6-terra",
6140
- "gpt-6-astra"
6144
+ "gpt-6-astra",
6145
+ "gpt-6-luna",
6146
+ "gpt-6-sol"
6141
6147
  ];
6142
6148
  var openaiResponsesModelIds = [
6143
6149
  "gpt-4.1",
@@ -7217,7 +7223,6 @@ function resolveAsyncToolOption({
7217
7223
  feature: `async tool calling for "${toolName}"`,
7218
7224
  details: "Async tool calling is only supported by GPT-6 and later models."
7219
7225
  });
7220
- return void 0;
7221
7226
  }
7222
7227
  function mapShellEnvironment(environment) {
7223
7228
  if (environment.type === "containerReference") {
@@ -8582,7 +8587,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8582
8587
  } else if (value.item.type === "shell_call_output") {
8583
8588
  } else if (value.item.type === "message") {
8584
8589
  activeOutputItemIds[value.output_index] = value.item.id;
8585
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
8590
+ ongoingAnnotations.splice(0);
8586
8591
  activeMessagePhase = (_c2 = value.item.phase) != null ? _c2 : void 0;
8587
8592
  controller.enqueue({
8588
8593
  type: "text-start",