@ai-sdk/openai 2.0.74 → 2.0.75

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.
@@ -3705,7 +3705,7 @@ var OpenAIResponsesLanguageModel = class {
3705
3705
  };
3706
3706
  }
3707
3707
  async doGenerate(options) {
3708
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
3708
+ 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;
3709
3709
  const {
3710
3710
  args: body,
3711
3711
  warnings,
@@ -3715,6 +3715,7 @@ var OpenAIResponsesLanguageModel = class {
3715
3715
  path: "/responses",
3716
3716
  modelId: this.modelId
3717
3717
  });
3718
+ const providerKey = this.config.provider.replace(".responses", "");
3718
3719
  const {
3719
3720
  responseHeaders,
3720
3721
  value: response,
@@ -3755,7 +3756,7 @@ var OpenAIResponsesLanguageModel = class {
3755
3756
  type: "reasoning",
3756
3757
  text: summary.text,
3757
3758
  providerMetadata: {
3758
- openai: {
3759
+ [providerKey]: {
3759
3760
  itemId: part.id,
3760
3761
  reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
3761
3762
  }
@@ -3792,7 +3793,7 @@ var OpenAIResponsesLanguageModel = class {
3792
3793
  action: part.action
3793
3794
  }),
3794
3795
  providerMetadata: {
3795
- openai: {
3796
+ [providerKey]: {
3796
3797
  itemId: part.id
3797
3798
  }
3798
3799
  }
@@ -3808,7 +3809,7 @@ var OpenAIResponsesLanguageModel = class {
3808
3809
  type: "text",
3809
3810
  text: contentPart.text,
3810
3811
  providerMetadata: {
3811
- openai: {
3812
+ [providerKey]: {
3812
3813
  itemId: part.id
3813
3814
  }
3814
3815
  }
@@ -3832,12 +3833,43 @@ var OpenAIResponsesLanguageModel = class {
3832
3833
  filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
3833
3834
  ...annotation.file_id ? {
3834
3835
  providerMetadata: {
3835
- openai: {
3836
+ [providerKey]: {
3836
3837
  fileId: annotation.file_id
3837
3838
  }
3838
3839
  }
3839
3840
  } : {}
3840
3841
  });
3842
+ } else if (annotation.type === "container_file_citation") {
3843
+ content.push({
3844
+ type: "source",
3845
+ sourceType: "document",
3846
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
3847
+ mediaType: "text/plain",
3848
+ title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
3849
+ filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
3850
+ providerMetadata: {
3851
+ [providerKey]: {
3852
+ fileId: annotation.file_id,
3853
+ containerId: annotation.container_id,
3854
+ ...annotation.index != null ? { index: annotation.index } : {}
3855
+ }
3856
+ }
3857
+ });
3858
+ } else if (annotation.type === "file_path") {
3859
+ content.push({
3860
+ type: "source",
3861
+ sourceType: "document",
3862
+ id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
3863
+ mediaType: "application/octet-stream",
3864
+ title: annotation.file_id,
3865
+ filename: annotation.file_id,
3866
+ providerMetadata: {
3867
+ [providerKey]: {
3868
+ fileId: annotation.file_id,
3869
+ ...annotation.index != null ? { index: annotation.index } : {}
3870
+ }
3871
+ }
3872
+ });
3841
3873
  }
3842
3874
  }
3843
3875
  }
@@ -3851,7 +3883,7 @@ var OpenAIResponsesLanguageModel = class {
3851
3883
  toolName: part.name,
3852
3884
  input: part.arguments,
3853
3885
  providerMetadata: {
3854
- openai: {
3886
+ [providerKey]: {
3855
3887
  itemId: part.id
3856
3888
  }
3857
3889
  }
@@ -3909,13 +3941,13 @@ var OpenAIResponsesLanguageModel = class {
3909
3941
  toolName: "file_search",
3910
3942
  result: {
3911
3943
  queries: part.queries,
3912
- results: (_n = (_m = part.results) == null ? void 0 : _m.map((result) => ({
3944
+ results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
3913
3945
  attributes: result.attributes,
3914
3946
  fileId: result.file_id,
3915
3947
  filename: result.filename,
3916
3948
  score: result.score,
3917
3949
  text: result.text
3918
- }))) != null ? _n : null
3950
+ }))) != null ? _w : null
3919
3951
  },
3920
3952
  providerExecuted: true
3921
3953
  });
@@ -3946,29 +3978,29 @@ var OpenAIResponsesLanguageModel = class {
3946
3978
  }
3947
3979
  }
