@ai-sdk/openai 2.0.108 → 2.0.110
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 +13 -0
- package/dist/index.js +46 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +45 -4
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +45 -4
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.0.110
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [b85c4fb]
|
|
8
|
+
- @ai-sdk/provider-utils@3.0.28
|
|
9
|
+
|
|
10
|
+
## 2.0.109
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- f8e6a5c: feat(openai): add orchestration token usage details to Responses API usage
|
|
15
|
+
|
|
3
16
|
## 2.0.108
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -2537,9 +2537,16 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
2537
2537
|
incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
|
|
2538
2538
|
usage: import_v417.z.object({
|
|
2539
2539
|
input_tokens: import_v417.z.number(),
|
|
2540
|
-
input_tokens_details: import_v417.z.object({
|
|
2540
|
+
input_tokens_details: import_v417.z.object({
|
|
2541
|
+
cached_tokens: import_v417.z.number().nullish(),
|
|
2542
|
+
orchestration_input_tokens: import_v417.z.number().nullish(),
|
|
2543
|
+
orchestration_input_cached_tokens: import_v417.z.number().nullish()
|
|
2544
|
+
}).nullish(),
|
|
2541
2545
|
output_tokens: import_v417.z.number(),
|
|
2542
|
-
output_tokens_details: import_v417.z.object({
|
|
2546
|
+
output_tokens_details: import_v417.z.object({
|
|
2547
|
+
reasoning_tokens: import_v417.z.number().nullish(),
|
|
2548
|
+
orchestration_output_tokens: import_v417.z.number().nullish()
|
|
2549
|
+
}).nullish()
|
|
2543
2550
|
}),
|
|
2544
2551
|
service_tier: import_v417.z.string().nullish()
|
|
2545
2552
|
})
|
|
@@ -2962,9 +2969,16 @@ var openaiResponsesResponseSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
2962
2969
|
incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
|
|
2963
2970
|
usage: import_v417.z.object({
|
|
2964
2971
|
input_tokens: import_v417.z.number(),
|
|
2965
|
-
input_tokens_details: import_v417.z.object({
|
|
2972
|
+
input_tokens_details: import_v417.z.object({
|
|
2973
|
+
cached_tokens: import_v417.z.number().nullish(),
|
|
2974
|
+
orchestration_input_tokens: import_v417.z.number().nullish(),
|
|
2975
|
+
orchestration_input_cached_tokens: import_v417.z.number().nullish()
|
|
2976
|
+
}).nullish(),
|
|
2966
2977
|
output_tokens: import_v417.z.number(),
|
|
2967
|
-
output_tokens_details: import_v417.z.object({
|
|
2978
|
+
output_tokens_details: import_v417.z.object({
|
|
2979
|
+
reasoning_tokens: import_v417.z.number().nullish(),
|
|
2980
|
+
orchestration_output_tokens: import_v417.z.number().nullish()
|
|
2981
|
+
}).nullish()
|
|
2968
2982
|
}).optional()
|
|
2969
2983
|
})
|
|
2970
2984
|
)
|
|
@@ -3774,6 +3788,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3774
3788
|
providerMetadata[providerKey].serviceTier = response.service_tier;
|
|
3775
3789
|
}
|
|
3776
3790
|
const usage = response.usage;
|
|
3791
|
+
const orchestrationUsage = getOrchestrationUsageMetadata(usage);
|
|
3792
|
+
if (orchestrationUsage != null) {
|
|
3793
|
+
providerMetadata[providerKey].usage = orchestrationUsage;
|
|
3794
|
+
}
|
|
3777
3795
|
return {
|
|
3778
3796
|
content,
|
|
3779
3797
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -3839,6 +3857,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3839
3857
|
let hasFunctionCall = false;
|
|
3840
3858
|
const activeReasoning = {};
|
|
3841
3859
|
let serviceTier;
|
|
3860
|
+
let orchestrationUsage;
|
|
3842
3861
|
return {
|
|
3843
3862
|
stream: response.pipeThrough(
|
|
3844
3863
|
new TransformStream({
|
|
@@ -4239,6 +4258,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4239
4258
|
if (typeof value.response.service_tier === "string") {
|
|
4240
4259
|
serviceTier = value.response.service_tier;
|
|
4241
4260
|
}
|
|
4261
|
+
orchestrationUsage = getOrchestrationUsageMetadata(
|
|
4262
|
+
value.response.usage
|
|
4263
|
+
);
|
|
4242
4264
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
4243
4265
|
ongoingAnnotations.push(value.annotation);
|
|
4244
4266
|
if (value.annotation.type === "url_citation") {
|
|
@@ -4282,6 +4304,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4282
4304
|
if (serviceTier !== void 0) {
|
|
4283
4305
|
providerMetadata[providerKey].serviceTier = serviceTier;
|
|
4284
4306
|
}
|
|
4307
|
+
if (orchestrationUsage != null) {
|
|
4308
|
+
providerMetadata[providerKey].usage = orchestrationUsage;
|
|
4309
|
+
}
|
|
4285
4310
|
controller.enqueue({
|
|
4286
4311
|
type: "finish",
|
|
4287
4312
|
finishReason,
|
|
@@ -4350,6 +4375,22 @@ function mapWebSearchOutput(action) {
|
|
|
4350
4375
|
};
|
|
4351
4376
|
}
|
|
4352
4377
|
}
|
|
4378
|
+
function getOrchestrationUsageMetadata(usage) {
|
|
4379
|
+
var _a, _b, _c;
|
|
4380
|
+
const orchestrationInputTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.orchestration_input_tokens;
|
|
4381
|
+
const orchestrationInputCachedTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_cached_tokens;
|
|
4382
|
+
const orchestrationOutputTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.orchestration_output_tokens;
|
|
4383
|
+
if (orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
|
|
4384
|
+
return void 0;
|
|
4385
|
+
}
|
|
4386
|
+
return {
|
|
4387
|
+
...orchestrationInputTokens != null && { orchestrationInputTokens },
|
|
4388
|
+
...orchestrationInputCachedTokens != null && {
|
|
4389
|
+
orchestrationInputCachedTokens
|
|
4390
|
+
},
|
|
4391
|
+
...orchestrationOutputTokens != null && { orchestrationOutputTokens }
|
|
4392
|
+
};
|
|
4393
|
+
}
|
|
4353
4394
|
|
|
4354
4395
|
// src/speech/openai-speech-model.ts
|
|
4355
4396
|
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
@@ -4704,7 +4745,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4704
4745
|
};
|
|
4705
4746
|
|
|
4706
4747
|
// src/version.ts
|
|
4707
|
-
var VERSION = true ? "2.0.
|
|
4748
|
+
var VERSION = true ? "2.0.110" : "0.0.0-test";
|
|
4708
4749
|
|
|
4709
4750
|
// src/openai-provider.ts
|
|
4710
4751
|
function createOpenAI(options = {}) {
|