@ai-sdk/openai 4.0.0-beta.13 → 4.0.0-beta.16

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.
@@ -35,7 +35,7 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
35
35
  // src/openai-language-model-capabilities.ts
36
36
  function getOpenAILanguageModelCapabilities(modelId) {
37
37
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
38
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
38
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
39
39
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
40
40
  const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
41
41
  const systemMessageMode = isReasoningModel ? "developer" : "system";
@@ -2978,7 +2978,7 @@ async function convertToOpenAIResponsesInput({
2978
2978
  break;
2979
2979
  }
2980
2980
  case "custom": {
2981
- if (part.kind === "openai-compaction") {
2981
+ if (part.kind === "openai.compaction") {
2982
2982
  const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
2983
2983
  const id = providerOpts == null ? void 0 : providerOpts.itemId;
2984
2984
  if (hasConversation && id != null) {
@@ -3293,6 +3293,23 @@ var openaiResponsesChunkSchema = lazySchema15(
3293
3293
  service_tier: z17.string().nullish()
3294
3294
  })
3295
3295
  }),
3296
+ z17.object({
3297
+ type: z17.literal("response.failed"),
3298
+ response: z17.object({
3299
+ error: z17.object({
3300
+ code: z17.string().nullish(),
3301
+ message: z17.string()
3302
+ }).nullish(),
3303
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3304
+ usage: z17.object({
3305
+ input_tokens: z17.number(),
3306
+ input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
3307
+ output_tokens: z17.number(),
3308
+ output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
3309
+ }).nullish(),
3310
+ service_tier: z17.string().nullish()
3311
+ })
3312
+ }),
3296
3313
  z17.object({
3297
3314
  type: z17.literal("response.created"),
3298
3315
  response: z17.object({
@@ -4125,6 +4142,10 @@ var openaiResponsesReasoningModelIds = [
4125
4142
  "gpt-5.3-codex",
4126
4143
  "gpt-5.4",
4127
4144
  "gpt-5.4-2026-03-05",
4145
+ "gpt-5.4-mini",
4146
+ "gpt-5.4-mini-2026-03-17",
4147
+ "gpt-5.4-nano",
4148
+ "gpt-5.4-nano-2026-03-17",
4128
4149
  "gpt-5.4-pro",
4129
4150
  "gpt-5.4-pro-2026-03-05"
4130
4151
  ];
@@ -5663,7 +5684,7 @@ var OpenAIResponsesLanguageModel = class {
5663
5684
  case "compaction": {
5664
5685
  content.push({
5665
5686
  type: "custom",
5666
- kind: "openai-compaction",
5687
+ kind: "openai.compaction",
5667
5688
  providerMetadata: {
5668
5689
  [providerOptionsName]: {
5669
5690
  type: "compaction",
@@ -5757,7 +5778,7 @@ var OpenAIResponsesLanguageModel = class {
5757
5778
  controller.enqueue({ type: "stream-start", warnings });
5758
5779
  },
5759
5780
  transform(chunk, controller) {
5760
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
5781
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
5761
5782
  if (options.includeRawChunks) {
5762
5783
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5763
5784
  }
@@ -6306,7 +6327,7 @@ var OpenAIResponsesLanguageModel = class {
6306
6327
  } else if (value.item.type === "compaction") {
6307
6328
  controller.enqueue({
6308
6329
  type: "custom",
6309
- kind: "openai-compaction",
6330
+ kind: "openai.compaction",
6310
6331
  providerMetadata: {
6311
6332
  [providerOptionsName]: {
6312
6333
  type: "compaction",
@@ -6494,13 +6515,23 @@ var OpenAIResponsesLanguageModel = class {
6494
6515
  if (typeof value.response.service_tier === "string") {
6495
6516
  serviceTier = value.response.service_tier;
6496
6517
  }
6518
+ } else if (isResponseFailedChunk(value)) {
6519
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6520
+ finishReason = {
6521
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6522
+ finishReason: incompleteReason,
6523
+ hasFunctionCall
6524
+ }) : "error",
6525
+ raw: incompleteReason != null ? incompleteReason : "error"
6526
+ };
6527
+ usage = (_z = value.response.usage) != null ? _z : void 0;
6497
6528
  } else if (isResponseAnnotationAddedChunk(value)) {
6498
6529
  ongoingAnnotations.push(value.annotation);
6499
6530
  if (value.annotation.type === "url_citation") {
6500
6531
  controller.enqueue({
6501
6532
  type: "source",
6502
6533
  sourceType: "url",
6503
- id: (_A = (_z = (_y = self.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId2(),
6534
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
6504
6535
  url: value.annotation.url,
6505
6536
  title: value.annotation.title
6506
6537
  });
@@ -6508,7 +6539,7 @@ var OpenAIResponsesLanguageModel = class {
6508
6539
  controller.enqueue({
6509
6540
  type: "source",
6510
6541
  sourceType: "document",
6511
- id: (_D = (_C = (_B = self.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId2(),
6542
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
6512
6543
  mediaType: "text/plain",
6513
6544
  title: value.annotation.filename,
6514
6545
  filename: value.annotation.filename,
@@ -6524,7 +6555,7 @@ var OpenAIResponsesLanguageModel = class {
6524
6555
  controller.enqueue({
6525
6556
  type: "source",
6526
6557
  sourceType: "document",
6527
- id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : generateId2(),
6558
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
6528
6559
  mediaType: "text/plain",
6529
6560
  title: value.annotation.filename,
6530
6561
  filename: value.annotation.filename,
@@ -6540,7 +6571,7 @@ var OpenAIResponsesLanguageModel = class {
6540
6571
  controller.enqueue({
6541
6572
  type: "source",
6542
6573
  sourceType: "document",
6543
- id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : generateId2(),
6574
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
6544
6575
  mediaType: "application/octet-stream",
6545
6576
  title: value.annotation.file_id,
6546
6577
  filename: value.annotation.file_id,
@@ -6588,6 +6619,9 @@ function isResponseOutputItemDoneChunk(chunk) {
6588
6619
  function isResponseFinishedChunk(chunk) {
6589
6620
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
6590
6621
  }
6622
+ function isResponseFailedChunk(chunk) {
6623
+ return chunk.type === "response.failed";
6624
+ }
6591
6625
  function isResponseCreatedChunk(chunk) {
6592
6626
  return chunk.type === "response.created";
6593
6627
  }