@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.
@@ -1674,12 +1674,26 @@ var import_v48 = require("zod/v4");
1674
1674
  var openaiImageResponseSchema = (0, import_provider_utils12.lazyValidator)(
1675
1675
  () => (0, import_provider_utils12.zodSchema)(
1676
1676
  import_v48.z.object({
1677
+ created: import_v48.z.number().nullish(),
1677
1678
  data: import_v48.z.array(
1678
1679
  import_v48.z.object({
1679
1680
  b64_json: import_v48.z.string(),
1680
1681
  revised_prompt: import_v48.z.string().nullish()
1681
1682
  })
1682
- )
1683
+ ),
1684
+ background: import_v48.z.string().nullish(),
1685
+ output_format: import_v48.z.string().nullish(),
1686
+ size: import_v48.z.string().nullish(),
1687
+ quality: import_v48.z.string().nullish(),
1688
+ usage: import_v48.z.object({
1689
+ input_tokens: import_v48.z.number().nullish(),
1690
+ output_tokens: import_v48.z.number().nullish(),
1691
+ total_tokens: import_v48.z.number().nullish(),
1692
+ input_tokens_details: import_v48.z.object({
1693
+ image_tokens: import_v48.z.number().nullish(),
1694
+ text_tokens: import_v48.z.number().nullish()
1695
+ }).nullish()
1696
+ }).nullish()
1683
1697
  })
1684
1698
  )
1685
1699
  );
@@ -1764,11 +1778,14 @@ var OpenAIImageModel = class {
1764
1778
  },
1765
1779
  providerMetadata: {
1766
1780
  openai: {
1767
- images: response.data.map(
1768
- (item) => item.revised_prompt ? {
1769
- revisedPrompt: item.revised_prompt
1770
- } : null
1771
- )
1781
+ images: response.data.map((item) => ({
1782
+ ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
1783
+ ...response.created != null ? { created: response.created } : {},
1784
+ ...response.size != null ? { size: response.size } : {},
1785
+ ...response.quality != null ? { quality: response.quality } : {},
1786
+ ...response.background != null ? { background: response.background } : {},
1787
+ ...response.output_format != null ? { outputFormat: response.output_format } : {}
1788
+ }))
1772
1789
  }
1773
1790
  }
1774
1791
  };
@@ -3644,7 +3661,7 @@ var OpenAIResponsesLanguageModel = class {
3644
3661
  };
3645
3662
  }
3646
3663
  async doGenerate(options) {
3647
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3664
+ 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;
3648
3665
  const {
3649
3666
  args: body,
3650
3667
  warnings,
@@ -3654,6 +3671,7 @@ var OpenAIResponsesLanguageModel = class {
3654
3671
  path: "/responses",
3655
3672
  modelId: this.modelId
3656
3673
  });
3674
+ const providerKey = this.config.provider.replace(".responses", "");
3657
3675
  const {
3658
3676
  responseHeaders,
3659
3677
  value: response,
@@ -3694,7 +3712,7 @@ var OpenAIResponsesLanguageModel = class {
3694
3712
  type: "reasoning",
3695
3713
  text: summary.text,
3696
3714
  providerMetadata: {
3697
- openai: {
3715
+ [providerKey]: {
3698
3716
  itemId: part.id,
3699
3717
  reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
3700
3718
  }
@@ -3731,7 +3749,7 @@ var OpenAIResponsesLanguageModel = class {
3731
3749
  action: part.action
3732
3750
  }),
3733
3751
  providerMetadata: {
3734
- openai: {
3752
+ [providerKey]: {
3735
3753
  itemId: part.id
3736
3754
  }
3737
3755
  }
@@ -3747,7 +3765,7 @@ var OpenAIResponsesLanguageModel = class {
3747
3765
  type: "text",
3748
3766
  text: contentPart.text,
3749
3767
  providerMetadata: {
3750
- openai: {
3768
+ [providerKey]: {
3751
3769
  itemId: part.id
3752
3770
  }
3753
3771
  }
@@ -3771,12 +3789,43 @@ var OpenAIResponsesLanguageModel = class {
3771
3789
  filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
3772
3790
  ...annotation.file_id ? {
3773
3791
  providerMetadata: {
3774
- openai: {
3792
+ [providerKey]: {
3775
3793
  fileId: annotation.file_id
3776
3794
  }
3777
3795
  }
3778
3796
  } : {}
3779
3797
  });
3798
+ } else if (annotation.type === "container_file_citation") {
3799
+ content.push({
3800
+ type: "source",
3801
+ sourceType: "document",
3802
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils29.generateId)(),
3803
+ mediaType: "text/plain",
3804
+ title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
3805
+ filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
3806
+ providerMetadata: {
3807
+ [providerKey]: {
3808
+ fileId: annotation.file_id,
3809
+ containerId: annotation.container_id,
3810
+ ...annotation.index != null ? { index: annotation.index } : {}
3811
+ }
3812
+ }
3813
+ });
3814
+ } else if (annotation.type === "file_path") {
3815
+ content.push({
3816
+ type: "source",
3817
+ sourceType: "document",
3818
+ id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils29.generateId)(),
3819
+ mediaType: "application/octet-stream",
3820
+ title: annotation.file_id,
3821
+ filename: annotation.file_id,
3822
+ providerMetadata: {
3823
+ [providerKey]: {
3824
+ fileId: annotation.file_id,
3825
+ ...annotation.index != null ? { index: annotation.index } : {}
3826
+ }
3827
+ }
3828
+ });
3780
3829
  }
3781
3830
  }
3782
3831
  }
@@ -3790,7 +3839,7 @@ var OpenAIResponsesLanguageModel = class {
3790
3839
  toolName: part.name,
3791
3840
  input: part.arguments,
3792
3841
  providerMetadata: {
3793
- openai: {
3842
+ [providerKey]: {
3794
3843
  itemId: part.id
3795
3844
  }
3796
3845
  }
@@ -3848,13 +3897,13 @@ var OpenAIResponsesLanguageModel = class {
3848
3897
  toolName: "file_search",
3849
3898
  result: {
3850
3899
  queries: part.queries,
3851
- results: (_n = (_m = part.results) == null ? void 0 : _m.map((result) => ({
3900
+ results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
3852
3901
  attributes: result.attributes,
3853
3902
  fileId: result.file_id,
3854
3903
  filename: result.filename,
3855
3904
  score: result.score,
3856
3905
  text: result.text
3857
- }))) != null ? _n : null
3906
+ }))) != null ? _w : null
3858
3907
  },
3859
3908
  providerExecuted: true
3860
3909
  });
