@ai-sdk/gateway 2.0.80 → 2.0.82
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.d.mts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +175 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -122
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -636,16 +636,110 @@ var gatewaySpendReportResponseSchema = lazySchema(
|
|
|
636
636
|
)
|
|
637
637
|
);
|
|
638
638
|
|
|
639
|
+
// src/gateway-generation-info.ts
|
|
640
|
+
import {
|
|
641
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
|
|
642
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
643
|
+
getFromApi as getFromApi3,
|
|
644
|
+
lazySchema as lazySchema2,
|
|
645
|
+
resolve as resolve3,
|
|
646
|
+
zodSchema as zodSchema6
|
|
647
|
+
} from "@ai-sdk/provider-utils";
|
|
648
|
+
import { z as z6 } from "zod/v4";
|
|
649
|
+
var GatewayGenerationInfoFetcher = class {
|
|
650
|
+
constructor(config) {
|
|
651
|
+
this.config = config;
|
|
652
|
+
}
|
|
653
|
+
async getGenerationInfo(params) {
|
|
654
|
+
try {
|
|
655
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
656
|
+
const { value } = await getFromApi3({
|
|
657
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
658
|
+
headers: await resolve3(this.config.headers()),
|
|
659
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
660
|
+
gatewayGenerationInfoResponseSchema
|
|
661
|
+
),
|
|
662
|
+
failedResponseHandler: createJsonErrorResponseHandler3({
|
|
663
|
+
errorSchema: z6.any(),
|
|
664
|
+
errorToMessage: (data) => data
|
|
665
|
+
}),
|
|
666
|
+
fetch: this.config.fetch
|
|
667
|
+
});
|
|
668
|
+
return value;
|
|
669
|
+
} catch (error) {
|
|
670
|
+
throw await asGatewayError(error);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var gatewayGenerationInfoResponseSchema = lazySchema2(
|
|
675
|
+
() => zodSchema6(
|
|
676
|
+
z6.object({
|
|
677
|
+
data: z6.object({
|
|
678
|
+
id: z6.string(),
|
|
679
|
+
total_cost: z6.number(),
|
|
680
|
+
upstream_inference_cost: z6.number(),
|
|
681
|
+
usage: z6.number(),
|
|
682
|
+
created_at: z6.string(),
|
|
683
|
+
model: z6.string(),
|
|
684
|
+
is_byok: z6.boolean(),
|
|
685
|
+
provider_name: z6.string(),
|
|
686
|
+
streamed: z6.boolean(),
|
|
687
|
+
finish_reason: z6.string(),
|
|
688
|
+
latency: z6.number(),
|
|
689
|
+
generation_time: z6.number(),
|
|
690
|
+
native_tokens_prompt: z6.number(),
|
|
691
|
+
native_tokens_completion: z6.number(),
|
|
692
|
+
native_tokens_reasoning: z6.number(),
|
|
693
|
+
native_tokens_cached: z6.number(),
|
|
694
|
+
native_tokens_cache_creation: z6.number(),
|
|
695
|
+
billable_web_search_calls: z6.number()
|
|
696
|
+
}).transform(
|
|
697
|
+
({
|
|
698
|
+
total_cost,
|
|
699
|
+
upstream_inference_cost,
|
|
700
|
+
created_at,
|
|
701
|
+
is_byok,
|
|
702
|
+
provider_name,
|
|
703
|
+
finish_reason,
|
|
704
|
+
generation_time,
|
|
705
|
+
native_tokens_prompt,
|
|
706
|
+
native_tokens_completion,
|
|
707
|
+
native_tokens_reasoning,
|
|
708
|
+
native_tokens_cached,
|
|
709
|
+
native_tokens_cache_creation,
|
|
710
|
+
billable_web_search_calls,
|
|
711
|
+
...rest
|
|
712
|
+
}) => ({
|
|
713
|
+
...rest,
|
|
714
|
+
totalCost: total_cost,
|
|
715
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
716
|
+
createdAt: created_at,
|
|
717
|
+
isByok: is_byok,
|
|
718
|
+
providerName: provider_name,
|
|
719
|
+
finishReason: finish_reason,
|
|
720
|
+
generationTime: generation_time,
|
|
721
|
+
promptTokens: native_tokens_prompt,
|
|
722
|
+
completionTokens: native_tokens_completion,
|
|
723
|
+
reasoningTokens: native_tokens_reasoning,
|
|
724
|
+
cachedTokens: native_tokens_cached,
|
|
725
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
726
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
727
|
+
})
|
|
728
|
+
)
|
|
729
|
+
}).transform(({ data }) => data)
|
|
730
|
+
)
|
|
731
|
+
);
|
|
732
|
+
|
|
639
733
|
// src/gateway-language-model.ts
|
|
640
734
|
import {
|
|
641
735
|
combineHeaders,
|
|
642
736
|
createEventSourceResponseHandler,
|
|
643
|
-
createJsonErrorResponseHandler as
|
|
644
|
-
createJsonResponseHandler as
|
|
737
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
|
|
738
|
+
createJsonResponseHandler as createJsonResponseHandler4,
|
|
645
739
|
postJsonToApi,
|
|
646
|
-
resolve as
|
|
740
|
+
resolve as resolve4
|
|
647
741
|
} from "@ai-sdk/provider-utils";
|
|
648
|
-
import { z as
|
|
742
|
+
import { z as z7 } from "zod/v4";
|
|
649
743
|
var GatewayLanguageModel = class {
|
|
650
744
|
constructor(modelId, config) {
|
|
651
745
|
this.modelId = modelId;
|
|
@@ -666,7 +760,7 @@ var GatewayLanguageModel = class {
|
|
|
666
760
|
async doGenerate(options) {
|
|
667
761
|
const { args, warnings } = await this.getArgs(options);
|
|
668
762
|
const { abortSignal } = options;
|
|
669
|
-
const resolvedHeaders = await
|
|
763
|
+
const resolvedHeaders = await resolve4(this.config.headers());
|
|
670
764
|
try {
|
|
671
765
|
const {
|
|
672
766
|
responseHeaders,
|
|
@@ -678,12 +772,12 @@ var GatewayLanguageModel = class {
|
|
|
678
772
|
resolvedHeaders,
|
|
679
773
|
options.headers,
|
|
680
774
|
this.getModelConfigHeaders(this.modelId, false),
|
|
681
|
-
await
|
|
775
|
+
await resolve4(this.config.o11yHeaders)
|
|
682
776
|
),
|
|
683
777
|
body: args,
|
|
684
|
-
successfulResponseHandler:
|
|
685
|
-
failedResponseHandler:
|
|
686
|
-
errorSchema:
|
|
778
|
+
successfulResponseHandler: createJsonResponseHandler4(z7.any()),
|
|
779
|
+
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
780
|
+
errorSchema: z7.any(),
|
|
687
781
|
errorToMessage: (data) => data
|
|
688
782
|
}),
|
|
689
783
|
...abortSignal && { abortSignal },
|
|
@@ -702,7 +796,7 @@ var GatewayLanguageModel = class {
|
|
|
702
796
|
async doStream(options) {
|
|
703
797
|
const { args, warnings } = await this.getArgs(options);
|
|
704
798
|
const { abortSignal } = options;
|
|
705
|
-
const resolvedHeaders = await
|
|
799
|
+
const resolvedHeaders = await resolve4(this.config.headers());
|
|
706
800
|
try {
|
|
707
801
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
708
802
|
url: this.getUrl(),
|
|
@@ -710,12 +804,12 @@ var GatewayLanguageModel = class {
|
|
|
710
804
|
resolvedHeaders,
|
|
711
805
|
options.headers,
|
|
712
806
|
this.getModelConfigHeaders(this.modelId, true),
|
|
713
|
-
await
|
|
807
|
+
await resolve4(this.config.o11yHeaders)
|
|
714
808
|
),
|
|
715
809
|
body: args,
|
|
716
|
-
successfulResponseHandler: createEventSourceResponseHandler(
|
|
717
|
-
failedResponseHandler:
|
|
718
|
-
errorSchema:
|
|
810
|
+
successfulResponseHandler: createEventSourceResponseHandler(z7.any()),
|
|
811
|
+
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
812
|
+
errorSchema: z7.any(),
|
|
719
813
|
errorToMessage: (data) => data
|
|
720
814
|
}),
|
|
721
815
|
...abortSignal && { abortSignal },
|
|
@@ -795,14 +889,14 @@ var GatewayLanguageModel = class {
|
|
|
795
889
|
// src/gateway-embedding-model.ts
|
|
796
890
|
import {
|
|
797
891
|
combineHeaders as combineHeaders2,
|
|
798
|
-
createJsonErrorResponseHandler as
|
|
799
|
-
createJsonResponseHandler as
|
|
892
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler5,
|
|
893
|
+
createJsonResponseHandler as createJsonResponseHandler5,
|
|
800
894
|
lazyValidator as lazyValidator5,
|
|
801
895
|
postJsonToApi as postJsonToApi2,
|
|
802
|
-
resolve as
|
|
803
|
-
zodSchema as
|
|
896
|
+
resolve as resolve5,
|
|
897
|
+
zodSchema as zodSchema7
|
|
804
898
|
} from "@ai-sdk/provider-utils";
|
|
805
|
-
import { z as
|
|
899
|
+
import { z as z8 } from "zod/v4";
|
|
806
900
|
var GatewayEmbeddingModel = class {
|
|
807
901
|
constructor(modelId, config) {
|
|
808
902
|
this.modelId = modelId;
|
|
@@ -821,7 +915,7 @@ var GatewayEmbeddingModel = class {
|
|
|
821
915
|
providerOptions
|
|
822
916
|
}) {
|
|
823
917
|
var _a9;
|
|
824
|
-
const resolvedHeaders = await
|
|
918
|
+
const resolvedHeaders = await resolve5(this.config.headers());
|
|
825
919
|
try {
|
|
826
920
|
const {
|
|
827
921
|
responseHeaders,
|
|
@@ -833,17 +927,17 @@ var GatewayEmbeddingModel = class {
|
|
|
833
927
|
resolvedHeaders,
|
|
834
928
|
headers != null ? headers : {},
|
|
835
929
|
this.getModelConfigHeaders(),
|
|
836
|
-
await
|
|
930
|
+
await resolve5(this.config.o11yHeaders)
|
|
837
931
|
),
|
|
838
932
|
body: {
|
|
839
933
|
input: values.length === 1 ? values[0] : values,
|
|
840
934
|
...providerOptions ? { providerOptions } : {}
|
|
841
935
|
},
|
|
842
|
-
successfulResponseHandler:
|
|
936
|
+
successfulResponseHandler: createJsonResponseHandler5(
|
|
843
937
|
gatewayEmbeddingResponseSchema
|
|
844
938
|
),
|
|
845
|
-
failedResponseHandler:
|
|
846
|
-
errorSchema:
|
|
939
|
+
failedResponseHandler: createJsonErrorResponseHandler5({
|
|
940
|
+
errorSchema: z8.any(),
|
|
847
941
|
errorToMessage: (data) => data
|
|
848
942
|
}),
|
|
849
943
|
...abortSignal && { abortSignal },
|
|
@@ -870,11 +964,11 @@ var GatewayEmbeddingModel = class {
|
|
|
870
964
|
}
|
|
871
965
|
};
|
|
872
966
|
var gatewayEmbeddingResponseSchema = lazyValidator5(
|
|
873
|
-
() =>
|
|
874
|
-
|
|
875
|
-
embeddings:
|
|
876
|
-
usage:
|
|
877
|
-
providerMetadata:
|
|
967
|
+
() => zodSchema7(
|
|
968
|
+
z8.object({
|
|
969
|
+
embeddings: z8.array(z8.array(z8.number())),
|
|
970
|
+
usage: z8.object({ tokens: z8.number() }).nullish(),
|
|
971
|
+
providerMetadata: z8.record(z8.string(), z8.record(z8.string(), z8.unknown())).optional()
|
|
878
972
|
})
|
|
879
973
|
)
|
|
880
974
|
);
|
|
@@ -882,12 +976,12 @@ var gatewayEmbeddingResponseSchema = lazyValidator5(
|
|
|
882
976
|
// src/gateway-image-model.ts
|
|
883
977
|
import {
|
|
884
978
|
combineHeaders as combineHeaders3,
|
|
885
|
-
createJsonResponseHandler as
|
|
886
|
-
createJsonErrorResponseHandler as
|
|
979
|
+
createJsonResponseHandler as createJsonResponseHandler6,
|
|
980
|
+
createJsonErrorResponseHandler as createJsonErrorResponseHandler6,
|
|
887
981
|
postJsonToApi as postJsonToApi3,
|
|
888
|
-
resolve as
|
|
982
|
+
resolve as resolve6
|
|
889
983
|
} from "@ai-sdk/provider-utils";
|
|
890
|
-
import { z as
|
|
984
|
+
import { z as z9 } from "zod/v4";
|
|
891
985
|
var GatewayImageModel = class {
|
|
892
986
|
constructor(modelId, config) {
|
|
893
987
|
this.modelId = modelId;
|
|
@@ -910,7 +1004,7 @@ var GatewayImageModel = class {
|
|
|
910
1004
|
abortSignal
|
|
911
1005
|
}) {
|
|
912
1006
|
var _a9, _b9, _c, _d;
|
|
913
|
-
const resolvedHeaders = await
|
|
1007
|
+
const resolvedHeaders = await resolve6(this.config.headers());
|
|
914
1008
|
try {
|
|
915
1009
|
const {
|
|
916
1010
|
responseHeaders,
|
|
@@ -922,7 +1016,7 @@ var GatewayImageModel = class {
|
|
|
922
1016
|
resolvedHeaders,
|
|
923
1017
|
headers != null ? headers : {},
|
|
924
1018
|
this.getModelConfigHeaders(),
|
|
925
|
-
await
|
|
1019
|
+
await resolve6(this.config.o11yHeaders)
|
|
926
1020
|
),
|
|
927
1021
|
body: {
|
|
928
1022
|
prompt,
|
|
@@ -932,11 +1026,11 @@ var GatewayImageModel = class {
|
|
|
932
1026
|
...seed && { seed },
|
|
933
1027
|
...providerOptions && { providerOptions }
|
|
934
1028
|
},
|
|
935
|
-
successfulResponseHandler:
|
|
1029
|
+
successfulResponseHandler: createJsonResponseHandler6(
|
|
936
1030
|
gatewayImageResponseSchema
|
|
937
1031
|
),
|
|
938
|
-
failedResponseHandler:
|
|
939
|
-
errorSchema:
|
|
1032
|
+
failedResponseHandler: createJsonErrorResponseHandler6({
|
|
1033
|
+
errorSchema: z9.any(),
|
|
940
1034
|
errorToMessage: (data) => data
|
|
941
1035
|
}),
|
|
942
1036
|
...abortSignal && { abortSignal },
|
|
@@ -974,89 +1068,89 @@ var GatewayImageModel = class {
|
|
|
974
1068
|
};
|
|
975
1069
|
}
|
|
976
1070
|
};
|
|
977
|
-
var providerMetadataEntrySchema =
|
|
978
|
-
images:
|
|
979
|
-
}).catchall(
|
|
980
|
-
var gatewayImageUsageSchema =
|
|
981
|
-
inputTokens:
|
|
982
|
-
outputTokens:
|
|
983
|
-
totalTokens:
|
|
1071
|
+
var providerMetadataEntrySchema = z9.object({
|
|
1072
|
+
images: z9.array(z9.unknown()).optional()
|
|
1073
|
+
}).catchall(z9.unknown());
|
|
1074
|
+
var gatewayImageUsageSchema = z9.object({
|
|
1075
|
+
inputTokens: z9.number().nullish(),
|
|
1076
|
+
outputTokens: z9.number().nullish(),
|
|
1077
|
+
totalTokens: z9.number().nullish()
|
|
984
1078
|
});
|
|
985
|
-
var gatewayImageResponseSchema =
|
|
986
|
-
images:
|
|
1079
|
+
var gatewayImageResponseSchema = z9.object({
|
|
1080
|
+
images: z9.array(z9.string()),
|
|
987
1081
|
// Always base64 strings over the wire
|
|
988
|
-
warnings:
|
|
989
|
-
|
|
990
|
-
type:
|
|
991
|
-
message:
|
|
1082
|
+
warnings: z9.array(
|
|
1083
|
+
z9.object({
|
|
1084
|
+
type: z9.literal("other"),
|
|
1085
|
+
message: z9.string()
|
|
992
1086
|
})
|
|
993
1087
|
).optional(),
|
|
994
|
-
providerMetadata:
|
|
1088
|
+
providerMetadata: z9.record(z9.string(), providerMetadataEntrySchema).optional(),
|
|
995
1089
|
usage: gatewayImageUsageSchema.optional()
|
|
996
1090
|
});
|
|
997
1091
|
|
|
998
1092
|
// src/tool/parallel-search.ts
|
|
999
1093
|
import {
|
|
1000
1094
|
createProviderDefinedToolFactoryWithOutputSchema,
|
|
1001
|
-
lazySchema as
|
|
1002
|
-
zodSchema as
|
|
1095
|
+
lazySchema as lazySchema3,
|
|
1096
|
+
zodSchema as zodSchema8
|
|
1003
1097
|
} from "@ai-sdk/provider-utils";
|
|
1004
|
-
import { z as
|
|
1005
|
-
var parallelSearchInputSchema =
|
|
1006
|
-
() =>
|
|
1007
|
-
|
|
1008
|
-
objective:
|
|
1098
|
+
import { z as z10 } from "zod";
|
|
1099
|
+
var parallelSearchInputSchema = lazySchema3(
|
|
1100
|
+
() => zodSchema8(
|
|
1101
|
+
z10.object({
|
|
1102
|
+
objective: z10.string().describe(
|
|
1009
1103
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
1010
1104
|
),
|
|
1011
|
-
search_queries:
|
|
1105
|
+
search_queries: z10.array(z10.string()).optional().describe(
|
|
1012
1106
|
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
1013
1107
|
),
|
|
1014
|
-
mode:
|
|
1108
|
+
mode: z10.enum(["one-shot", "agentic"]).optional().describe(
|
|
1015
1109
|
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
1016
1110
|
),
|
|
1017
|
-
max_results:
|
|
1111
|
+
max_results: z10.number().optional().describe(
|
|
1018
1112
|
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
1019
1113
|
),
|
|
1020
|
-
source_policy:
|
|
1021
|
-
include_domains:
|
|
1022
|
-
exclude_domains:
|
|
1023
|
-
after_date:
|
|
1114
|
+
source_policy: z10.object({
|
|
1115
|
+
include_domains: z10.array(z10.string()).optional().describe("List of domains to include in search results."),
|
|
1116
|
+
exclude_domains: z10.array(z10.string()).optional().describe("List of domains to exclude from search results."),
|
|
1117
|
+
after_date: z10.string().optional().describe(
|
|
1024
1118
|
"Only include results published after this date (ISO 8601 format)."
|
|
1025
1119
|
)
|
|
1026
1120
|
}).optional().describe(
|
|
1027
1121
|
"Source policy for controlling which domains to include/exclude and freshness."
|
|
1028
1122
|
),
|
|
1029
|
-
excerpts:
|
|
1030
|
-
max_chars_per_result:
|
|
1031
|
-
max_chars_total:
|
|
1123
|
+
excerpts: z10.object({
|
|
1124
|
+
max_chars_per_result: z10.number().optional().describe("Maximum characters per result."),
|
|
1125
|
+
max_chars_total: z10.number().optional().describe("Maximum total characters across all results.")
|
|
1032
1126
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
1033
|
-
fetch_policy:
|
|
1034
|
-
max_age_seconds:
|
|
1127
|
+
fetch_policy: z10.object({
|
|
1128
|
+
max_age_seconds: z10.number().optional().describe(
|
|
1035
1129
|
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
1036
1130
|
)
|
|
1037
1131
|
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
1038
1132
|
})
|
|
1039
1133
|
)
|
|
1040
1134
|
);
|
|
1041
|
-
var parallelSearchOutputSchema =
|
|
1042
|
-
() =>
|
|
1043
|
-
|
|
1135
|
+
var parallelSearchOutputSchema = lazySchema3(
|
|
1136
|
+
() => zodSchema8(
|
|
1137
|
+
z10.union([
|
|
1044
1138
|
// Success response
|
|
1045
|
-
|
|
1046
|
-
searchId:
|
|
1047
|
-
results:
|
|
1048
|
-
|
|
1049
|
-
url:
|
|
1050
|
-
title:
|
|
1051
|
-
excerpt:
|
|
1052
|
-
publishDate:
|
|
1053
|
-
relevanceScore:
|
|
1139
|
+
z10.object({
|
|
1140
|
+
searchId: z10.string(),
|
|
1141
|
+
results: z10.array(
|
|
1142
|
+
z10.object({
|
|
1143
|
+
url: z10.string(),
|
|
1144
|
+
title: z10.string(),
|
|
1145
|
+
excerpt: z10.string(),
|
|
1146
|
+
publishDate: z10.string().nullable().optional(),
|
|
1147
|
+
relevanceScore: z10.number().optional()
|
|
1054
1148
|
})
|
|
1055
1149
|
)
|
|
1056
1150
|
}),
|
|
1057
1151
|
// Error response
|
|
1058
|
-
|
|
1059
|
-
error:
|
|
1152
|
+
z10.object({
|
|
1153
|
+
error: z10.enum([
|
|
1060
1154
|
"api_error",
|
|
1061
1155
|
"rate_limit",
|
|
1062
1156
|
"timeout",
|
|
@@ -1064,8 +1158,8 @@ var parallelSearchOutputSchema = lazySchema2(
|
|
|
1064
1158
|
"configuration_error",
|
|
1065
1159
|
"unknown"
|
|
1066
1160
|
]),
|
|
1067
|
-
statusCode:
|
|
1068
|
-
message:
|
|
1161
|
+
statusCode: z10.number().optional(),
|
|
1162
|
+
message: z10.string()
|
|
1069
1163
|
})
|
|
1070
1164
|
])
|
|
1071
1165
|
)
|
|
@@ -1081,79 +1175,79 @@ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
|
1081
1175
|
// src/tool/perplexity-search.ts
|
|
1082
1176
|
import {
|
|
1083
1177
|
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
|
|
1084
|
-
lazySchema as
|
|
1085
|
-
zodSchema as
|
|
1178
|
+
lazySchema as lazySchema4,
|
|
1179
|
+
zodSchema as zodSchema9
|
|
1086
1180
|
} from "@ai-sdk/provider-utils";
|
|
1087
|
-
import { z as
|
|
1088
|
-
var perplexitySearchInputSchema =
|
|
1089
|
-
() =>
|
|
1090
|
-
|
|
1091
|
-
query:
|
|
1181
|
+
import { z as z11 } from "zod";
|
|
1182
|
+
var perplexitySearchInputSchema = lazySchema4(
|
|
1183
|
+
() => zodSchema9(
|
|
1184
|
+
z11.object({
|
|
1185
|
+
query: z11.union([z11.string(), z11.array(z11.string())]).describe(
|
|
1092
1186
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
1093
1187
|
),
|
|
1094
|
-
max_results:
|
|
1188
|
+
max_results: z11.number().optional().describe(
|
|
1095
1189
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
1096
1190
|
),
|
|
1097
|
-
max_tokens_per_page:
|
|
1191
|
+
max_tokens_per_page: z11.number().optional().describe(
|
|
1098
1192
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
1099
1193
|
),
|
|
1100
|
-
max_tokens:
|
|
1194
|
+
max_tokens: z11.number().optional().describe(
|
|
1101
1195
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
1102
1196
|
),
|
|
1103
|
-
country:
|
|
1197
|
+
country: z11.string().optional().describe(
|
|
1104
1198
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
1105
1199
|
),
|
|
1106
|
-
search_domain_filter:
|
|
1200
|
+
search_domain_filter: z11.array(z11.string()).optional().describe(
|
|
1107
1201
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
1108
1202
|
),
|
|
1109
|
-
search_language_filter:
|
|
1203
|
+
search_language_filter: z11.array(z11.string()).optional().describe(
|
|
1110
1204
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
1111
1205
|
),
|
|
1112
|
-
search_after_date:
|
|
1206
|
+
search_after_date: z11.string().optional().describe(
|
|
1113
1207
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
1114
1208
|
),
|
|
1115
|
-
search_before_date:
|
|
1209
|
+
search_before_date: z11.string().optional().describe(
|
|
1116
1210
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
1117
1211
|
),
|
|
1118
|
-
last_updated_after_filter:
|
|
1212
|
+
last_updated_after_filter: z11.string().optional().describe(
|
|
1119
1213
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
1120
1214
|
),
|
|
1121
|
-
last_updated_before_filter:
|
|
1215
|
+
last_updated_before_filter: z11.string().optional().describe(
|
|
1122
1216
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
1123
1217
|
),
|
|
1124
|
-
search_recency_filter:
|
|
1218
|
+
search_recency_filter: z11.enum(["day", "week", "month", "year"]).optional().describe(
|
|
1125
1219
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
1126
1220
|
)
|
|
1127
1221
|
})
|
|
1128
1222
|
)
|
|
1129
1223
|
);
|
|
1130
|
-
var perplexitySearchOutputSchema =
|
|
1131
|
-
() =>
|
|
1132
|
-
|
|
1224
|
+
var perplexitySearchOutputSchema = lazySchema4(
|
|
1225
|
+
() => zodSchema9(
|
|
1226
|
+
z11.union([
|
|
1133
1227
|
// Success response
|
|
1134
|
-
|
|
1135
|
-
results:
|
|
1136
|
-
|
|
1137
|
-
title:
|
|
1138
|
-
url:
|
|
1139
|
-
snippet:
|
|
1140
|
-
date:
|
|
1141
|
-
lastUpdated:
|
|
1228
|
+
z11.object({
|
|
1229
|
+
results: z11.array(
|
|
1230
|
+
z11.object({
|
|
1231
|
+
title: z11.string(),
|
|
1232
|
+
url: z11.string(),
|
|
1233
|
+
snippet: z11.string(),
|
|
1234
|
+
date: z11.string().optional(),
|
|
1235
|
+
lastUpdated: z11.string().optional()
|
|
1142
1236
|
})
|
|
1143
1237
|
),
|
|
1144
|
-
id:
|
|
1238
|
+
id: z11.string()
|
|
1145
1239
|
}),
|
|
1146
1240
|
// Error response
|
|
1147
|
-
|
|
1148
|
-
error:
|
|
1241
|
+
z11.object({
|
|
1242
|
+
error: z11.enum([
|
|
1149
1243
|
"api_error",
|
|
1150
1244
|
"rate_limit",
|
|
1151
1245
|
"timeout",
|
|
1152
1246
|
"invalid_input",
|
|
1153
1247
|
"unknown"
|
|
1154
1248
|
]),
|
|
1155
|
-
statusCode:
|
|
1156
|
-
message:
|
|
1249
|
+
statusCode: z11.number().optional(),
|
|
1250
|
+
message: z11.string()
|
|
1157
1251
|
})
|
|
1158
1252
|
])
|
|
1159
1253
|
)
|
|
@@ -1199,7 +1293,7 @@ async function getVercelRequestId() {
|
|
|
1199
1293
|
import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
|
|
1200
1294
|
|
|
1201
1295
|
// src/version.ts
|
|
1202
|
-
var VERSION = true ? "2.0.
|
|
1296
|
+
var VERSION = true ? "2.0.82" : "0.0.0-test";
|
|
1203
1297
|
|
|
1204
1298
|
// src/gateway-provider.ts
|
|
1205
1299
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
@@ -1311,6 +1405,18 @@ function createGatewayProvider(options = {}) {
|
|
|
1311
1405
|
);
|
|
1312
1406
|
});
|
|
1313
1407
|
};
|
|
1408
|
+
const getGenerationInfo = async (params) => {
|
|
1409
|
+
return new GatewayGenerationInfoFetcher({
|
|
1410
|
+
baseURL,
|
|
1411
|
+
headers: getHeaders,
|
|
1412
|
+
fetch: options.fetch
|
|
1413
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
1414
|
+
throw await asGatewayError(
|
|
1415
|
+
error,
|
|
1416
|
+
await parseAuthMethod(await getHeaders())
|
|
1417
|
+
);
|
|
1418
|
+
});
|
|
1419
|
+
};
|
|
1314
1420
|
const provider = function(modelId) {
|
|
1315
1421
|
if (new.target) {
|
|
1316
1422
|
throw new Error(
|
|
@@ -1322,6 +1428,7 @@ function createGatewayProvider(options = {}) {
|
|
|
1322
1428
|
provider.getAvailableModels = getAvailableModels;
|
|
1323
1429
|
provider.getCredits = getCredits;
|
|
1324
1430
|
provider.getSpendReport = getSpendReport;
|
|
1431
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
1325
1432
|
provider.imageModel = (modelId) => {
|
|
1326
1433
|
return new GatewayImageModel(modelId, {
|
|
1327
1434
|
provider: "gateway",
|