@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/CHANGELOG.md +12 -0
- package/dist/index.js +87 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +86 -34
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +86 -34
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -1670,12 +1670,26 @@ import { z as z8 } from "zod/v4";
|
|
|
1670
1670
|
var openaiImageResponseSchema = lazyValidator7(
|
|
1671
1671
|
() => zodSchema7(
|
|
1672
1672
|
z8.object({
|
|
1673
|
+
created: z8.number().nullish(),
|
|
1673
1674
|
data: z8.array(
|
|
1674
1675
|
z8.object({
|
|
1675
1676
|
b64_json: z8.string(),
|
|
1676
1677
|
revised_prompt: z8.string().nullish()
|
|
1677
1678
|
})
|
|
1678
|
-
)
|
|
1679
|
+
),
|
|
1680
|
+
background: z8.string().nullish(),
|
|
1681
|
+
output_format: z8.string().nullish(),
|
|
1682
|
+
size: z8.string().nullish(),
|
|
1683
|
+
quality: z8.string().nullish(),
|
|
1684
|
+
usage: z8.object({
|
|
1685
|
+
input_tokens: z8.number().nullish(),
|
|
1686
|
+
output_tokens: z8.number().nullish(),
|
|
1687
|
+
total_tokens: z8.number().nullish(),
|
|
1688
|
+
input_tokens_details: z8.object({
|
|
1689
|
+
image_tokens: z8.number().nullish(),
|
|
1690
|
+
text_tokens: z8.number().nullish()
|
|
1691
|
+
}).nullish()
|
|
1692
|
+
}).nullish()
|
|
1679
1693
|
})
|
|
1680
1694
|
)
|
|
1681
1695
|
);
|
|
@@ -1760,11 +1774,14 @@ var OpenAIImageModel = class {
|
|
|
1760
1774
|
},
|
|
1761
1775
|
providerMetadata: {
|
|
1762
1776
|
openai: {
|
|
1763
|
-
images: response.data.map(
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
} :
|
|
1767
|
-
|
|
1777
|
+
images: response.data.map((item) => ({
|
|
1778
|
+
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1779
|
+
...response.created != null ? { created: response.created } : {},
|
|
1780
|
+
...response.size != null ? { size: response.size } : {},
|
|
1781
|
+
...response.quality != null ? { quality: response.quality } : {},
|
|
1782
|
+
...response.background != null ? { background: response.background } : {},
|
|
1783
|
+
...response.output_format != null ? { outputFormat: response.output_format } : {}
|
|
1784
|
+
}))
|
|
1768
1785
|
}
|
|
1769
1786
|
}
|
|
1770
1787
|
};
|
|
@@ -3705,7 +3722,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3705
3722
|
};
|
|
3706
3723
|
}
|
|
3707
3724
|
async doGenerate(options) {
|
|
3708
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
3725
|
+
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
3726
|
const {
|
|
3710
3727
|
args: body,
|
|
3711
3728
|
warnings,
|
|
@@ -3715,6 +3732,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3715
3732
|
path: "/responses",
|
|
3716
3733
|
modelId: this.modelId
|
|
3717
3734
|
});
|
|
3735
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
3718
3736
|
const {
|
|
3719
3737
|
responseHeaders,
|
|
3720
3738
|
value: response,
|
|
@@ -3755,7 +3773,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3755
3773
|
type: "reasoning",
|
|
3756
3774
|
text: summary.text,
|
|
3757
3775
|
providerMetadata: {
|
|
3758
|
-
|
|
3776
|
+
[providerKey]: {
|
|
3759
3777
|
itemId: part.id,
|
|
3760
3778
|
reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
|
|
3761
3779
|
}
|
|
@@ -3792,7 +3810,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3792
3810
|
action: part.action
|
|
3793
3811
|
}),
|
|
3794
3812
|
providerMetadata: {
|
|
3795
|
-
|
|
3813
|
+
[providerKey]: {
|
|
3796
3814
|
itemId: part.id
|
|
3797
3815
|
}
|
|
3798
3816
|
}
|
|
@@ -3808,7 +3826,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3808
3826
|
type: "text",
|
|
3809
3827
|
text: contentPart.text,
|
|
3810
3828
|
providerMetadata: {
|
|
3811
|
-
|
|
3829
|
+
[providerKey]: {
|
|
3812
3830
|
itemId: part.id
|
|
3813
3831
|
}
|
|
3814
3832
|
}
|
|
@@ -3832,12 +3850,43 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3832
3850
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
3833
3851
|
...annotation.file_id ? {
|
|
3834
3852
|
providerMetadata: {
|
|
3835
|
-
|
|
3853
|
+
[providerKey]: {
|
|
3836
3854
|
fileId: annotation.file_id
|
|
3837
3855
|
}
|
|
3838
3856
|
}
|
|
3839
3857
|
} : {}
|
|
3840
3858
|
});
|
|
3859
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3860
|
+
content.push({
|
|
3861
|
+
type: "source",
|
|
3862
|
+
sourceType: "document",
|
|
3863
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
|
|
3864
|
+
mediaType: "text/plain",
|
|
3865
|
+
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3866
|
+
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
3867
|
+
providerMetadata: {
|
|
3868
|
+
[providerKey]: {
|
|
3869
|
+
fileId: annotation.file_id,
|
|
3870
|
+
containerId: annotation.container_id,
|
|
3871
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
});
|
|
3875
|
+
} else if (annotation.type === "file_path") {
|
|
3876
|
+
content.push({
|
|
3877
|
+
type: "source",
|
|
3878
|
+
sourceType: "document",
|
|
3879
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId2(),
|
|
3880
|
+
mediaType: "application/octet-stream",
|
|
3881
|
+
title: annotation.file_id,
|
|
3882
|
+
filename: annotation.file_id,
|
|
3883
|
+
providerMetadata: {
|
|
3884
|
+
[providerKey]: {
|
|
3885
|
+
fileId: annotation.file_id,
|
|
3886
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
});
|
|
3841
3890
|
}
|
|
3842
3891
|
}
|
|
3843
3892
|
}
|
|
@@ -3851,7 +3900,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3851
3900
|
toolName: part.name,
|
|
3852
3901
|
input: part.arguments,
|
|
3853
3902
|
providerMetadata: {
|
|
3854
|
-
|
|
3903
|
+
[providerKey]: {
|
|
3855
3904
|
itemId: part.id
|
|
3856
3905
|
}
|
|
3857
3906
|
}
|
|
@@ -3909,13 +3958,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3909
3958
|
toolName: "file_search",
|
|
3910
3959
|
result: {
|
|
3911
3960
|
queries: part.queries,
|
|
3912
|
-
results: (
|
|
3961
|
+
results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
|
|
3913
3962
|
attributes: result.attributes,
|
|
3914
3963
|
fileId: result.file_id,
|
|
3915
3964
|
filename: result.filename,
|
|
3916
3965
|
score: result.score,
|
|
3917
3966
|
text: result.text
|
|
3918
|
-
}))) != null ?
|
|
3967
|
+
}))) != null ? _w : null
|
|
3919
3968
|
},
|
|
3920
3969
|
providerExecuted: true
|
|
3921
3970
|
});
|
|
@@ -3946,29 +3995,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3946
3995
|
}
|
|
3947
3996
|
}
|
|
3948
3997
|
const providerMetadata = {
|
|
3949
|
-
|
|
3998
|
+
[providerKey]: {
|
|
3950
3999
|
...response.id != null ? { responseId: response.id } : {}
|
|
3951
4000
|
}
|
|
3952
4001
|
};
|
|
3953
4002
|
if (logprobs.length > 0) {
|
|
3954
|
-
providerMetadata.
|
|
4003
|
+
providerMetadata[providerKey].logprobs = logprobs;
|
|
3955
4004
|
}
|
|
3956
4005
|
if (typeof response.service_tier === "string") {
|
|
3957
|
-
providerMetadata.
|
|
4006
|
+
providerMetadata[providerKey].serviceTier = response.service_tier;
|
|
3958
4007
|
}
|
|
3959
4008
|
const usage = response.usage;
|
|
3960
4009
|
return {
|
|
3961
4010
|
content,
|
|
3962
4011
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3963
|
-
finishReason: (
|
|
4012
|
+
finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
|
|
3964
4013
|
hasFunctionCall
|
|
3965
4014
|
}),
|
|
3966
4015
|
usage: {
|
|
3967
4016
|
inputTokens: usage.input_tokens,
|
|
3968
4017
|
outputTokens: usage.output_tokens,
|
|
3969
4018
|
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
3970
|
-
reasoningTokens: (
|
|
3971
|
-
cachedInputTokens: (
|
|
4019
|
+
reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
|
|
4020
|
+
cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
|
|
3972
4021
|
},
|
|
3973
4022
|
request: { body },
|
|
3974
4023
|
response: {
|
|
@@ -4007,6 +4056,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4007
4056
|
fetch: this.config.fetch
|
|
4008
4057
|
});
|
|
4009
4058
|
const self = this;
|
|
4059
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
4010
4060
|
let finishReason = "unknown";
|
|
4011
4061
|
const usage = {
|
|
4012
4062
|
inputTokens: void 0,
|
|
@@ -4122,7 +4172,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4122
4172
|
type: "text-start",
|
|
4123
4173
|
id: value.item.id,
|
|
4124
4174
|
providerMetadata: {
|
|
4125
|
-
|
|
4175
|
+
[providerKey]: {
|
|
4126
4176
|
itemId: value.item.id
|
|
4127
4177
|
}
|
|
4128
4178
|
}
|
|
@@ -4136,7 +4186,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4136
4186
|
type: "reasoning-start",
|
|
4137
4187
|
id: `${value.item.id}:0`,
|
|
4138
4188
|
providerMetadata: {
|
|
4139
|
-
|
|
4189
|
+
[providerKey]: {
|
|
4140
4190
|
itemId: value.item.id,
|
|
4141
4191
|
reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
|
|
4142
4192
|
}
|
|
@@ -4149,7 +4199,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4149
4199
|
type: "text-end",
|
|
4150
4200
|
id: value.item.id,
|
|
4151
4201
|
providerMetadata: {
|
|
4152
|
-
|
|
4202
|
+
[providerKey]: {
|
|
4153
4203
|
itemId: value.item.id,
|
|
4154
4204
|
...ongoingAnnotations.length > 0 && {
|
|
4155
4205
|
annotations: ongoingAnnotations
|
|
@@ -4170,7 +4220,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4170
4220
|
toolName: value.item.name,
|
|
4171
4221
|
input: value.item.arguments,
|
|
4172
4222
|
providerMetadata: {
|
|
4173
|
-
|
|
4223
|
+
[providerKey]: {
|
|
4174
4224
|
itemId: value.item.id
|
|
4175
4225
|
}
|
|
4176
4226
|
}
|
|
@@ -4263,7 +4313,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4263
4313
|
}
|
|
4264
4314
|
}),
|
|
4265
4315
|
providerMetadata: {
|
|
4266
|
-
|
|
4316
|
+
[providerKey]: { itemId: value.item.id }
|
|
4267
4317
|
}
|
|
4268
4318
|
});
|
|
4269
4319
|
} else if (value.item.type === "reasoning") {
|
|
@@ -4278,7 +4328,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4278
4328
|
type: "reasoning-end",
|
|
4279
4329
|
id: `${value.item.id}:${summaryIndex}`,
|
|
4280
4330
|
providerMetadata: {
|
|
4281
|
-
|
|
4331
|
+
[providerKey]: {
|
|
4282
4332
|
itemId: value.item.id,
|
|
4283
4333
|
reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
|
|
4284
4334
|
}
|
|
@@ -4358,7 +4408,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4358
4408
|
controller.enqueue({
|
|
4359
4409
|
type: "reasoning-end",
|
|
4360
4410
|
id: `${value.item_id}:${summaryIndex}`,
|
|
4361
|
-
providerMetadata: {
|
|
4411
|
+
providerMetadata: {
|
|
4412
|
+
[providerKey]: { itemId: value.item_id }
|
|
4413
|
+
}
|
|
4362
4414
|
});
|
|
4363
4415
|
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
4364
4416
|
}
|
|
@@ -4367,7 +4419,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4367
4419
|
type: "reasoning-start",
|
|
4368
4420
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4369
4421
|
providerMetadata: {
|
|
4370
|
-
|
|
4422
|
+
[providerKey]: {
|
|
4371
4423
|
itemId: value.item_id,
|
|
4372
4424
|
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
4373
4425
|
}
|
|
@@ -4380,7 +4432,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4380
4432
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4381
4433
|
delta: value.delta,
|
|
4382
4434
|
providerMetadata: {
|
|
4383
|
-
|
|
4435
|
+
[providerKey]: {
|
|
4384
4436
|
itemId: value.item_id
|
|
4385
4437
|
}
|
|
4386
4438
|
}
|
|
@@ -4391,7 +4443,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4391
4443
|
type: "reasoning-end",
|
|
4392
4444
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4393
4445
|
providerMetadata: {
|
|
4394
|
-
|
|
4446
|
+
[providerKey]: { itemId: value.item_id }
|
|
4395
4447
|
}
|
|
4396
4448
|
});
|
|
4397
4449
|
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
@@ -4431,7 +4483,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4431
4483
|
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
4432
4484
|
...value.annotation.file_id ? {
|
|
4433
4485
|
providerMetadata: {
|
|
4434
|
-
|
|
4486
|
+
[providerKey]: {
|
|
4435
4487
|
fileId: value.annotation.file_id
|
|
4436
4488
|
}
|
|
4437
4489
|
}
|
|
@@ -4444,15 +4496,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4444
4496
|
},
|
|
4445
4497
|
flush(controller) {
|
|
4446
4498
|
const providerMetadata = {
|
|
4447
|
-
|
|
4499
|
+
[providerKey]: {
|
|
4448
4500
|
responseId
|
|
4449
4501
|
}
|
|
4450
4502
|
};
|
|
4451
4503
|
if (logprobs.length > 0) {
|
|
4452
|
-
providerMetadata.
|
|
4504
|
+
providerMetadata[providerKey].logprobs = logprobs;
|
|
4453
4505
|
}
|
|
4454
4506
|
if (serviceTier !== void 0) {
|
|
4455
|
-
providerMetadata.
|
|
4507
|
+
providerMetadata[providerKey].serviceTier = serviceTier;
|
|
4456
4508
|
}
|
|
4457
4509
|
controller.enqueue({
|
|
4458
4510
|
type: "finish",
|