@ai-sdk/openai 2.0.74 → 2.0.76

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/dist/index.mjs CHANGED
@@ -1678,12 +1678,26 @@ import { z as z8 } from "zod/v4";
1678
1678
  var openaiImageResponseSchema = lazyValidator7(
1679
1679
  () => zodSchema7(
1680
1680
  z8.object({
1681
+ created: z8.number().nullish(),
1681
1682
  data: z8.array(
1682
1683
  z8.object({
1683
1684
  b64_json: z8.string(),
1684
1685
  revised_prompt: z8.string().nullish()
1685
1686
  })
1686
- )
1687
+ ),
1688
+ background: z8.string().nullish(),
1689
+ output_format: z8.string().nullish(),
1690
+ size: z8.string().nullish(),
1691
+ quality: z8.string().nullish(),
1692
+ usage: z8.object({
1693
+ input_tokens: z8.number().nullish(),
1694
+ output_tokens: z8.number().nullish(),
1695
+ total_tokens: z8.number().nullish(),
1696
+ input_tokens_details: z8.object({
1697
+ image_tokens: z8.number().nullish(),
1698
+ text_tokens: z8.number().nullish()
1699
+ }).nullish()
1700
+ }).nullish()
1687
1701
  })
1688
1702
  )
1689
1703
  );
@@ -1768,11 +1782,14 @@ var OpenAIImageModel = class {
1768
1782
  },
1769
1783
  providerMetadata: {
1770
1784
  openai: {
1771
- images: response.data.map(
1772
- (item) => item.revised_prompt ? {
1773
- revisedPrompt: item.revised_prompt
1774
- } : null
1775
- )
1785
+ images: response.data.map((item) => ({
1786
+ ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
1787
+ ...response.created != null ? { created: response.created } : {},
1788
+ ...response.size != null ? { size: response.size } : {},
1789
+ ...response.quality != null ? { quality: response.quality } : {},
1790
+ ...response.background != null ? { background: response.background } : {},
1791
+ ...response.output_format != null ? { outputFormat: response.output_format } : {}
1792
+ }))
1776
1793
  }
1777
1794
  }
1778
1795
  };
@@ -3413,7 +3430,7 @@ var OpenAIResponsesLanguageModel = class {
3413
3430
  };
3414
3431
  }
3415
3432
  async doGenerate(options) {
3416
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3433
+ 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;
3417
3434
  const {
3418
3435
  args: body,
3419
3436
  warnings,
@@ -3423,6 +3440,7 @@ var OpenAIResponsesLanguageModel = class {
3423
3440
  path: "/responses",
3424
3441
  modelId: this.modelId
3425
3442
  });
3443
+ const providerKey = this.config.provider.replace(".responses", "");
3426
3444
  const {
3427
3445
  responseHeaders,
3428
3446
  value: response,
@@ -3463,7 +3481,7 @@ var OpenAIResponsesLanguageModel = class {
3463
3481
  type: "reasoning",
3464
3482
  text: summary.text,
3465
3483
  providerMetadata: {
3466
- openai: {
3484
+ [providerKey]: {
3467
3485
  itemId: part.id,
3468
3486
  reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
3469
3487
  }
@@ -3500,7 +3518,7 @@ var OpenAIResponsesLanguageModel = class {
3500
3518
  action: part.action
3501
3519
  }),
3502
3520
  providerMetadata: {
3503
- openai: {
3521
+ [providerKey]: {
3504
3522
  itemId: part.id
3505
3523
  }
3506
3524
  }
@@ -3516,7 +3534,7 @@ var OpenAIResponsesLanguageModel = class {
3516
3534
  type: "text",
3517
3535
  text: contentPart.text,
3518
3536
  providerMetadata: {
3519
- openai: {
3537
+ [providerKey]: {
3520
3538
  itemId: part.id
3521
3539
  }
3522
3540
  }
@@ -3540,12 +3558,43 @@ var OpenAIResponsesLanguageModel = class {
3540
3558
  filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
3541
3559
  ...annotation.file_id ? {
3542
3560
  providerMetadata: {
3543
- openai: {
3561
+ [providerKey]: {
3544
3562
  fileId: annotation.file_id
3545
3563
  }
3546
3564
  }
3547
3565
  } : {}
3548
3566
  });
3567
+ } else if (annotation.type === "container_file_citation") {
3568
+ content.push({
3569
+ type: "source",
3570
+ sourceType: "document",
3571
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
3572
+ mediaType: "text/plain",
3573
+ title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
3574
+ filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
3575
+ providerMetadata: {
3576
+ [providerKey]: {
3577
+ fileId: annotation.file_id,
3578
+ containerId: annotation.container_id,
3579
+ ...annotation.index != null ? { index: annotation.index } : {}
3580
+ }
3581
+ }
3582
+ });
3583
+ } else if (annotation.type === "file_path") {
3584
+ content.push({
3585
+ type: "source",
3586
+ sourceType: "document",
3587
+ id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
3588
+ mediaType: "application/octet-stream",
3589
+ title: annotation.file_id,
3590
+ filename: annotation.file_id,
3591
+ providerMetadata: {
3592
+ [providerKey]: {
3593
+ fileId: annotation.file_id,
3594
+ ...annotation.index != null ? { index: annotation.index } : {}
3595
+ }
3596
+ }
3597
+ });
3549
3598
  }
3550
3599
  }
3551
3600
  }
@@ -3559,7 +3608,7 @@ var OpenAIResponsesLanguageModel = class {
3559
3608
  toolName: part.name,
3560
3609
  input: part.arguments,
3561
3610
  providerMetadata: {
3562
- openai: {
3611
+ [providerKey]: {
3563
3612
  itemId: part.id
3564
3613
  }
3565
3614
  }
@@ -3617,13 +3666,13 @@ var OpenAIResponsesLanguageModel = class {
3617
3666
  toolName: "file_search",
3618
3667
  result: {
3619
3668
  queries: part.queries,
3620
- results: (_n = (_m = part.results) == null ? void 0 : _m.map((result) => ({
3669
+ results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
3621
3670
  attributes: result.attributes,
3622
3671
  fileId: result.file_id,
3623
3672
  filename: result.filename,
3624
3673
  score: result.score,
3625
3674
  text: result.text
3626
- }))) != null ? _n : null
3675
+ }))) != null ? _w : null
3627
3676
  },
3628
3677
  providerExecuted: true
3629
3678
  });
@@ -3654,29 +3703,29 @@ var OpenAIResponsesLanguageModel = class {
3654
3703
  }
3655
3704
  }
