@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/dist/internal/index.js
CHANGED
|
@@ -2608,9 +2608,16 @@ var openaiResponsesChunkSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
2608
2608
|
incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
|
|
2609
2609
|
usage: import_v415.z.object({
|
|
2610
2610
|
input_tokens: import_v415.z.number(),
|
|
2611
|
-
input_tokens_details: import_v415.z.object({
|
|
2611
|
+
input_tokens_details: import_v415.z.object({
|
|
2612
|
+
cached_tokens: import_v415.z.number().nullish(),
|
|
2613
|
+
orchestration_input_tokens: import_v415.z.number().nullish(),
|
|
2614
|
+
orchestration_input_cached_tokens: import_v415.z.number().nullish()
|
|
2615
|
+
}).nullish(),
|
|
2612
2616
|
output_tokens: import_v415.z.number(),
|
|
2613
|
-
output_tokens_details: import_v415.z.object({
|
|
2617
|
+
output_tokens_details: import_v415.z.object({
|
|
2618
|
+
reasoning_tokens: import_v415.z.number().nullish(),
|
|
2619
|
+
orchestration_output_tokens: import_v415.z.number().nullish()
|
|
2620
|
+
}).nullish()
|
|
2614
2621
|
}),
|
|
2615
2622
|
service_tier: import_v415.z.string().nullish()
|
|
2616
2623
|
})
|
|
@@ -3033,9 +3040,16 @@ var openaiResponsesResponseSchema = (0, import_provider_utils22.lazyValidator)(
|
|
|
3033
3040
|
incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
|
|
3034
3041
|
usage: import_v415.z.object({
|
|
3035
3042
|
input_tokens: import_v415.z.number(),
|
|
3036
|
-
input_tokens_details: import_v415.z.object({
|
|
3043
|
+
input_tokens_details: import_v415.z.object({
|
|
3044
|
+
cached_tokens: import_v415.z.number().nullish(),
|
|
3045
|
+
orchestration_input_tokens: import_v415.z.number().nullish(),
|
|
3046
|
+
orchestration_input_cached_tokens: import_v415.z.number().nullish()
|
|
3047
|
+
}).nullish(),
|
|
3037
3048
|
output_tokens: import_v415.z.number(),
|
|
3038
|
-
output_tokens_details: import_v415.z.object({
|
|
3049
|
+
output_tokens_details: import_v415.z.object({
|
|
3050
|
+
reasoning_tokens: import_v415.z.number().nullish(),
|
|
3051
|
+
orchestration_output_tokens: import_v415.z.number().nullish()
|
|
3052
|
+
}).nullish()
|
|
3039
3053
|
}).optional()
|
|
3040
3054
|
})
|
|
3041
3055
|
)
|
|
@@ -4080,6 +4094,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4080
4094
|
providerMetadata[providerKey].serviceTier = response.service_tier;
|
|
4081
4095
|
}
|
|
4082
4096
|
const usage = response.usage;
|
|
4097
|
+
const orchestrationUsage = getOrchestrationUsageMetadata(usage);
|
|
4098
|
+
if (orchestrationUsage != null) {
|
|
4099
|
+
providerMetadata[providerKey].usage = orchestrationUsage;
|
|
4100
|
+
}
|
|
4083
4101
|
return {
|
|
4084
4102
|
content,
|
|
4085
4103
|
finishReason: mapOpenAIResponseFinishReason({
|
|
@@ -4145,6 +4163,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4145
4163
|
let hasFunctionCall = false;
|
|
4146
4164
|
const activeReasoning = {};
|
|
4147
4165
|
let serviceTier;
|
|
4166
|
+
let orchestrationUsage;
|
|
4148
4167
|
return {
|
|
4149
4168
|
stream: response.pipeThrough(
|
|
4150
4169
|
new TransformStream({
|
|
@@ -4545,6 +4564,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4545
4564
|
if (typeof value.response.service_tier === "string") {
|
|
4546
4565
|
serviceTier = value.response.service_tier;
|
|
4547
4566
|
}
|
|
4567
|
+
orchestrationUsage = getOrchestrationUsageMetadata(
|
|
4568
|
+
value.response.usage
|
|
4569
|
+
);
|
|
4548
4570
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
4549
4571
|
ongoingAnnotations.push(value.annotation);
|
|
4550
4572
|
if (value.annotation.type === "url_citation") {
|
|
@@ -4588,6 +4610,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4588
4610
|
if (serviceTier !== void 0) {
|
|
4589
4611
|
providerMetadata[providerKey].serviceTier = serviceTier;
|
|
4590
4612
|
}
|
|
4613
|
+
if (orchestrationUsage != null) {
|
|
4614
|
+
providerMetadata[providerKey].usage = orchestrationUsage;
|
|
4615
|
+
}
|
|
4591
4616
|
controller.enqueue({
|
|
4592
4617
|
type: "finish",
|
|
4593
4618
|
finishReason,
|
|
@@ -4656,6 +4681,22 @@ function mapWebSearchOutput(action) {
|
|
|
4656
4681
|
};
|
|
4657
4682
|
}
|
|
4658
4683
|
}
|
|
4684
|
+
function getOrchestrationUsageMetadata(usage) {
|
|
4685
|
+
var _a, _b, _c;
|
|
4686
|
+
const orchestrationInputTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.orchestration_input_tokens;
|
|
4687
|
+
const orchestrationInputCachedTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_cached_tokens;
|
|
4688
|
+
const orchestrationOutputTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.orchestration_output_tokens;
|
|
4689
|
+
if (orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
|
|
4690
|
+
return void 0;
|
|
4691
|
+
}
|
|
4692
|
+
return {
|
|
4693
|
+
...orchestrationInputTokens != null && { orchestrationInputTokens },
|
|
4694
|
+
...orchestrationInputCachedTokens != null && {
|
|
4695
|
+
orchestrationInputCachedTokens
|
|
4696
|
+
},
|
|
4697
|
+
...orchestrationOutputTokens != null && { orchestrationOutputTokens }
|
|
4698
|
+
};
|
|
4699
|
+
}
|
|
4659
4700
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4660
4701
|
0 && (module.exports = {
|
|
4661
4702
|
OpenAIChatLanguageModel,
|