@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.74
4
+
5
+ ### Patch Changes
6
+
7
+ - 4cf5a99: fix(openai): classify Responses stream errors with null codes
8
+ - 771e74b: chore: enable dead code lint rules
9
+ - Updated dependencies [fe07867]
10
+ - Updated dependencies [a4b0940]
11
+ - Updated dependencies [771e74b]
12
+ - @ai-sdk/provider-utils@5.0.47
13
+
14
+ ## 4.0.73
15
+
16
+ ### Patch Changes
17
+
18
+ - 6d1f881: fix(openai): expose Chat Completions audio transcripts as generated text
19
+ - 618dc11: feat: GPT-6 Sol and Luna model IDs
20
+ - Updated dependencies [ffb0e76]
21
+ - @ai-sdk/provider@4.0.18
22
+ - @ai-sdk/provider-utils@5.0.46
23
+
3
24
  ## 4.0.72
4
25
 
5
26
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -4,13 +4,13 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { InferSchema, FetchFunction, WebSocketConstructor, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } 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;
@@ -226,8 +226,8 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
226
226
  sequence_number: number;
227
227
  error: {
228
228
  type: string;
229
- code: string;
230
229
  message: string;
230
+ code?: string | null | undefined;
231
231
  param?: string | null | undefined;
232
232
  };
233
233
  } | {
@@ -1497,7 +1497,7 @@ interface OpenAIRealtimeFactory extends Experimental_RealtimeFactoryV4 {
1497
1497
  getToken(options: Parameters<Experimental_RealtimeFactoryV4['getToken']>[0] & OpenAIRealtimeOptions): ReturnType<Experimental_RealtimeFactoryV4['getToken']>;
1498
1498
  }
1499
1499
 
1500
- 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 & {});
1500
+ 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 & {});
1501
1501
  declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
1502
1502
  conversation?: string | null | undefined;
1503
1503
  include?: ("web_search_call.results" | "file_search_call.results" | "message.output_text.logprobs" | "reasoning.encrypted_content")[] | null | undefined;
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
53
53
  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);
54
54
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
55
55
  const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
56
+ const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
56
57
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
57
58
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
58
59
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
@@ -63,7 +64,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
63
64
  supportsPriorityProcessing,
64
65
  supportsConfigurationUpdate: isGpt6OrLaterModel,
65
66
  supportsAsyncToolCalling: isGpt6OrLaterModel,
66
- supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
67
+ supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
67
68
  isReasoningModel,
68
69
  systemMessageMode,
69
70
  supportsNonReasoningParameters