3656
3705
  const providerMetadata = {
3657
- openai: {
3706
+ [providerKey]: {
3658
3707
  ...response.id != null ? { responseId: response.id } : {}
3659
3708
  }
3660
3709
  };
3661
3710
  if (logprobs.length > 0) {
3662
- providerMetadata.openai.logprobs = logprobs;
3711
+ providerMetadata[providerKey].logprobs = logprobs;
3663
3712
  }
3664
3713
  if (typeof response.service_tier === "string") {
3665
- providerMetadata.openai.serviceTier = response.service_tier;
3714
+ providerMetadata[providerKey].serviceTier = response.service_tier;
3666
3715
  }
3667
3716
  const usage = response.usage;
3668
3717
  return {
3669
3718
  content,
3670
3719
  finishReason: mapOpenAIResponseFinishReason({
3671
- finishReason: (_o = response.incomplete_details) == null ? void 0 : _o.reason,
3720
+ finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
3672
3721
  hasFunctionCall
3673
3722
  }),
3674
3723
  usage: {
3675
3724
  inputTokens: usage.input_tokens,
3676
3725
  outputTokens: usage.output_tokens,
3677
3726
  totalTokens: usage.input_tokens + usage.output_tokens,
3678
- reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
3679
- cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
3727
+ reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
3728
+ cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
3680
3729
  },
3681
3730
  request: { body },
3682
3731
  response: {
@@ -3715,6 +3764,7 @@ var OpenAIResponsesLanguageModel = class {
3715
3764
  fetch: this.config.fetch
3716
3765
  });
3717
3766
  const self = this;
3767
+ const providerKey = this.config.provider.replace(".responses", "");
3718
3768
  let finishReason = "unknown";
3719
3769
  const usage = {
3720
3770
  inputTokens: void 0,
@@ -3830,7 +3880,7 @@ var OpenAIResponsesLanguageModel = class {
3830
3880
  type: "text-start",
3831
3881
  id: value.item.id,
3832
3882
  providerMetadata: {
3833
- openai: {
3883
+ [providerKey]: {
3834
3884
  itemId: value.item.id
3835
3885
  }
3836
3886
  }
@@ -3844,7 +3894,7 @@ var OpenAIResponsesLanguageModel = class {
3844
3894
  type: "reasoning-start",
3845
3895
  id: `${value.item.id}:0`,
3846
3896
  providerMetadata: {
3847
- openai: {
3897
+ [providerKey]: {
3848
3898
  itemId: value.item.id,
3849
3899
  reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
3850
3900
  }
@@ -3857,7 +3907,7 @@ var OpenAIResponsesLanguageModel = class {
3857
3907
  type: "text-end",
3858
3908
  id: value.item.id,
3859
3909
  providerMetadata: {
3860
- openai: {
3910
+ [providerKey]: {
3861
3911
  itemId: value.item.id,
3862
3912
  ...ongoingAnnotations.length > 0 && {
3863
3913
  annotations: ongoingAnnotations
@@ -3878,7 +3928,7 @@ var OpenAIResponsesLanguageModel = class {
3878
3928
  toolName: value.item.name,
3879
3929
  input: value.item.arguments,
3880
3930
  providerMetadata: {
3881
- openai: {
3931
+ [providerKey]: {
3882
3932
  itemId: value.item.id
3883
3933
  }
3884
3934
  }
@@ -3971,7 +4021,7 @@ var OpenAIResponsesLanguageModel = class {
3971
4021
  }
3972
4022
  }),
3973
4023
  providerMetadata: {
3974
- openai: { itemId: value.item.id }
4024
+ [providerKey]: { itemId: value.item.id }
3975
4025
  }
3976
4026
  });
3977
4027
  } else if (value.item.type === "reasoning") {
@@ -3986,7 +4036,7 @@ var OpenAIResponsesLanguageModel = class {
3986
4036
  type: "reasoning-end",
3987
4037
  id: `${value.item.id}:${summaryIndex}`,
3988
4038
  providerMetadata: {
3989
- openai: {
4039
+ [providerKey]: {
3990
4040
  itemId: value.item.id,
3991
4041
  reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
3992
4042
  }
@@ -4066,7 +4116,9 @@ var OpenAIResponsesLanguageModel = class {
4066
4116
  controller.enqueue({
4067
4117
  type: "reasoning-end",
4068
4118
  id: `${value.item_id}:${summaryIndex}`,
4069
- providerMetadata: { openai: { itemId: value.item_id } }
4119
+ providerMetadata: {
4120
+ [providerKey]: { itemId: value.item_id }
4121
+ }
4070
4122
  });
4071
4123
  activeReasoningPart.summaryParts[summaryIndex] = "concluded";
4072
4124
  }
@@ -4075,7 +4127,7 @@ var OpenAIResponsesLanguageModel = class {
4075
4127
  type: "reasoning-start",
4076
4128
  id: `${value.item_id}:${value.summary_index}`,
4077
4129
  providerMetadata: {
4078
- openai: {
4130
+ [providerKey]: {
4079
4131
  itemId: value.item_id,
4080
4132
  reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
4081
4133
  }
@@ -4088,7 +4140,7 @@ var OpenAIResponsesLanguageModel = class {
4088
4140
  id: `${value.item_id}:${value.summary_index}`,
4089
4141
  delta: value.delta,
4090
4142
  providerMetadata: {
4091
- openai: {
4143
+ [providerKey]: {
4092
4144
  itemId: value.item_id
4093
4145
  }
4094
4146
  }
@@ -4099,7 +4151,7 @@ var OpenAIResponsesLanguageModel = class {
4099
4151
  type: "reasoning-end",
4100
4152
  id: `${value.item_id}:${value.summary_index}`,
4101
4153
  providerMetadata: {
4102
- openai: { itemId: value.item_id }
4154
+ [providerKey]: { itemId: value.item_id }
4103
4155
  }
4104
4156
  });
4105
4157
  activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
@@ -4139,7 +4191,7 @@ var OpenAIResponsesLanguageModel = class {
4139
4191
  filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
4140
4192
  ...value.annotation.file_id ? {
4141
4193
  providerMetadata: {
4142
- openai: {
4194
+ [providerKey]: {
4143
4195
  fileId: value.annotation.file_id
4144
4196
  }
4145
4197
  }
@@ -4152,15 +4204,15 @@ var OpenAIResponsesLanguageModel = class {
4152
4204
  },
4153
4205
  flush(controller) {
4154
4206
  const providerMetadata = {
4155
- openai: {
4207
+ [providerKey]: {
4156
4208
  responseId
4157
4209
  }
4158
4210
  };
4159
4211
  if (logprobs.length > 0) {
4160
- providerMetadata.openai.logprobs = logprobs;
4212
+ providerMetadata[providerKey].logprobs = logprobs;
4161
4213
  }
4162
4214
  if (serviceTier !== void 0) {
4163
- providerMetadata.openai.serviceTier = serviceTier;
4215
+ providerMetadata[providerKey].serviceTier = serviceTier;
4164
4216
  }
4165
4217
  controller.enqueue({
4166
4218
  type: "finish",
@@ -4621,7 +4673,7 @@ var OpenAITranscriptionModel = class {
4621
4673
  };
4622
4674
 
4623
4675
  // src/version.ts
4624
- var VERSION = true ? "2.0.74" : "0.0.0-test";
4676
+ var VERSION = true ? "2.0.76" : "0.0.0-test";
4625
4677
 
4626
4678
  // src/openai-provider.ts
4627
4679
  function createOpenAI(options = {}) {