@ai-sdk/gateway 4.0.0-beta.3 → 4.0.0-beta.31
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 +189 -4
- package/dist/index.d.mts +131 -21
- package/dist/index.d.ts +131 -21
- package/dist/index.js +359 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +415 -186
- package/dist/index.mjs.map +1 -1
- package/docs/00-ai-gateway.mdx +219 -44
- package/package.json +4 -6
- package/src/gateway-embedding-model-settings.ts +1 -0
- package/src/gateway-embedding-model.ts +8 -8
- package/src/gateway-fetch-metadata.ts +1 -1
- package/src/gateway-generation-info.ts +147 -0
- package/src/gateway-image-model-settings.ts +6 -0
- package/src/gateway-image-model.ts +10 -10
- package/src/gateway-language-model-settings.ts +18 -6
- package/src/gateway-language-model.ts +19 -19
- package/src/gateway-model-entry.ts +2 -2
- package/src/gateway-provider-options.ts +8 -4
- package/src/gateway-provider.ts +75 -17
- package/src/gateway-spend-report.ts +191 -0
- package/src/gateway-video-model.ts +15 -15
- package/src/index.ts +12 -3
package/dist/index.mjs
CHANGED
|
@@ -536,7 +536,7 @@ var gatewayAvailableModelsResponseSchema = lazySchema4(
|
|
|
536
536
|
})
|
|
537
537
|
).nullish(),
|
|
538
538
|
specification: z4.object({
|
|
539
|
-
specificationVersion: z4.literal("
|
|
539
|
+
specificationVersion: z4.literal("v4"),
|
|
540
540
|
provider: z4.string(),
|
|
541
541
|
modelId: z4.string()
|
|
542
542
|
}),
|
|
@@ -558,21 +558,224 @@ var gatewayCreditsResponseSchema = lazySchema4(
|
|
|
558
558
|
)
|
|
559
559
|
);
|
|
560
560
|
|
|
561
|
+
// src/gateway-spend-report.ts
|
|
562
|
+
import {
|
|
563
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
|
|
564
|
+
createJsonResponseHandler as createJsonResponseHandler2,
|
|
565
|
+
getFromApi as getFromApi2,
|
|
566
|
+
lazySchema as lazySchema5,
|
|
567
|
+
resolve as resolve2,
|
|
568
|
+
zodSchema as zodSchema5
|
|
569
|
+
} from "@ai-sdk/provider-utils";
|
|
570
|
+
import { z as z5 } from "zod/v4";
|
|
571
|
+
var GatewaySpendReport = class {
|
|
572
|
+
constructor(config) {
|
|
573
|
+
this.config = config;
|
|
574
|
+
}
|
|
575
|
+
async getSpendReport(params) {
|
|
576
|
+
try {
|
|
577
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
578
|
+
const searchParams = new URLSearchParams();
|
|
579
|
+
searchParams.set("start_date", params.startDate);
|
|
580
|
+
searchParams.set("end_date", params.endDate);
|
|
581
|
+
if (params.groupBy) {
|
|
582
|
+
searchParams.set("group_by", params.groupBy);
|
|
583
|
+
}
|
|
584
|
+
if (params.datePart) {
|
|
585
|
+
searchParams.set("date_part", params.datePart);
|
|
586
|
+
}
|
|
587
|
+
if (params.userId) {
|
|
588
|
+
searchParams.set("user_id", params.userId);
|
|
589
|
+
}
|
|
590
|
+
if (params.model) {
|
|
591
|
+
searchParams.set("model", params.model);
|
|
592
|
+
}
|
|
593
|
+
if (params.provider) {
|
|
594
|
+
searchParams.set("provider", params.provider);
|
|
595
|
+
}
|
|
596
|
+
if (params.credentialType) {
|
|
597
|
+
searchParams.set("credential_type", params.credentialType);
|
|
598
|
+
}
|
|
599
|
+
if (params.tags && params.tags.length > 0) {
|
|
600
|
+
searchParams.set("tags", params.tags.join(","));
|
|
601
|
+
}
|
|
602
|
+
const { value } = await getFromApi2({
|
|
603
|
+
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
604
|
+
headers: await resolve2(this.config.headers()),
|
|
605
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
606
|
+
gatewaySpendReportResponseSchema
|
|
607
|
+
),
|
|
608
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
609
|
+
errorSchema: z5.any(),
|
|
610
|
+
errorToMessage: (data) => data
|
|
611
|
+
}),
|
|
612
|
+
fetch: this.config.fetch
|
|
613
|
+
});
|
|
614
|
+
return value;
|
|
615
|
+
} catch (error) {
|
|
616
|
+
throw await asGatewayError(error);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
var gatewaySpendReportResponseSchema = lazySchema5(
|
|
621
|
+
() => zodSchema5(
|
|
622
|
+
z5.object({
|
|
623
|
+
results: z5.array(
|
|
624
|
+
z5.object({
|
|
625
|
+
day: z5.string().optional(),
|
|
626
|
+
hour: z5.string().optional(),
|
|
627
|
+
user: z5.string().optional(),
|
|
628
|
+
model: z5.string().optional(),
|
|
629
|
+
tag: z5.string().optional(),
|
|
630
|
+
provider: z5.string().optional(),
|
|
631
|
+
credential_type: z5.enum(["byok", "system"]).optional(),
|
|
632
|
+
total_cost: z5.number(),
|
|
633
|
+
market_cost: z5.number().optional(),
|
|
634
|
+
input_tokens: z5.number().optional(),
|
|
635
|
+
output_tokens: z5.number().optional(),
|
|
636
|
+
cached_input_tokens: z5.number().optional(),
|
|
637
|
+
cache_creation_input_tokens: z5.number().optional(),
|
|
638
|
+
reasoning_tokens: z5.number().optional(),
|
|
639
|
+
request_count: z5.number().optional()
|
|
640
|
+
}).transform(
|
|
641
|
+
({
|
|
642
|
+
credential_type,
|
|
643
|
+
total_cost,
|
|
644
|
+
market_cost,
|
|
645
|
+
input_tokens,
|
|
646
|
+
output_tokens,
|
|
647
|
+
cached_input_tokens,
|
|
648
|
+
cache_creation_input_tokens,
|
|
649
|
+
reasoning_tokens,
|
|
650
|
+
request_count,
|
|
651
|
+
...rest
|
|
652
|
+
}) => ({
|
|
653
|
+
...rest,
|
|
654
|
+
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
655
|
+
totalCost: total_cost,
|
|
656
|
+
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
657
|
+
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
658
|
+
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
659
|
+
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
660
|
+
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
661
|
+
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
662
|
+
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
663
|
+
})
|
|
664
|
+
)
|
|
665
|
+
)
|
|
666
|
+
})
|
|
667
|
+
)
|
|
668
|
+
);
|
|
669
|
+
|
|
670
|
+
// src/gateway-generation-info.ts
|
|
671
|
+
import {
|
|
672
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
|
|
673
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
674
|
+
getFromApi as getFromApi3,
|
|
675
|
+
lazySchema as lazySchema6,
|
|
676
|
+
resolve as resolve3,
|
|
677
|
+
zodSchema as zodSchema6
|
|
678
|
+
} from "@ai-sdk/provider-utils";
|
|
679
|
+
import { z as z6 } from "zod/v4";
|
|
680
|
+
var GatewayGenerationInfoFetcher = class {
|
|
681
|
+
constructor(config) {
|
|
682
|
+
this.config = config;
|
|
683
|
+
}
|
|
684
|
+
async getGenerationInfo(params) {
|
|
685
|
+
try {
|
|
686
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
687
|
+
const { value } = await getFromApi3({
|
|
688
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
689
|
+
headers: await resolve3(this.config.headers()),
|
|
690
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
691
|
+
gatewayGenerationInfoResponseSchema
|
|
692
|
+
),
|
|
693
|
+
failedResponseHandler: createJsonErrorResponseHandler3({
|
|
694
|
+
errorSchema: z6.any(),
|
|
695
|
+
errorToMessage: (data) => data
|
|
696
|
+
}),
|
|
697
|
+
fetch: this.config.fetch
|
|
698
|
+
});
|
|
699
|
+
return value;
|
|
700
|
+
} catch (error) {
|
|
701
|
+
throw await asGatewayError(error);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
var gatewayGenerationInfoResponseSchema = lazySchema6(
|
|
706
|
+
() => zodSchema6(
|
|
707
|
+
z6.object({
|
|
708
|
+
data: z6.object({
|
|
709
|
+
id: z6.string(),
|
|
710
|
+
total_cost: z6.number(),
|
|
711
|
+
upstream_inference_cost: z6.number(),
|
|
712
|
+
usage: z6.number(),
|
|
713
|
+
created_at: z6.string(),
|
|
714
|
+
model: z6.string(),
|
|
715
|
+
is_byok: z6.boolean(),
|
|
716
|
+
provider_name: z6.string(),
|
|
717
|
+
streamed: z6.boolean(),
|
|
718
|
+
finish_reason: z6.string(),
|
|
719
|
+
latency: z6.number(),
|
|
720
|
+
generation_time: z6.number(),
|
|
721
|
+
native_tokens_prompt: z6.number(),
|
|
722
|
+
native_tokens_completion: z6.number(),
|
|
723
|
+
native_tokens_reasoning: z6.number(),
|
|
724
|
+
native_tokens_cached: z6.number(),
|
|
725
|
+
native_tokens_cache_creation: z6.number(),
|
|
726
|
+
billable_web_search_calls: z6.number()
|
|
727
|
+
}).transform(
|
|
728
|
+
({
|
|
729
|
+
total_cost,
|
|
730
|
+
upstream_inference_cost,
|
|
731
|
+
created_at,
|
|
732
|
+
is_byok,
|
|
733
|
+
provider_name,
|
|
734
|
+
finish_reason,
|
|
735
|
+
generation_time,
|
|
736
|
+
native_tokens_prompt,
|
|
737
|
+
native_tokens_completion,
|
|
738
|
+
native_tokens_reasoning,
|
|
739
|
+
native_tokens_cached,
|
|
740
|
+
native_tokens_cache_creation,
|
|
741
|
+
billable_web_search_calls,
|
|
742
|
+
...rest
|
|
743
|
+
}) => ({
|
|
744
|
+
...rest,
|
|
745
|
+
totalCost: total_cost,
|
|
746
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
747
|
+
createdAt: created_at,
|
|
748
|
+
isByok: is_byok,
|
|
749
|
+
providerName: provider_name,
|
|
750
|
+
finishReason: finish_reason,
|
|
751
|
+
generationTime: generation_time,
|
|
752
|
+
promptTokens: native_tokens_prompt,
|
|
753
|
+
completionTokens: native_tokens_completion,
|
|
754
|
+
reasoningTokens: native_tokens_reasoning,
|
|
755
|
+
cachedTokens: native_tokens_cached,
|
|
756
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
757
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
758
|
+
})
|
|
759
|
+
)
|
|
760
|
+
}).transform(({ data }) => data)
|
|
761
|
+
)
|
|
762
|
+
);
|
|
763
|
+
|
|
561
764
|
// src/gateway-language-model.ts
|
|
562
765
|
import {
|
|
563
766
|
combineHeaders,
|
|
564
767
|
createEventSourceResponseHandler,
|
|
565
|
-
createJsonErrorResponseHandler as
|
|
566
|
-
createJsonResponseHandler as
|
|
768
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
|
|
769
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
567
770
|
postJsonToApi,
|
|
568
|
-
resolve as
|
|
771
|
+
resolve as resolve4
|
|
569
772
|
} from "@ai-sdk/provider-utils";
|
|
570
|
-
import { z as
|
|
773
|
+
import { z as z7 } from "zod/v4";
|
|
571
774
|
var GatewayLanguageModel = class {
|
|
572
775
|
constructor(modelId, config) {
|
|
573
776
|
this.modelId = modelId;
|
|
574
777
|
this.config = config;
|
|
575
|
-
this.specificationVersion = "
|
|
778
|
+
this.specificationVersion = "v4";
|
|
576
779
|
this.supportedUrls = { "*/*": [/.*/] };
|
|
577
780
|
}
|
|
578
781
|
get provider() {
|
|
@@ -588,7 +791,7 @@ var GatewayLanguageModel = class {
|
|
|
588
791
|
async doGenerate(options) {
|
|
589
792
|
const { args, warnings } = await this.getArgs(options);
|
|
590
793
|
const { abortSignal } = options;
|
|
591
|
-
const resolvedHeaders = await
|
|
794
|
+
const resolvedHeaders = await resolve4(this.config.headers());
|
|
592
795
|
try {
|
|
593
796
|
const {
|
|
594
797
|
responseHeaders,
|
|
@@ -600,12 +803,12 @@ var GatewayLanguageModel = class {
|
|
|
600
803
|
resolvedHeaders,
|
|
601
804
|
options.headers,
|
|
602
805
|
this.getModelConfigHeaders(this.modelId, false),
|
|
603
|
-
await
|
|
806
|
+
await resolve4(this.config.o11yHeaders)
|
|
604
807
|
),
|
|
605
808
|
body: args,
|
|
606
|
-
successfulResponseHandler:
|
|
607
|
-
failedResponseHandler:
|
|
608
|
-
errorSchema:
|
|
809
|
+
successfulResponseHandler: createJsonResponseHandler4(z7.any()),
|
|
810
|
+
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
811
|
+
errorSchema: z7.any(),
|
|
609
812
|
errorToMessage: (data) => data
|
|
610
813
|
}),
|
|
611
814
|
...abortSignal && { abortSignal },
|
|
@@ -624,7 +827,7 @@ var GatewayLanguageModel = class {
|
|
|
624
827
|
async doStream(options) {
|
|
625
828
|
const { args, warnings } = await this.getArgs(options);
|
|
626
829
|
const { abortSignal } = options;
|
|
627
|
-
const resolvedHeaders = await
|
|
830
|
+
const resolvedHeaders = await resolve4(this.config.headers());
|
|
628
831
|
try {
|
|
629
832
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
630
833
|
url: this.getUrl(),
|
|
@@ -632,12 +835,12 @@ var GatewayLanguageModel = class {
|
|
|
632
835
|
resolvedHeaders,
|
|
633
836
|
options.headers,
|
|
634
837
|
this.getModelConfigHeaders(this.modelId, true),
|
|
635
|
-
await
|
|
838
|
+
await resolve4(this.config.o11yHeaders)
|
|
636
839
|
),
|
|
637
840
|
body: args,
|
|
638
|
-
successfulResponseHandler: createEventSourceResponseHandler(
|
|
639
|
-
failedResponseHandler:
|
|
640
|
-
errorSchema:
|
|
841
|
+
successfulResponseHandler: createEventSourceResponseHandler(z7.any()),
|
|
842
|
+
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
843
|
+
errorSchema: z7.any(),
|
|
641
844
|
errorToMessage: (data) => data
|
|
642
845
|
}),
|
|
643
846
|
...abortSignal && { abortSignal },
|
|
@@ -707,7 +910,7 @@ var GatewayLanguageModel = class {
|
|
|
707
910
|
}
|
|
708
911
|
getModelConfigHeaders(modelId, streaming) {
|
|
709
912
|
return {
|
|
710
|
-
"ai-language-model-specification-version": "
|
|
913
|
+
"ai-language-model-specification-version": "4",
|
|
711
914
|
"ai-language-model-id": modelId,
|
|
712
915
|
"ai-language-model-streaming": String(streaming)
|
|
713
916
|
};
|
|
@@ -717,19 +920,19 @@ var GatewayLanguageModel = class {
|
|
|
717
920
|
// src/gateway-embedding-model.ts
|
|
718
921
|
import {
|
|
719
922
|
combineHeaders as combineHeaders2,
|
|
720
|
-
createJsonErrorResponseHandler as
|
|
721
|
-
createJsonResponseHandler as
|
|
722
|
-
lazySchema as
|
|
923
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler5,
|
|
924
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
925
|
+
lazySchema as lazySchema7,
|
|
723
926
|
postJsonToApi as postJsonToApi2,
|
|
724
|
-
resolve as
|
|
725
|
-
zodSchema as
|
|
927
|
+
resolve as resolve5,
|
|
928
|
+
zodSchema as zodSchema7
|
|
726
929
|
} from "@ai-sdk/provider-utils";
|
|
727
|
-
import { z as
|
|
930
|
+
import { z as z8 } from "zod/v4";
|
|
728
931
|
var GatewayEmbeddingModel = class {
|
|
729
932
|
constructor(modelId, config) {
|
|
730
933
|
this.modelId = modelId;
|
|
731
934
|
this.config = config;
|
|
732
|
-
this.specificationVersion = "
|
|
935
|
+
this.specificationVersion = "v4";
|
|
733
936
|
this.maxEmbeddingsPerCall = 2048;
|
|
734
937
|
this.supportsParallelCalls = true;
|
|
735
938
|
}
|
|
@@ -743,7 +946,7 @@ var GatewayEmbeddingModel = class {
|
|
|
743
946
|
providerOptions
|
|
744
947
|
}) {
|
|
745
948
|
var _a9;
|
|
746
|
-
const resolvedHeaders = await
|
|
949
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
747
950
|
try {
|
|
748
951
|
const {
|
|
749
952
|
responseHeaders,
|
|
@@ -755,17 +958,17 @@ var GatewayEmbeddingModel = class {
|
|
|
755
958
|
resolvedHeaders,
|
|
756
959
|
headers != null ? headers : {},
|
|
757
960
|
this.getModelConfigHeaders(),
|
|
758
|
-
await
|
|
961
|
+
await resolve5(this.config.o11yHeaders)
|
|
759
962
|
),
|
|
760
963
|
body: {
|
|
761
964
|
values,
|
|
762
965
|
...providerOptions ? { providerOptions } : {}
|
|
763
966
|
},
|
|
764
|
-
successfulResponseHandler:
|
|
967
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
765
968
|
gatewayEmbeddingResponseSchema
|
|
766
969
|
),
|
|
767
|
-
failedResponseHandler:
|
|
768
|
-
errorSchema:
|
|
970
|
+
failedResponseHandler: createJsonErrorResponseHandler5({
|
|
971
|
+
errorSchema: z8.any(),
|
|
769
972
|
errorToMessage: (data) => data
|
|
770
973
|
}),
|
|
771
974
|
...abortSignal && { abortSignal },
|
|
@@ -787,17 +990,17 @@ var GatewayEmbeddingModel = class {
|
|
|
787
990
|
}
|
|
788
991
|
getModelConfigHeaders() {
|
|
789
992
|
return {
|
|
790
|
-
"ai-embedding-model-specification-version": "
|
|
993
|
+
"ai-embedding-model-specification-version": "4",
|
|
791
994
|
"ai-model-id": this.modelId
|
|
792
995
|
};
|
|
793
996
|
}
|
|
794
997
|
};
|
|
795
|
-
var gatewayEmbeddingResponseSchema =
|
|
796
|
-
() =>
|
|
797
|
-
|
|
798
|
-
embeddings:
|
|
799
|
-
usage:
|
|
800
|
-
providerMetadata:
|
|
998
|
+
var gatewayEmbeddingResponseSchema = lazySchema7(
|
|
999
|
+
() => zodSchema7(
|
|
1000
|
+
z8.object({
|
|
1001
|
+
embeddings: z8.array(z8.array(z8.number())),
|
|
1002
|
+
usage: z8.object({ tokens: z8.number() }).nullish(),
|
|
1003
|
+
providerMetadata: z8.record(z8.string(), z8.record(z8.string(), z8.unknown())).optional()
|
|
801
1004
|
})
|
|
802
1005
|
)
|
|
803
1006
|
);
|
|
@@ -806,17 +1009,17 @@ var gatewayEmbeddingResponseSchema = lazySchema5(
|
|
|
806
1009
|
import {
|
|
807
1010
|
combineHeaders as combineHeaders3,
|
|
808
1011
|
convertUint8ArrayToBase64,
|
|
809
|
-
createJsonResponseHandler as
|
|
810
|
-
createJsonErrorResponseHandler as
|
|
1012
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
1013
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler6,
|
|
811
1014
|
postJsonToApi as postJsonToApi3,
|
|
812
|
-
resolve as
|
|
1015
|
+
resolve as resolve6
|
|
813
1016
|
} from "@ai-sdk/provider-utils";
|
|
814
|
-
import { z as
|
|
1017
|
+
import { z as z9 } from "zod/v4";
|
|
815
1018
|
var GatewayImageModel = class {
|
|
816
1019
|
constructor(modelId, config) {
|
|
817
1020
|
this.modelId = modelId;
|
|
818
1021
|
this.config = config;
|
|
819
|
-
this.specificationVersion = "
|
|
1022
|
+
this.specificationVersion = "v4";
|
|
820
1023
|
// Set a very large number to prevent client-side splitting of requests
|
|
821
1024
|
this.maxImagesPerCall = Number.MAX_SAFE_INTEGER;
|
|
822
1025
|
}
|
|
@@ -836,7 +1039,7 @@ var GatewayImageModel = class {
|
|
|
836
1039
|
abortSignal
|
|
837
1040
|
}) {
|
|
838
1041
|
var _a9, _b9, _c, _d;
|
|
839
|
-
const resolvedHeaders = await
|
|
1042
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
840
1043
|
try {
|
|
841
1044
|
const {
|
|
842
1045
|
responseHeaders,
|
|
@@ -848,7 +1051,7 @@ var GatewayImageModel = class {
|
|
|
848
1051
|
resolvedHeaders,
|
|
849
1052
|
headers != null ? headers : {},
|
|
850
1053
|
this.getModelConfigHeaders(),
|
|
851
|
-
await
|
|
1054
|
+
await resolve6(this.config.o11yHeaders)
|
|
852
1055
|
),
|
|
853
1056
|
body: {
|
|
854
1057
|
prompt,
|
|
@@ -862,11 +1065,11 @@ var GatewayImageModel = class {
|
|
|
862
1065
|
},
|
|
863
1066
|
...mask && { mask: maybeEncodeImageFile(mask) }
|
|
864
1067
|
},
|
|
865
|
-
successfulResponseHandler:
|
|
1068
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
866
1069
|
gatewayImageResponseSchema
|
|
867
1070
|
),
|
|
868
|
-
failedResponseHandler:
|
|
869
|
-
errorSchema:
|
|
1071
|
+
failedResponseHandler: createJsonErrorResponseHandler6({
|
|
1072
|
+
errorSchema: z9.any(),
|
|
870
1073
|
errorToMessage: (data) => data
|
|
871
1074
|
}),
|
|
872
1075
|
...abortSignal && { abortSignal },
|
|
@@ -899,7 +1102,7 @@ var GatewayImageModel = class {
|
|
|
899
1102
|
}
|
|
900
1103
|
getModelConfigHeaders() {
|
|
901
1104
|
return {
|
|
902
|
-
"ai-image-model-specification-version": "
|
|
1105
|
+
"ai-image-model-specification-version": "4",
|
|
903
1106
|
"ai-model-id": this.modelId
|
|
904
1107
|
};
|
|
905
1108
|
}
|
|
@@ -913,35 +1116,35 @@ function maybeEncodeImageFile(file) {
|
|
|
913
1116
|
}
|
|
914
1117
|
return file;
|
|
915
1118
|
}
|
|
916
|
-
var providerMetadataEntrySchema =
|
|
917
|
-
images:
|
|
918
|
-
}).catchall(
|
|
919
|
-
var gatewayImageWarningSchema =
|
|
920
|
-
|
|
921
|
-
type:
|
|
922
|
-
feature:
|
|
923
|
-
details:
|
|
1119
|
+
var providerMetadataEntrySchema = z9.object({
|
|
1120
|
+
images: z9.array(z9.unknown()).optional()
|
|
1121
|
+
}).catchall(z9.unknown());
|
|
1122
|
+
var gatewayImageWarningSchema = z9.discriminatedUnion("type", [
|
|
1123
|
+
z9.object({
|
|
1124
|
+
type: z9.literal("unsupported"),
|
|
1125
|
+
feature: z9.string(),
|
|
1126
|
+
details: z9.string().optional()
|
|
924
1127
|
}),
|
|
925
|
-
|
|
926
|
-
type:
|
|
927
|
-
feature:
|
|
928
|
-
details:
|
|
1128
|
+
z9.object({
|
|
1129
|
+
type: z9.literal("compatibility"),
|
|
1130
|
+
feature: z9.string(),
|
|
1131
|
+
details: z9.string().optional()
|
|
929
1132
|
}),
|
|
930
|
-
|
|
931
|
-
type:
|
|
932
|
-
message:
|
|
1133
|
+
z9.object({
|
|
1134
|
+
type: z9.literal("other"),
|
|
1135
|
+
message: z9.string()
|
|
933
1136
|
})
|
|
934
1137
|
]);
|
|
935
|
-
var gatewayImageUsageSchema =
|
|
936
|
-
inputTokens:
|
|
937
|
-
outputTokens:
|
|
938
|
-
totalTokens:
|
|
1138
|
+
var gatewayImageUsageSchema = z9.object({
|
|
1139
|
+
inputTokens: z9.number().nullish(),
|
|
1140
|
+
outputTokens: z9.number().nullish(),
|
|
1141
|
+
totalTokens: z9.number().nullish()
|
|
939
1142
|
});
|
|
940
|
-
var gatewayImageResponseSchema =
|
|
941
|
-
images:
|
|
1143
|
+
var gatewayImageResponseSchema = z9.object({
|
|
1144
|
+
images: z9.array(z9.string()),
|
|
942
1145
|
// Always base64 strings over the wire
|
|
943
|
-
warnings:
|
|
944
|
-
providerMetadata:
|
|
1146
|
+
warnings: z9.array(gatewayImageWarningSchema).optional(),
|
|
1147
|
+
providerMetadata: z9.record(z9.string(), providerMetadataEntrySchema).optional(),
|
|
945
1148
|
usage: gatewayImageUsageSchema.optional()
|
|
946
1149
|
});
|
|
947
1150
|
|
|
@@ -950,17 +1153,17 @@ import { APICallError as APICallError2 } from "@ai-sdk/provider";
|
|
|
950
1153
|
import {
|
|
951
1154
|
combineHeaders as combineHeaders4,
|
|
952
1155
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
953
|
-
createJsonErrorResponseHandler as
|
|
1156
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler7,
|
|
954
1157
|
parseJsonEventStream,
|
|
955
1158
|
postJsonToApi as postJsonToApi4,
|
|
956
|
-
resolve as
|
|
1159
|
+
resolve as resolve7
|
|
957
1160
|
} from "@ai-sdk/provider-utils";
|
|
958
|
-
import { z as
|
|
1161
|
+
import { z as z10 } from "zod/v4";
|
|
959
1162
|
var GatewayVideoModel = class {
|
|
960
1163
|
constructor(modelId, config) {
|
|
961
1164
|
this.modelId = modelId;
|
|
962
1165
|
this.config = config;
|
|
963
|
-
this.specificationVersion = "
|
|
1166
|
+
this.specificationVersion = "v4";
|
|
964
1167
|
// Set a very large number to prevent client-side splitting of requests
|
|
965
1168
|
this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
|
|
966
1169
|
}
|
|
@@ -981,7 +1184,7 @@ var GatewayVideoModel = class {
|
|
|
981
1184
|
abortSignal
|
|
982
1185
|
}) {
|
|
983
1186
|
var _a9;
|
|
984
|
-
const resolvedHeaders = await
|
|
1187
|
+
const resolvedHeaders = await resolve7(this.config.headers());
|
|
985
1188
|
try {
|
|
986
1189
|
const { responseHeaders, value: responseBody } = await postJsonToApi4({
|
|
987
1190
|
url: this.getUrl(),
|
|
@@ -989,7 +1192,7 @@ var GatewayVideoModel = class {
|
|
|
989
1192
|
resolvedHeaders,
|
|
990
1193
|
headers != null ? headers : {},
|
|
991
1194
|
this.getModelConfigHeaders(),
|
|
992
|
-
await
|
|
1195
|
+
await resolve7(this.config.o11yHeaders),
|
|
993
1196
|
{ accept: "text/event-stream" }
|
|
994
1197
|
),
|
|
995
1198
|
body: {
|
|
@@ -1067,8 +1270,8 @@ var GatewayVideoModel = class {
|
|
|
1067
1270
|
responseHeaders: Object.fromEntries([...response.headers])
|
|
1068
1271
|
};
|
|
1069
1272
|
},
|
|
1070
|
-
failedResponseHandler:
|
|
1071
|
-
errorSchema:
|
|
1273
|
+
failedResponseHandler: createJsonErrorResponseHandler7({
|
|
1274
|
+
errorSchema: z10.any(),
|
|
1072
1275
|
errorToMessage: (data) => data
|
|
1073
1276
|
}),
|
|
1074
1277
|
...abortSignal && { abortSignal },
|
|
@@ -1093,7 +1296,7 @@ var GatewayVideoModel = class {
|
|
|
1093
1296
|
}
|
|
1094
1297
|
getModelConfigHeaders() {
|
|
1095
1298
|
return {
|
|
1096
|
-
"ai-video-model-specification-version": "
|
|
1299
|
+
"ai-video-model-specification-version": "4",
|
|
1097
1300
|
"ai-model-id": this.modelId
|
|
1098
1301
|
};
|
|
1099
1302
|
}
|
|
@@ -1107,115 +1310,115 @@ function maybeEncodeVideoFile(file) {
|
|
|
1107
1310
|
}
|
|
1108
1311
|
return file;
|
|
1109
1312
|
}
|
|
1110
|
-
var providerMetadataEntrySchema2 =
|
|
1111
|
-
videos:
|
|
1112
|
-
}).catchall(
|
|
1113
|
-
var gatewayVideoDataSchema =
|
|
1114
|
-
|
|
1115
|
-
type:
|
|
1116
|
-
url:
|
|
1117
|
-
mediaType:
|
|
1313
|
+
var providerMetadataEntrySchema2 = z10.object({
|
|
1314
|
+
videos: z10.array(z10.unknown()).optional()
|
|
1315
|
+
}).catchall(z10.unknown());
|
|
1316
|
+
var gatewayVideoDataSchema = z10.union([
|
|
1317
|
+
z10.object({
|
|
1318
|
+
type: z10.literal("url"),
|
|
1319
|
+
url: z10.string(),
|
|
1320
|
+
mediaType: z10.string()
|
|
1118
1321
|
}),
|
|
1119
|
-
|
|
1120
|
-
type:
|
|
1121
|
-
data:
|
|
1122
|
-
mediaType:
|
|
1322
|
+
z10.object({
|
|
1323
|
+
type: z10.literal("base64"),
|
|
1324
|
+
data: z10.string(),
|
|
1325
|
+
mediaType: z10.string()
|
|
1123
1326
|
})
|
|
1124
1327
|
]);
|
|
1125
|
-
var gatewayVideoWarningSchema =
|
|
1126
|
-
|
|
1127
|
-
type:
|
|
1128
|
-
feature:
|
|
1129
|
-
details:
|
|
1328
|
+
var gatewayVideoWarningSchema = z10.discriminatedUnion("type", [
|
|
1329
|
+
z10.object({
|
|
1330
|
+
type: z10.literal("unsupported"),
|
|
1331
|
+
feature: z10.string(),
|
|
1332
|
+
details: z10.string().optional()
|
|
1130
1333
|
}),
|
|
1131
|
-
|
|
1132
|
-
type:
|
|
1133
|
-
feature:
|
|
1134
|
-
details:
|
|
1334
|
+
z10.object({
|
|
1335
|
+
type: z10.literal("compatibility"),
|
|
1336
|
+
feature: z10.string(),
|
|
1337
|
+
details: z10.string().optional()
|
|
1135
1338
|
}),
|
|
1136
|
-
|
|
1137
|
-
type:
|
|
1138
|
-
message:
|
|
1339
|
+
z10.object({
|
|
1340
|
+
type: z10.literal("other"),
|
|
1341
|
+
message: z10.string()
|
|
1139
1342
|
})
|
|
1140
1343
|
]);
|
|
1141
|
-
var gatewayVideoEventSchema =
|
|
1142
|
-
|
|
1143
|
-
type:
|
|
1144
|
-
videos:
|
|
1145
|
-
warnings:
|
|
1146
|
-
providerMetadata:
|
|
1344
|
+
var gatewayVideoEventSchema = z10.discriminatedUnion("type", [
|
|
1345
|
+
z10.object({
|
|
1346
|
+
type: z10.literal("result"),
|
|
1347
|
+
videos: z10.array(gatewayVideoDataSchema),
|
|
1348
|
+
warnings: z10.array(gatewayVideoWarningSchema).optional(),
|
|
1349
|
+
providerMetadata: z10.record(z10.string(), providerMetadataEntrySchema2).optional()
|
|
1147
1350
|
}),
|
|
1148
|
-
|
|
1149
|
-
type:
|
|
1150
|
-
message:
|
|
1151
|
-
errorType:
|
|
1152
|
-
statusCode:
|
|
1153
|
-
param:
|
|
1351
|
+
z10.object({
|
|
1352
|
+
type: z10.literal("error"),
|
|
1353
|
+
message: z10.string(),
|
|
1354
|
+
errorType: z10.string(),
|
|
1355
|
+
statusCode: z10.number(),
|
|
1356
|
+
param: z10.unknown().nullable()
|
|
1154
1357
|
})
|
|
1155
1358
|
]);
|
|
1156
1359
|
|
|
1157
1360
|
// src/tool/parallel-search.ts
|
|
1158
1361
|
import {
|
|
1159
1362
|
createProviderToolFactoryWithOutputSchema,
|
|
1160
|
-
lazySchema as
|
|
1161
|
-
zodSchema as
|
|
1363
|
+
lazySchema as lazySchema8,
|
|
1364
|
+
zodSchema as zodSchema8
|
|
1162
1365
|
} from "@ai-sdk/provider-utils";
|
|
1163
|
-
import { z as
|
|
1164
|
-
var parallelSearchInputSchema =
|
|
1165
|
-
() =>
|
|
1166
|
-
|
|
1167
|
-
objective:
|
|
1366
|
+
import { z as z11 } from "zod";
|
|
1367
|
+
var parallelSearchInputSchema = lazySchema8(
|
|
1368
|
+
() => zodSchema8(
|
|
1369
|
+
z11.object({
|
|
1370
|
+
objective: z11.string().describe(
|
|
1168
1371
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
1169
1372
|
),
|
|
1170
|
-
search_queries:
|
|
1373
|
+
search_queries: z11.array(z11.string()).optional().describe(
|
|
1171
1374
|
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
1172
1375
|
),
|
|
1173
|
-
mode:
|
|
1376
|
+
mode: z11.enum(["one-shot", "agentic"]).optional().describe(
|
|
1174
1377
|
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
1175
1378
|
),
|
|
1176
|
-
max_results:
|
|
1379
|
+
max_results: z11.number().optional().describe(
|
|
1177
1380
|
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
1178
1381
|
),
|
|
1179
|
-
source_policy:
|
|
1180
|
-
include_domains:
|
|
1181
|
-
exclude_domains:
|
|
1182
|
-
after_date:
|
|
1382
|
+
source_policy: z11.object({
|
|
1383
|
+
include_domains: z11.array(z11.string()).optional().describe("List of domains to include in search results."),
|
|
1384
|
+
exclude_domains: z11.array(z11.string()).optional().describe("List of domains to exclude from search results."),
|
|
1385
|
+
after_date: z11.string().optional().describe(
|
|
1183
1386
|
"Only include results published after this date (ISO 8601 format)."
|
|
1184
1387
|
)
|
|
1185
1388
|
}).optional().describe(
|
|
1186
1389
|
"Source policy for controlling which domains to include/exclude and freshness."
|
|
1187
1390
|
),
|
|
1188
|
-
excerpts:
|
|
1189
|
-
max_chars_per_result:
|
|
1190
|
-
max_chars_total:
|
|
1391
|
+
excerpts: z11.object({
|
|
1392
|
+
max_chars_per_result: z11.number().optional().describe("Maximum characters per result."),
|
|
1393
|
+
max_chars_total: z11.number().optional().describe("Maximum total characters across all results.")
|
|
1191
1394
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
1192
|
-
fetch_policy:
|
|
1193
|
-
max_age_seconds:
|
|
1395
|
+
fetch_policy: z11.object({
|
|
1396
|
+
max_age_seconds: z11.number().optional().describe(
|
|
1194
1397
|
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
1195
1398
|
)
|
|
1196
1399
|
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
1197
1400
|
})
|
|
1198
1401
|
)
|
|
1199
1402
|
);
|
|
1200
|
-
var parallelSearchOutputSchema =
|
|
1201
|
-
() =>
|
|
1202
|
-
|
|
1403
|
+
var parallelSearchOutputSchema = lazySchema8(
|
|
1404
|
+
() => zodSchema8(
|
|
1405
|
+
z11.union([
|
|
1203
1406
|
// Success response
|
|
1204
|
-
|
|
1205
|
-
searchId:
|
|
1206
|
-
results:
|
|
1207
|
-
|
|
1208
|
-
url:
|
|
1209
|
-
title:
|
|
1210
|
-
excerpt:
|
|
1211
|
-
publishDate:
|
|
1212
|
-
relevanceScore:
|
|
1407
|
+
z11.object({
|
|
1408
|
+
searchId: z11.string(),
|
|
1409
|
+
results: z11.array(
|
|
1410
|
+
z11.object({
|
|
1411
|
+
url: z11.string(),
|
|
1412
|
+
title: z11.string(),
|
|
1413
|
+
excerpt: z11.string(),
|
|
1414
|
+
publishDate: z11.string().nullable().optional(),
|
|
1415
|
+
relevanceScore: z11.number().optional()
|
|
1213
1416
|
})
|
|
1214
1417
|
)
|
|
1215
1418
|
}),
|
|
1216
1419
|
// Error response
|
|
1217
|
-
|
|
1218
|
-
error:
|
|
1420
|
+
z11.object({
|
|
1421
|
+
error: z11.enum([
|
|
1219
1422
|
"api_error",
|
|
1220
1423
|
"rate_limit",
|
|
1221
1424
|
"timeout",
|
|
@@ -1223,8 +1426,8 @@ var parallelSearchOutputSchema = lazySchema6(
|
|
|
1223
1426
|
"configuration_error",
|
|
1224
1427
|
"unknown"
|
|
1225
1428
|
]),
|
|
1226
|
-
statusCode:
|
|
1227
|
-
message:
|
|
1429
|
+
statusCode: z11.number().optional(),
|
|
1430
|
+
message: z11.string()
|
|
1228
1431
|
})
|
|
1229
1432
|
])
|
|
1230
1433
|
)
|
|
@@ -1239,79 +1442,79 @@ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
|
1239
1442
|
// src/tool/perplexity-search.ts
|
|
1240
1443
|
import {
|
|
1241
1444
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
1242
|
-
lazySchema as
|
|
1243
|
-
zodSchema as
|
|
1445
|
+
lazySchema as lazySchema9,
|
|
1446
|
+
zodSchema as zodSchema9
|
|
1244
1447
|
} from "@ai-sdk/provider-utils";
|
|
1245
|
-
import { z as
|
|
1246
|
-
var perplexitySearchInputSchema =
|
|
1247
|
-
() =>
|
|
1248
|
-
|
|
1249
|
-
query:
|
|
1448
|
+
import { z as z12 } from "zod";
|
|
1449
|
+
var perplexitySearchInputSchema = lazySchema9(
|
|
1450
|
+
() => zodSchema9(
|
|
1451
|
+
z12.object({
|
|
1452
|
+
query: z12.union([z12.string(), z12.array(z12.string())]).describe(
|
|
1250
1453
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
1251
1454
|
),
|
|
1252
|
-
max_results:
|
|
1455
|
+
max_results: z12.number().optional().describe(
|
|
1253
1456
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
1254
1457
|
),
|
|
1255
|
-
max_tokens_per_page:
|
|
1458
|
+
max_tokens_per_page: z12.number().optional().describe(
|
|
1256
1459
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
1257
1460
|
),
|
|
1258
|
-
max_tokens:
|
|
1461
|
+
max_tokens: z12.number().optional().describe(
|
|
1259
1462
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
1260
1463
|
),
|
|
1261
|
-
country:
|
|
1464
|
+
country: z12.string().optional().describe(
|
|
1262
1465
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
1263
1466
|
),
|
|
1264
|
-
search_domain_filter:
|
|
1467
|
+
search_domain_filter: z12.array(z12.string()).optional().describe(
|
|
1265
1468
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
1266
1469
|
),
|
|
1267
|
-
search_language_filter:
|
|
1470
|
+
search_language_filter: z12.array(z12.string()).optional().describe(
|
|
1268
1471
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
1269
1472
|
),
|
|
1270
|
-
search_after_date:
|
|
1473
|
+
search_after_date: z12.string().optional().describe(
|
|
1271
1474
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
1272
1475
|
),
|
|
1273
|
-
search_before_date:
|
|
1476
|
+
search_before_date: z12.string().optional().describe(
|
|
1274
1477
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
1275
1478
|
),
|
|
1276
|
-
last_updated_after_filter:
|
|
1479
|
+
last_updated_after_filter: z12.string().optional().describe(
|
|
1277
1480
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
1278
1481
|
),
|
|
1279
|
-
last_updated_before_filter:
|
|
1482
|
+
last_updated_before_filter: z12.string().optional().describe(
|
|
1280
1483
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
1281
1484
|
),
|
|
1282
|
-
search_recency_filter:
|
|
1485
|
+
search_recency_filter: z12.enum(["day", "week", "month", "year"]).optional().describe(
|
|
1283
1486
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
1284
1487
|
)
|
|
1285
1488
|
})
|
|
1286
1489
|
)
|
|
1287
1490
|
);
|
|
1288
|
-
var perplexitySearchOutputSchema =
|
|
1289
|
-
() =>
|
|
1290
|
-
|
|
1491
|
+
var perplexitySearchOutputSchema = lazySchema9(
|
|
1492
|
+
() => zodSchema9(
|
|
1493
|
+
z12.union([
|
|
1291
1494
|
// Success response
|
|
1292
|
-
|
|
1293
|
-
results:
|
|
1294
|
-
|
|
1295
|
-
title:
|
|
1296
|
-
url:
|
|
1297
|
-
snippet:
|
|
1298
|
-
date:
|
|
1299
|
-
lastUpdated:
|
|
1495
|
+
z12.object({
|
|
1496
|
+
results: z12.array(
|
|
1497
|
+
z12.object({
|
|
1498
|
+
title: z12.string(),
|
|
1499
|
+
url: z12.string(),
|
|
1500
|
+
snippet: z12.string(),
|
|
1501
|
+
date: z12.string().optional(),
|
|
1502
|
+
lastUpdated: z12.string().optional()
|
|
1300
1503
|
})
|
|
1301
1504
|
),
|
|
1302
|
-
id:
|
|
1505
|
+
id: z12.string()
|
|
1303
1506
|
}),
|
|
1304
1507
|
// Error response
|
|
1305
|
-
|
|
1306
|
-
error:
|
|
1508
|
+
z12.object({
|
|
1509
|
+
error: z12.enum([
|
|
1307
1510
|
"api_error",
|
|
1308
1511
|
"rate_limit",
|
|
1309
1512
|
"timeout",
|
|
1310
1513
|
"invalid_input",
|
|
1311
1514
|
"unknown"
|
|
1312
1515
|
]),
|
|
1313
|
-
statusCode:
|
|
1314
|
-
message:
|
|
1516
|
+
statusCode: z12.number().optional(),
|
|
1517
|
+
message: z12.string()
|
|
1315
1518
|
})
|
|
1316
1519
|
])
|
|
1317
1520
|
)
|
|
@@ -1356,7 +1559,7 @@ async function getVercelRequestId() {
|
|
|
1356
1559
|
import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
|
|
1357
1560
|
|
|
1358
1561
|
// src/version.ts
|
|
1359
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1562
|
+
var VERSION = true ? "4.0.0-beta.31" : "0.0.0-test";
|
|
1360
1563
|
|
|
1361
1564
|
// src/gateway-provider.ts
|
|
1362
1565
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -1458,6 +1661,30 @@ function createGatewayProvider(options = {}) {
|
|
|
1458
1661
|
);
|
|
1459
1662
|
});
|
|
1460
1663
|
};
|
|
1664
|
+
const getSpendReport = async (params) => {
|
|
1665
|
+
return new GatewaySpendReport({
|
|
1666
|
+
baseURL,
|
|
1667
|
+
headers: getHeaders,
|
|
1668
|
+
fetch: options.fetch
|
|
1669
|
+
}).getSpendReport(params).catch(async (error) => {
|
|
1670
|
+
throw await asGatewayError(
|
|
1671
|
+
error,
|
|
1672
|
+
await parseAuthMethod(await getHeaders())
|
|
1673
|
+
);
|
|
1674
|
+
});
|
|
1675
|
+
};
|
|
1676
|
+
const getGenerationInfo = async (params) => {
|
|
1677
|
+
return new GatewayGenerationInfoFetcher({
|
|
1678
|
+
baseURL,
|
|
1679
|
+
headers: getHeaders,
|
|
1680
|
+
fetch: options.fetch
|
|
1681
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
1682
|
+
throw await asGatewayError(
|
|
1683
|
+
error,
|
|
1684
|
+
await parseAuthMethod(await getHeaders())
|
|
1685
|
+
);
|
|
1686
|
+
});
|
|
1687
|
+
};
|
|
1461
1688
|
const provider = function(modelId) {
|
|
1462
1689
|
if (new.target) {
|
|
1463
1690
|
throw new Error(
|
|
@@ -1466,9 +1693,11 @@ function createGatewayProvider(options = {}) {
|
|
|
1466
1693
|
}
|
|
1467
1694
|
return createLanguageModel(modelId);
|
|
1468
1695
|
};
|
|
1469
|
-
provider.specificationVersion = "
|
|
1696
|
+
provider.specificationVersion = "v4";
|
|
1470
1697
|
provider.getAvailableModels = getAvailableModels;
|
|
1471
1698
|
provider.getCredits = getCredits;
|
|
1699
|
+
provider.getSpendReport = getSpendReport;
|
|
1700
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
1472
1701
|
provider.imageModel = (modelId) => {
|
|
1473
1702
|
return new GatewayImageModel(modelId, {
|
|
1474
1703
|
provider: "gateway",
|