3948
3980
  const providerMetadata = {
3949
- openai: {
3981
+ [providerKey]: {
3950
3982
  ...response.id != null ? { responseId: response.id } : {}
3951
3983
  }
3952
3984
  };
3953
3985
  if (logprobs.length > 0) {
3954
- providerMetadata.openai.logprobs = logprobs;
3986
+ providerMetadata[providerKey].logprobs = logprobs;
3955
3987
  }
3956
3988
  if (typeof response.service_tier === "string") {
3957
- providerMetadata.openai.serviceTier = response.service_tier;
3989
+ providerMetadata[providerKey].serviceTier = response.service_tier;
3958
3990
  }
3959
3991
  const usage = response.usage;
3960
3992
  return {
3961
3993
  content,
3962
3994
  finishReason: mapOpenAIResponseFinishReason({
3963
- finishReason: (_o = response.incomplete_details) == null ? void 0 : _o.reason,
3995
+ finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
3964
3996
  hasFunctionCall
3965
3997
  }),
3966
3998
  usage: {
3967
3999
  inputTokens: usage.input_tokens,
3968
4000
  outputTokens: usage.output_tokens,
3969
4001
  totalTokens: usage.input_tokens + usage.output_tokens,
3970
- reasoningTokens: (_q = (_p = usage.output_tokens_details) == null ? void 0 : _p.reasoning_tokens) != null ? _q : void 0,
3971
- cachedInputTokens: (_s = (_r = usage.input_tokens_details) == null ? void 0 : _r.cached_tokens) != null ? _s : void 0
4002
+ reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
4003
+ cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
3972
4004
  },
3973
4005
  request: { body },
3974
4006
  response: {
@@ -4007,6 +4039,7 @@ var OpenAIResponsesLanguageModel = class {
4007
4039
  fetch: this.config.fetch
4008
4040
  });
4009
4041
  const self = this;
4042
+ const providerKey = this.config.provider.replace(".responses", "");
4010
4043
  let finishReason = "unknown";
4011
4044
  const usage = {
4012
4045
  inputTokens: void 0,
@@ -4122,7 +4155,7 @@ var OpenAIResponsesLanguageModel = class {
4122
4155
  type: "text-start",
4123
4156
  id: value.item.id,
4124
4157
  providerMetadata: {
4125
- openai: {
4158
+ [providerKey]: {
4126
4159
  itemId: value.item.id
4127
4160
  }
4128
4161
  }
@@ -4136,7 +4169,7 @@ var OpenAIResponsesLanguageModel = class {
4136
4169
  type: "reasoning-start",
4137
4170
  id: `${value.item.id}:0`,
4138
4171
  providerMetadata: {
4139
- openai: {
4172
+ [providerKey]: {
4140
4173
  itemId: value.item.id,
4141
4174
  reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
4142
4175
  }
@@ -4149,7 +4182,7 @@ var OpenAIResponsesLanguageModel = class {
4149
4182
  type: "text-end",
4150
4183
  id: value.item.id,
4151
4184
  providerMetadata: {
4152
- openai: {
4185
+ [providerKey]: {
4153
4186
  itemId: value.item.id,
4154
4187
  ...ongoingAnnotations.length > 0 && {
4155
4188
  annotations: ongoingAnnotations
@@ -4170,7 +4203,7 @@ var OpenAIResponsesLanguageModel = class {
4170
4203
  toolName: value.item.name,
4171
4204
  input: value.item.arguments,
4172
4205
  providerMetadata: {
4173
- openai: {
4206
+ [providerKey]: {
4174
4207
  itemId: value.item.id
4175
4208
  }
4176
4209
  }
@@ -4263,7 +4296,7 @@ var OpenAIResponsesLanguageModel = class {
4263
4296
  }
4264
4297
  }),
4265
4298
  providerMetadata: {
4266
- openai: { itemId: value.item.id }
4299
+ [providerKey]: { itemId: value.item.id }
4267
4300
  }
4268
4301
  });
4269
4302
  } else if (value.item.type === "reasoning") {
@@ -4278,7 +4311,7 @@ var OpenAIResponsesLanguageModel = class {
4278
4311
  type: "reasoning-end",
4279
4312
  id: `${value.item.id}:${summaryIndex}`,
4280
4313
  providerMetadata: {
4281
- openai: {
4314
+ [providerKey]: {
4282
4315
  itemId: value.item.id,
4283
4316
  reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
4284
4317
  }
@@ -4358,7 +4391,9 @@ var OpenAIResponsesLanguageModel = class {
4358
4391
  controller.enqueue({
4359
4392
  type: "reasoning-end",
4360
4393
  id: `${value.item_id}:${summaryIndex}`,
4361
- providerMetadata: { openai: { itemId: value.item_id } }
4394
+ providerMetadata: {
4395
+ [providerKey]: { itemId: value.item_id }
4396
+ }
4362
4397
  });
4363
4398
  activeReasoningPart.summaryParts[summaryIndex] = "concluded";
4364
4399
  }
@@ -4367,7 +4402,7 @@ var OpenAIResponsesLanguageModel = class {
4367
4402
  type: "reasoning-start",
4368
4403
  id: `${value.item_id}:${value.summary_index}`,
4369
4404
  providerMetadata: {
4370
- openai: {
4405
+ [providerKey]: {
4371
4406
  itemId: value.item_id,
4372
4407
  reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
4373
4408
  }
@@ -4380,7 +4415,7 @@ var OpenAIResponsesLanguageModel = class {
4380
4415
  id: `${value.item_id}:${value.summary_index}`,
4381
4416
  delta: value.delta,
4382
4417
  providerMetadata: {
4383
- openai: {
4418
+ [providerKey]: {
4384
4419
  itemId: value.item_id
4385
4420
  }
4386
4421
  }
@@ -4391,7 +4426,7 @@ var OpenAIResponsesLanguageModel = class {
4391
4426
  type: "reasoning-end",
4392
4427
  id: `${value.item_id}:${value.summary_index}`,
4393
4428
  providerMetadata: {
4394
- openai: { itemId: value.item_id }
4429
+ [providerKey]: { itemId: value.item_id }
4395
4430
  }
4396
4431
  });
4397
4432
  activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
@@ -4431,7 +4466,7 @@ var OpenAIResponsesLanguageModel = class {
4431
4466
  filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
4432
4467
  ...value.annotation.file_id ? {
4433
4468
  providerMetadata: {
4434
- openai: {
4469
+ [providerKey]: {
4435
4470
  fileId: value.annotation.file_id
4436
4471
  }
4437
4472
  }
@@ -4444,15 +4479,15 @@ var OpenAIResponsesLanguageModel = class {
4444
4479
  },
4445
4480
  flush(controller) {
4446
4481
  const providerMetadata = {
4447
- openai: {
4482
+ [providerKey]: {
4448
4483
  responseId
4449
4484
  }
4450
4485
  };
4451
4486
  if (logprobs.length > 0) {
4452
- providerMetadata.openai.logprobs = logprobs;
4487
+ providerMetadata[providerKey].logprobs = logprobs;
4453
4488
  }
4454
4489
  if (serviceTier !== void 0) {
4455
- providerMetadata.openai.serviceTier = serviceTier;
4490
+ providerMetadata[providerKey].serviceTier = serviceTier;
4456
4491
  }
4457
4492
  controller.enqueue({
4458
4493
  type: "finish",