@@ -3885,29 +3934,29 @@ var OpenAIResponsesLanguageModel = class {
3885
3934
  }
3886
3935
  }
3887
3936
  const providerMetadata = {
3888
- openai: {
3937
+ [providerKey]: {
3889
3938
  ...response.id != null ? { responseId: response.id } : {}
3890
3939
  }
3891
3940
  };
3892
3941
  if (logprobs.length > 0) {
3893
- providerMetadata.openai.logprobs = logprobs;
3942
+ providerMetadata[providerKey].logprobs = logprobs;
3894
3943
  }
3895
3944
  if (typeof response.service_tier === "string") {
3896
- providerMetadata.openai.serviceTier = response.service_tier;
3945
+ providerMetadata[providerKey].serviceTier = response.service_tier;
3897
3946
  }
3898
3947
  const usage = response.usage;
3899
3948
  return {
3900
3949
  content,
3901
3950
  finishReason: mapOpenAIResponseFinishReason({
3902
- finishReason: (_o = response.incomplete_details) == null ? void 0 : _o.reason,
3951
+ finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
3903
3952
  hasFunctionCall
3904
3953
  }),
3905
3954
  usage: {
3906
3955
  inputTokens: usage.input_tokens,
3907
3956
  outputTokens: usage.output_tokens,
3908
3957
  totalTokens: usage.input_tokens + usage.output_tokens,
3909
- reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
3910
- cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
3958
+ reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
3959
+ cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
3911
3960
  },
3912
3961
  request: { body },
3913
3962
  response: {
@@ -3946,6 +3995,7 @@ var OpenAIResponsesLanguageModel = class {
3946
3995
  fetch: this.config.fetch
3947
3996
  });
3948
3997
  const self = this;
3998
+ const providerKey = this.config.provider.replace(".responses", "");
3949
3999
  let finishReason = "unknown";
3950
4000
  const usage = {
3951
4001
  inputTokens: void 0,
@@ -4061,7 +4111,7 @@ var OpenAIResponsesLanguageModel = class {
4061
4111
  type: "text-start",
4062
4112
  id: value.item.id,
4063
4113
  providerMetadata: {
4064
- openai: {
4114
+ [providerKey]: {
4065
4115
  itemId: value.item.id
4066
4116
  }
4067
4117
  }
@@ -4075,7 +4125,7 @@ var OpenAIResponsesLanguageModel = class {
4075
4125
  type: "reasoning-start",
4076
4126
  id: `${value.item.id}:0`,
4077
4127
  providerMetadata: {
4078
- openai: {
4128
+ [providerKey]: {
4079
4129
  itemId: value.item.id,
4080
4130
  reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
4081
4131
  }
@@ -4088,7 +4138,7 @@ var OpenAIResponsesLanguageModel = class {
4088
4138
  type: "text-end",
4089
4139
  id: value.item.id,
4090
4140
  providerMetadata: {
4091
- openai: {
4141
+ [providerKey]: {
4092
4142
  itemId: value.item.id,
4093
4143
  ...ongoingAnnotations.length > 0 && {
4094
4144
  annotations: ongoingAnnotations
@@ -4109,7 +4159,7 @@ var OpenAIResponsesLanguageModel = class {
4109
4159
  toolName: value.item.name,
4110
4160
  input: value.item.arguments,
4111
4161
  providerMetadata: {
4112
- openai: {
4162
+ [providerKey]: {
4113
4163
  itemId: value.item.id
4114
4164
  }
4115
4165
  }
@@ -4202,7 +4252,7 @@ var OpenAIResponsesLanguageModel = class {
4202
4252
  }
4203
4253
  }),
4204
4254
  providerMetadata: {
4205
- openai: { itemId: value.item.id }
4255
+ [providerKey]: { itemId: value.item.id }
4206
4256
  }
4207
4257
  });
4208
4258
  } else if (value.item.type === "reasoning") {
@@ -4217,7 +4267,7 @@ var OpenAIResponsesLanguageModel = class {
4217
4267
  type: "reasoning-end",
4218
4268
  id: `${value.item.id}:${summaryIndex}`,
4219
4269
  providerMetadata: {
4220
- openai: {
4270
+ [providerKey]: {
4221
4271
  itemId: value.item.id,
4222
4272
  reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
4223
4273
  }
@@ -4297,7 +4347,9 @@ var OpenAIResponsesLanguageModel = class {
4297
4347
  controller.enqueue({
4298
4348
  type: "reasoning-end",
4299
4349
  id: `${value.item_id}:${summaryIndex}`,
4300
- providerMetadata: { openai: { itemId: value.item_id } }
4350
+ providerMetadata: {
4351
+ [providerKey]: { itemId: value.item_id }
4352
+ }
4301
4353
  });
4302
4354
  activeReasoningPart.summaryParts[summaryIndex] = "concluded";
4303
4355
  }
@@ -4306,7 +4358,7 @@ var OpenAIResponsesLanguageModel = class {
4306
4358
  type: "reasoning-start",
4307
4359
  id: `${value.item_id}:${value.summary_index}`,
4308
4360
  providerMetadata: {
4309
- openai: {
4361
+ [providerKey]: {
4310
4362
  itemId: value.item_id,
4311
4363
  reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
4312
4364
  }
@@ -4319,7 +4371,7 @@ var OpenAIResponsesLanguageModel = class {
4319
4371
  id: `${value.item_id}:${value.summary_index}`,
4320
4372
  delta: value.delta,
4321
4373
  providerMetadata: {
4322
- openai: {
4374
+ [providerKey]: {
4323
4375
  itemId: value.item_id
4324
4376
  }
4325
4377
  }
@@ -4330,7 +4382,7 @@ var OpenAIResponsesLanguageModel = class {
4330
4382
  type: "reasoning-end",
4331
4383
  id: `${value.item_id}:${value.summary_index}`,
4332
4384
  providerMetadata: {
4333
- openai: { itemId: value.item_id }
4385
+ [providerKey]: { itemId: value.item_id }
4334
4386
  }
4335
4387
  });
4336
4388
  activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
@@ -4370,7 +4422,7 @@ var OpenAIResponsesLanguageModel = class {
4370
4422
  filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
4371
4423
  ...value.annotation.file_id ? {
4372
4424
  providerMetadata: {
4373
- openai: {
4425
+ [providerKey]: {
4374
4426
  fileId: value.annotation.file_id
4375
4427
  }
4376
4428
  }
@@ -4383,15 +4435,15 @@ var OpenAIResponsesLanguageModel = class {
4383
4435
  },
4384
4436
  flush(controller) {
4385
4437
  const providerMetadata = {
4386
- openai: {
4438
+ [providerKey]: {
4387
4439
  responseId
4388
4440
  }
4389
4441
  };
4390
4442
  if (logprobs.length > 0) {
4391
- providerMetadata.openai.logprobs = logprobs;
4443
+ providerMetadata[providerKey].logprobs = logprobs;
4392
4444
  }
4393
4445
  if (serviceTier !== void 0) {
4394
- providerMetadata.openai.serviceTier = serviceTier;
4446
+ providerMetadata[providerKey].serviceTier = serviceTier;
4395
4447
  }
4396
4448
  controller.enqueue({
4397
4449
  type: "finish",