@@ -653,6 +654,9 @@ var openaiChatResponseSchema = lazySchema(
653
654
  message: z2.object({
654
655
  role: z2.literal("assistant").nullish(),
655
656
  content: z2.string().nullish(),
657
+ audio: z2.object({
658
+ transcript: z2.string().nullish()
659
+ }).nullish(),
656
660
  tool_calls: z2.array(
657
661
  z2.object({
658
662
  id: z2.string().nullish(),
@@ -1373,7 +1377,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1373
1377
  };
1374
1378
  }
1375
1379
  async doGenerate(options) {
1376
- var _a2, _b, _c, _d, _e, _f, _g;
1380
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
1377
1381
  const { args: body, warnings } = await this.getArgs(options);
1378
1382
  const {
1379
1383
  responseHeaders,
@@ -1401,11 +1405,11 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1401
1405
  });
1402
1406
  }
1403
1407
  const content = [];
1404
- const text = choice.message.content;
1408
+ const text = choice.message.content != null && choice.message.content.length > 0 ? choice.message.content : (_c = choice.message.audio) == null ? void 0 : _c.transcript;
1405
1409
  if (text != null && text.length > 0) {
1406
1410
  content.push({ type: "text", text });
1407
1411
  }
1408
- for (const toolCall of (_c = choice.message.tool_calls) != null ? _c : []) {
1412
+ for (const toolCall of (_d = choice.message.tool_calls) != null ? _d : []) {
1409
1413
  content.push({
1410
1414
  type: "tool-call",
1411
1415
  toolCallId: toolCall.id || generateId(),
@@ -1413,7 +1417,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1413
1417
  input: toolCall.function.arguments
1414
1418
  });
1415
1419
  }
1416
- for (const annotation of (_d = choice.message.annotations) != null ? _d : []) {
1420
+ for (const annotation of (_e = choice.message.annotations) != null ? _e : []) {
1417
1421
  content.push({
1418
1422
  type: "source",
1419
1423
  sourceType: "url",
@@ -1422,7 +1426,7 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1422
1426
  title: annotation.url_citation.title
1423
1427
  });
1424
1428
  }
1425
- const completionTokenDetails = (_e = response.usage) == null ? void 0 : _e.completion_tokens_details;
1429
+ const completionTokenDetails = (_f = response.usage) == null ? void 0 : _f.completion_tokens_details;
1426
1430
  const providerMetadata = { openai: {} };
1427
1431
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
1428
1432
  providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
@@ -1430,14 +1434,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1430
1434
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
1431
1435
  providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
1432
1436
  }
1433
- if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
1437
+ if (((_g = choice.logprobs) == null ? void 0 : _g.content) != null) {
1434
1438
  providerMetadata.openai.logprobs = choice.logprobs.content;
1435
1439
  }
1436
1440
  return {
1437
1441
  content,
1438
1442
  finishReason: {
1439
1443
  unified: mapOpenAIFinishReason(choice.finish_reason),
1440
- raw: (_g = choice.finish_reason) != null ? _g : void 0
1444
+ raw: (_h = choice.finish_reason) != null ? _h : void 0
1441
1445
  },
1442
1446
  usage: convertOpenAIChatUsage(response.usage),
1443
1447
  request: { body },
@@ -3937,7 +3941,7 @@ var openaiResponsesNestedErrorChunkSchema = z25.object({
3937
3941
  sequence_number: z25.number(),
3938
3942
  error: z25.object({
3939
3943
  type: z25.string(),
3940
- code: z25.string(),
3944
+ code: z25.string().nullish(),
3941
3945
  message: z25.string(),
3942
3946
  param: z25.string().nullish()
3943
3947
  })
@@ -6199,7 +6203,9 @@ var openaiResponsesReasoningModelIds = [
6199
6203
  "gpt-5.6-luna",
6200
6204
  "gpt-5.6-sol",
6201
6205
  "gpt-5.6-terra",
6202
- "gpt-6-astra"
6206
+ "gpt-6-astra",
6207
+ "gpt-6-luna",
6208
+ "gpt-6-sol"
6203
6209
  ];
6204
6210
  var openaiResponsesModelIds = [
6205
6211
  "gpt-4.1",
@@ -6923,7 +6929,6 @@ function resolveAsyncToolOption({
6923
6929
  feature: `async tool calling for "${toolName}"`,
6924
6930
  details: "Async tool calling is only supported by GPT-6 and later models."
6925
6931
  });
6926
- return void 0;
6927
6932
  }
6928
6933
  function mapShellEnvironment(environment) {
6929
6934
  if (environment.type === "containerReference") {
@@ -8288,7 +8293,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8288
8293
  } else if (value.item.type === "shell_call_output") {
8289
8294
  } else if (value.item.type === "message") {
8290
8295
  activeOutputItemIds[value.output_index] = value.item.id;
8291
- ongoingAnnotations.splice(0, ongoingAnnotations.length);
8296
+ ongoingAnnotations.splice(0);
8292
8297
  activeMessagePhase = (_c2 = value.item.phase) != null ? _c2 : void 0;
8293
8298
  controller.enqueue({
8294
8299
  type: "text-start",
@@ -12018,7 +12023,7 @@ var OpenAISkills = class {
12018
12023
  };
12019
12024
 
12020
12025
  // src/version.ts
12021
- var VERSION = true ? "4.0.72" : "0.0.0-test";
12026
+ var VERSION = true ? "4.0.74" : "0.0.0-test";
12022
12027
 
12023
12028
  // src/openai-provider.ts
12024
12029
  function createOpenAI(options = {}) {