@ai-sdk/gateway 4.0.45 → 4.0.47
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 +19 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +416 -406
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/errors/create-gateway-error.ts +1 -1
- package/src/errors/gateway-forbidden-error.ts +1 -1
- package/src/errors/gateway-model-not-found-error.ts +1 -1
- package/src/errors/parse-auth-method.ts +1 -1
- package/src/gateway-embedding-model.ts +1 -1
- package/src/gateway-fetch-metadata.ts +1 -1
- package/src/gateway-generation-info.ts +1 -1
- package/src/gateway-image-model-settings.ts +1 -0
- package/src/gateway-image-model.ts +1 -1
- package/src/gateway-language-model-settings.ts +4 -3
- package/src/gateway-language-model.ts +1 -1
- package/src/gateway-provider.ts +1 -1
- package/src/gateway-reranking-model.ts +1 -1
- package/src/gateway-speech-model-settings.ts +3 -0
- package/src/gateway-speech-model.ts +1 -1
- package/src/gateway-spend-report.ts +1 -1
- package/src/gateway-transcription-model-settings.ts +1 -0
- package/src/gateway-transcription-model.ts +1 -1
- package/src/gateway-video-model-settings.ts +1 -0
- package/src/gateway-video-model.ts +1 -1
- package/src/tool/exa-search.ts +1 -1
- package/src/tool/parallel-search.ts +1 -1
- package/src/tool/perplexity-search.ts +1 -1
- package/src/zod.ts +31 -0
package/dist/index.js
CHANGED
|
@@ -69,14 +69,40 @@ import {
|
|
|
69
69
|
withoutTrailingSlash,
|
|
70
70
|
withUserAgentSuffix
|
|
71
71
|
} from "@ai-sdk/provider-utils";
|
|
72
|
-
|
|
72
|
+
|
|
73
|
+
// src/zod.ts
|
|
74
|
+
import {
|
|
75
|
+
any,
|
|
76
|
+
array,
|
|
77
|
+
boolean,
|
|
78
|
+
discriminatedUnion,
|
|
79
|
+
enum as enumType,
|
|
80
|
+
literal,
|
|
81
|
+
number,
|
|
82
|
+
object,
|
|
83
|
+
record,
|
|
84
|
+
string,
|
|
85
|
+
union,
|
|
86
|
+
unknown
|
|
87
|
+
} from "zod/v4";
|
|
88
|
+
var z = {
|
|
89
|
+
any,
|
|
90
|
+
array,
|
|
91
|
+
boolean,
|
|
92
|
+
discriminatedUnion,
|
|
93
|
+
enum: enumType,
|
|
94
|
+
literal,
|
|
95
|
+
number,
|
|
96
|
+
object,
|
|
97
|
+
record,
|
|
98
|
+
string,
|
|
99
|
+
union,
|
|
100
|
+
unknown
|
|
101
|
+
};
|
|
73
102
|
|
|
74
103
|
// src/errors/as-gateway-error.ts
|
|
75
104
|
import { APICallError } from "@ai-sdk/provider";
|
|
76
105
|
|
|
77
|
-
// src/errors/create-gateway-error.ts
|
|
78
|
-
import { z as z3 } from "zod/v4";
|
|
79
|
-
|
|
80
106
|
// src/errors/gateway-error.ts
|
|
81
107
|
var marker = "vercel.ai.gateway.error";
|
|
82
108
|
var symbol = Symbol.for(marker);
|
|
@@ -227,7 +253,6 @@ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a4 = symbol4, _b
|
|
|
227
253
|
};
|
|
228
254
|
|
|
229
255
|
// src/errors/gateway-model-not-found-error.ts
|
|
230
|
-
import { z } from "zod/v4";
|
|
231
256
|
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
232
257
|
var name4 = "GatewayModelNotFoundError";
|
|
233
258
|
var marker5 = `vercel.ai.gateway.error.${name4}`;
|
|
@@ -307,15 +332,14 @@ var GatewayFailedDependencyError = class extends (_b7 = GatewayError, _a7 = symb
|
|
|
307
332
|
};
|
|
308
333
|
|
|
309
334
|
// src/errors/gateway-forbidden-error.ts
|
|
310
|
-
import { z as z2 } from "zod/v4";
|
|
311
335
|
import { lazySchema as lazySchema2, zodSchema as zodSchema2 } from "@ai-sdk/provider-utils";
|
|
312
336
|
var name7 = "GatewayForbiddenError";
|
|
313
337
|
var marker8 = `vercel.ai.gateway.error.${name7}`;
|
|
314
338
|
var symbol8 = Symbol.for(marker8);
|
|
315
339
|
var forbiddenParamSchema = lazySchema2(
|
|
316
340
|
() => zodSchema2(
|
|
317
|
-
|
|
318
|
-
ruleId:
|
|
341
|
+
z.object({
|
|
342
|
+
ruleId: z.string()
|
|
319
343
|
})
|
|
320
344
|
)
|
|
321
345
|
);
|
|
@@ -474,14 +498,14 @@ async function createGatewayErrorFromResponse({
|
|
|
474
498
|
}
|
|
475
499
|
var gatewayErrorResponseSchema = lazySchema3(
|
|
476
500
|
() => zodSchema3(
|
|
477
|
-
|
|
478
|
-
error:
|
|
479
|
-
message:
|
|
480
|
-
type:
|
|
481
|
-
param:
|
|
482
|
-
code:
|
|
501
|
+
z.object({
|
|
502
|
+
error: z.object({
|
|
503
|
+
message: z.string(),
|
|
504
|
+
type: z.string().nullish(),
|
|
505
|
+
param: z.unknown().nullish(),
|
|
506
|
+
code: z.union([z.string(), z.number()]).nullish()
|
|
483
507
|
}),
|
|
484
|
-
generationId:
|
|
508
|
+
generationId: z.string().nullish()
|
|
485
509
|
})
|
|
486
510
|
)
|
|
487
511
|
);
|
|
@@ -600,7 +624,6 @@ var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
|
|
|
600
624
|
var VERCEL_AI_GATEWAY_TEAM_HEADER = "x-vercel-ai-gateway-team";
|
|
601
625
|
|
|
602
626
|
// src/errors/parse-auth-method.ts
|
|
603
|
-
import { z as z4 } from "zod/v4";
|
|
604
627
|
import {
|
|
605
628
|
lazySchema as lazySchema4,
|
|
606
629
|
safeValidateTypes as safeValidateTypes2,
|
|
@@ -614,7 +637,7 @@ async function parseAuthMethod(headers) {
|
|
|
614
637
|
return result.success ? result.value : void 0;
|
|
615
638
|
}
|
|
616
639
|
var gatewayAuthMethodSchema = lazySchema4(
|
|
617
|
-
() => zodSchema4(
|
|
640
|
+
() => zodSchema4(z.union([z.literal("api-key"), z.literal("oidc")]))
|
|
618
641
|
);
|
|
619
642
|
|
|
620
643
|
// src/gateway-fetch-metadata.ts
|
|
@@ -626,7 +649,6 @@ import {
|
|
|
626
649
|
resolve,
|
|
627
650
|
zodSchema as zodSchema5
|
|
628
651
|
} from "@ai-sdk/provider-utils";
|
|
629
|
-
import { z as z5 } from "zod/v4";
|
|
630
652
|
|
|
631
653
|
// src/gateway-model-entry.ts
|
|
632
654
|
var KNOWN_MODEL_TYPES = [
|
|
@@ -655,7 +677,7 @@ var GatewayFetchMetadata = class {
|
|
|
655
677
|
gatewayAvailableModelsResponseSchema
|
|
656
678
|
),
|
|
657
679
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
658
|
-
errorSchema:
|
|
680
|
+
errorSchema: z.any(),
|
|
659
681
|
errorToMessage: (data) => data
|
|
660
682
|
}),
|
|
661
683
|
fetch: this.config.fetch
|
|
@@ -676,7 +698,7 @@ var GatewayFetchMetadata = class {
|
|
|
676
698
|
gatewayCreditsResponseSchema
|
|
677
699
|
),
|
|
678
700
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
679
|
-
errorSchema:
|
|
701
|
+
errorSchema: z.any(),
|
|
680
702
|
errorToMessage: (data) => data
|
|
681
703
|
}),
|
|
682
704
|
fetch: this.config.fetch
|
|
@@ -689,17 +711,17 @@ var GatewayFetchMetadata = class {
|
|
|
689
711
|
};
|
|
690
712
|
var gatewayAvailableModelsResponseSchema = lazySchema5(
|
|
691
713
|
() => zodSchema5(
|
|
692
|
-
|
|
693
|
-
models:
|
|
694
|
-
|
|
695
|
-
id:
|
|
696
|
-
name:
|
|
697
|
-
description:
|
|
698
|
-
pricing:
|
|
699
|
-
input:
|
|
700
|
-
output:
|
|
701
|
-
input_cache_read:
|
|
702
|
-
input_cache_write:
|
|
714
|
+
z.object({
|
|
715
|
+
models: z.array(
|
|
716
|
+
z.object({
|
|
717
|
+
id: z.string(),
|
|
718
|
+
name: z.string(),
|
|
719
|
+
description: z.string().nullish(),
|
|
720
|
+
pricing: z.object({
|
|
721
|
+
input: z.string(),
|
|
722
|
+
output: z.string(),
|
|
723
|
+
input_cache_read: z.string().nullish(),
|
|
724
|
+
input_cache_write: z.string().nullish()
|
|
703
725
|
}).transform(
|
|
704
726
|
({ input, output, input_cache_read, input_cache_write }) => ({
|
|
705
727
|
input,
|
|
@@ -708,12 +730,12 @@ var gatewayAvailableModelsResponseSchema = lazySchema5(
|
|
|
708
730
|
...input_cache_write ? { cacheCreationInputTokens: input_cache_write } : {}
|
|
709
731
|
})
|
|
710
732
|
).nullish(),
|
|
711
|
-
specification:
|
|
712
|
-
specificationVersion:
|
|
713
|
-
provider:
|
|
714
|
-
modelId:
|
|
733
|
+
specification: z.object({
|
|
734
|
+
specificationVersion: z.literal("v4"),
|
|
735
|
+
provider: z.string(),
|
|
736
|
+
modelId: z.string()
|
|
715
737
|
}),
|
|
716
|
-
modelType:
|
|
738
|
+
modelType: z.string().nullish()
|
|
717
739
|
})
|
|
718
740
|
).transform(
|
|
719
741
|
(models) => models.filter(
|
|
@@ -725,9 +747,9 @@ var gatewayAvailableModelsResponseSchema = lazySchema5(
|
|
|
725
747
|
);
|
|
726
748
|
var gatewayCreditsResponseSchema = lazySchema5(
|
|
727
749
|
() => zodSchema5(
|
|
728
|
-
|
|
729
|
-
balance:
|
|
730
|
-
total_used:
|
|
750
|
+
z.object({
|
|
751
|
+
balance: z.string(),
|
|
752
|
+
total_used: z.string()
|
|
731
753
|
}).transform(({ balance, total_used }) => ({
|
|
732
754
|
balance,
|
|
733
755
|
totalUsed: total_used
|
|
@@ -744,7 +766,6 @@ import {
|
|
|
744
766
|
resolve as resolve2,
|
|
745
767
|
zodSchema as zodSchema6
|
|
746
768
|
} from "@ai-sdk/provider-utils";
|
|
747
|
-
import { z as z6 } from "zod/v4";
|
|
748
769
|
var GatewaySpendReport = class {
|
|
749
770
|
constructor(config) {
|
|
750
771
|
this.config = config;
|
|
@@ -784,7 +805,7 @@ var GatewaySpendReport = class {
|
|
|
784
805
|
gatewaySpendReportResponseSchema
|
|
785
806
|
),
|
|
786
807
|
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
787
|
-
errorSchema:
|
|
808
|
+
errorSchema: z.any(),
|
|
788
809
|
errorToMessage: (data) => data
|
|
789
810
|
}),
|
|
790
811
|
fetch: this.config.fetch
|
|
@@ -797,24 +818,24 @@ var GatewaySpendReport = class {
|
|
|
797
818
|
};
|
|
798
819
|
var gatewaySpendReportResponseSchema = lazySchema6(
|
|
799
820
|
() => zodSchema6(
|
|
800
|
-
|
|
801
|
-
results:
|
|
802
|
-
|
|
803
|
-
day:
|
|
804
|
-
hour:
|
|
805
|
-
user:
|
|
806
|
-
model:
|
|
807
|
-
tag:
|
|
808
|
-
provider:
|
|
809
|
-
credential_type:
|
|
810
|
-
total_cost:
|
|
811
|
-
market_cost:
|
|
812
|
-
input_tokens:
|
|
813
|
-
output_tokens:
|
|
814
|
-
cached_input_tokens:
|
|
815
|
-
cache_creation_input_tokens:
|
|
816
|
-
reasoning_tokens:
|
|
817
|
-
request_count:
|
|
821
|
+
z.object({
|
|
822
|
+
results: z.array(
|
|
823
|
+
z.object({
|
|
824
|
+
day: z.string().optional(),
|
|
825
|
+
hour: z.string().optional(),
|
|
826
|
+
user: z.string().optional(),
|
|
827
|
+
model: z.string().optional(),
|
|
828
|
+
tag: z.string().optional(),
|
|
829
|
+
provider: z.string().optional(),
|
|
830
|
+
credential_type: z.enum(["byok", "system"]).optional(),
|
|
831
|
+
total_cost: z.number(),
|
|
832
|
+
market_cost: z.number().optional(),
|
|
833
|
+
input_tokens: z.number().optional(),
|
|
834
|
+
output_tokens: z.number().optional(),
|
|
835
|
+
cached_input_tokens: z.number().optional(),
|
|
836
|
+
cache_creation_input_tokens: z.number().optional(),
|
|
837
|
+
reasoning_tokens: z.number().optional(),
|
|
838
|
+
request_count: z.number().optional()
|
|
818
839
|
}).transform(
|
|
819
840
|
({
|
|
820
841
|
credential_type,
|
|
@@ -854,7 +875,6 @@ import {
|
|
|
854
875
|
resolve as resolve3,
|
|
855
876
|
zodSchema as zodSchema7
|
|
856
877
|
} from "@ai-sdk/provider-utils";
|
|
857
|
-
import { z as z7 } from "zod/v4";
|
|
858
878
|
var GatewayGenerationInfoFetcher = class {
|
|
859
879
|
constructor(config) {
|
|
860
880
|
this.config = config;
|
|
@@ -870,7 +890,7 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
870
890
|
gatewayGenerationInfoResponseSchema
|
|
871
891
|
),
|
|
872
892
|
failedResponseHandler: createJsonErrorResponseHandler3({
|
|
873
|
-
errorSchema:
|
|
893
|
+
errorSchema: z.any(),
|
|
874
894
|
errorToMessage: (data) => data
|
|
875
895
|
}),
|
|
876
896
|
fetch: this.config.fetch
|
|
@@ -883,26 +903,26 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
883
903
|
};
|
|
884
904
|
var gatewayGenerationInfoResponseSchema = lazySchema7(
|
|
885
905
|
() => zodSchema7(
|
|
886
|
-
|
|
887
|
-
data:
|
|
888
|
-
id:
|
|
889
|
-
total_cost:
|
|
890
|
-
upstream_inference_cost:
|
|
891
|
-
usage:
|
|
892
|
-
created_at:
|
|
893
|
-
model:
|
|
894
|
-
is_byok:
|
|
895
|
-
provider_name:
|
|
896
|
-
streamed:
|
|
897
|
-
finish_reason:
|
|
898
|
-
latency:
|
|
899
|
-
generation_time:
|
|
900
|
-
native_tokens_prompt:
|
|
901
|
-
native_tokens_completion:
|
|
902
|
-
native_tokens_reasoning:
|
|
903
|
-
native_tokens_cached:
|
|
904
|
-
native_tokens_cache_creation:
|
|
905
|
-
billable_web_search_calls:
|
|
906
|
+
z.object({
|
|
907
|
+
data: z.object({
|
|
908
|
+
id: z.string(),
|
|
909
|
+
total_cost: z.number(),
|
|
910
|
+
upstream_inference_cost: z.number(),
|
|
911
|
+
usage: z.number(),
|
|
912
|
+
created_at: z.string(),
|
|
913
|
+
model: z.string(),
|
|
914
|
+
is_byok: z.boolean(),
|
|
915
|
+
provider_name: z.string(),
|
|
916
|
+
streamed: z.boolean(),
|
|
917
|
+
finish_reason: z.string(),
|
|
918
|
+
latency: z.number(),
|
|
919
|
+
generation_time: z.number(),
|
|
920
|
+
native_tokens_prompt: z.number(),
|
|
921
|
+
native_tokens_completion: z.number(),
|
|
922
|
+
native_tokens_reasoning: z.number(),
|
|
923
|
+
native_tokens_cached: z.number(),
|
|
924
|
+
native_tokens_cache_creation: z.number(),
|
|
925
|
+
billable_web_search_calls: z.number()
|
|
906
926
|
}).transform(
|
|
907
927
|
({
|
|
908
928
|
total_cost,
|
|
@@ -952,7 +972,6 @@ import {
|
|
|
952
972
|
WORKFLOW_SERIALIZE,
|
|
953
973
|
WORKFLOW_DESERIALIZE
|
|
954
974
|
} from "@ai-sdk/provider-utils";
|
|
955
|
-
import { z as z8 } from "zod/v4";
|
|
956
975
|
var GatewayLanguageModel = class _GatewayLanguageModel {
|
|
957
976
|
constructor(modelId, config) {
|
|
958
977
|
this.modelId = modelId;
|
|
@@ -997,9 +1016,9 @@ var GatewayLanguageModel = class _GatewayLanguageModel {
|
|
|
997
1016
|
await resolve4(this.config.o11yHeaders)
|
|
998
1017
|
),
|
|
999
1018
|
body: args,
|
|
1000
|
-
successfulResponseHandler: createJsonResponseHandler4(
|
|
1019
|
+
successfulResponseHandler: createJsonResponseHandler4(z.any()),
|
|
1001
1020
|
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
1002
|
-
errorSchema:
|
|
1021
|
+
errorSchema: z.any(),
|
|
1003
1022
|
errorToMessage: (data) => data
|
|
1004
1023
|
}),
|
|
1005
1024
|
...abortSignal && { abortSignal },
|
|
@@ -1032,9 +1051,9 @@ var GatewayLanguageModel = class _GatewayLanguageModel {
|
|
|
1032
1051
|
await resolve4(this.config.o11yHeaders)
|
|
1033
1052
|
),
|
|
1034
1053
|
body: args,
|
|
1035
|
-
successfulResponseHandler: createEventSourceResponseHandler(
|
|
1054
|
+
successfulResponseHandler: createEventSourceResponseHandler(z.any()),
|
|
1036
1055
|
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
1037
|
-
errorSchema:
|
|
1056
|
+
errorSchema: z.any(),
|
|
1038
1057
|
errorToMessage: (data) => data
|
|
1039
1058
|
}),
|
|
1040
1059
|
...abortSignal && { abortSignal },
|
|
@@ -1134,7 +1153,6 @@ import {
|
|
|
1134
1153
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2,
|
|
1135
1154
|
zodSchema as zodSchema8
|
|
1136
1155
|
} from "@ai-sdk/provider-utils";
|
|
1137
|
-
import { z as z9 } from "zod/v4";
|
|
1138
1156
|
var GatewayEmbeddingModel = class _GatewayEmbeddingModel {
|
|
1139
1157
|
constructor(modelId, config) {
|
|
1140
1158
|
this.modelId = modelId;
|
|
@@ -1184,7 +1202,7 @@ var GatewayEmbeddingModel = class _GatewayEmbeddingModel {
|
|
|
1184
1202
|
gatewayEmbeddingResponseSchema
|
|
1185
1203
|
),
|
|
1186
1204
|
failedResponseHandler: createJsonErrorResponseHandler5({
|
|
1187
|
-
errorSchema:
|
|
1205
|
+
errorSchema: z.any(),
|
|
1188
1206
|
errorToMessage: (data) => data
|
|
1189
1207
|
}),
|
|
1190
1208
|
...abortSignal && { abortSignal },
|
|
@@ -1214,34 +1232,34 @@ var GatewayEmbeddingModel = class _GatewayEmbeddingModel {
|
|
|
1214
1232
|
};
|
|
1215
1233
|
}
|
|
1216
1234
|
};
|
|
1217
|
-
var gatewayEmbeddingWarningSchema =
|
|
1218
|
-
|
|
1219
|
-
type:
|
|
1220
|
-
feature:
|
|
1221
|
-
details:
|
|
1235
|
+
var gatewayEmbeddingWarningSchema = z.discriminatedUnion("type", [
|
|
1236
|
+
z.object({
|
|
1237
|
+
type: z.literal("unsupported"),
|
|
1238
|
+
feature: z.string(),
|
|
1239
|
+
details: z.string().optional()
|
|
1222
1240
|
}),
|
|
1223
|
-
|
|
1224
|
-
type:
|
|
1225
|
-
feature:
|
|
1226
|
-
details:
|
|
1241
|
+
z.object({
|
|
1242
|
+
type: z.literal("compatibility"),
|
|
1243
|
+
feature: z.string(),
|
|
1244
|
+
details: z.string().optional()
|
|
1227
1245
|
}),
|
|
1228
|
-
|
|
1229
|
-
type:
|
|
1230
|
-
setting:
|
|
1231
|
-
message:
|
|
1246
|
+
z.object({
|
|
1247
|
+
type: z.literal("deprecated"),
|
|
1248
|
+
setting: z.string(),
|
|
1249
|
+
message: z.string()
|
|
1232
1250
|
}),
|
|
1233
|
-
|
|
1234
|
-
type:
|
|
1235
|
-
message:
|
|
1251
|
+
z.object({
|
|
1252
|
+
type: z.literal("other"),
|
|
1253
|
+
message: z.string()
|
|
1236
1254
|
})
|
|
1237
1255
|
]);
|
|
1238
1256
|
var gatewayEmbeddingResponseSchema = lazySchema8(
|
|
1239
1257
|
() => zodSchema8(
|
|
1240
|
-
|
|
1241
|
-
embeddings:
|
|
1242
|
-
usage:
|
|
1243
|
-
warnings:
|
|
1244
|
-
providerMetadata:
|
|
1258
|
+
z.object({
|
|
1259
|
+
embeddings: z.array(z.array(z.number())),
|
|
1260
|
+
usage: z.object({ tokens: z.number() }).nullish(),
|
|
1261
|
+
warnings: z.array(gatewayEmbeddingWarningSchema).optional(),
|
|
1262
|
+
providerMetadata: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
1245
1263
|
})
|
|
1246
1264
|
)
|
|
1247
1265
|
);
|
|
@@ -1258,7 +1276,6 @@ import {
|
|
|
1258
1276
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3,
|
|
1259
1277
|
WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3
|
|
1260
1278
|
} from "@ai-sdk/provider-utils";
|
|
1261
|
-
import { z as z10 } from "zod/v4";
|
|
1262
1279
|
var GatewayImageModel = class _GatewayImageModel {
|
|
1263
1280
|
constructor(modelId, config) {
|
|
1264
1281
|
this.modelId = modelId;
|
|
@@ -1318,7 +1335,7 @@ var GatewayImageModel = class _GatewayImageModel {
|
|
|
1318
1335
|
gatewayImageResponseSchema
|
|
1319
1336
|
),
|
|
1320
1337
|
failedResponseHandler: createJsonErrorResponseHandler6({
|
|
1321
|
-
errorSchema:
|
|
1338
|
+
errorSchema: z.any(),
|
|
1322
1339
|
errorToMessage: (data) => data
|
|
1323
1340
|
}),
|
|
1324
1341
|
...abortSignal && { abortSignal },
|
|
@@ -1368,40 +1385,40 @@ function maybeEncodeImageFile(file) {
|
|
|
1368
1385
|
}
|
|
1369
1386
|
return file;
|
|
1370
1387
|
}
|
|
1371
|
-
var providerMetadataEntrySchema =
|
|
1372
|
-
images:
|
|
1373
|
-
}).catchall(
|
|
1374
|
-
var gatewayImageWarningSchema =
|
|
1375
|
-
|
|
1376
|
-
type:
|
|
1377
|
-
feature:
|
|
1378
|
-
details:
|
|
1388
|
+
var providerMetadataEntrySchema = z.object({
|
|
1389
|
+
images: z.array(z.unknown()).optional()
|
|
1390
|
+
}).catchall(z.unknown());
|
|
1391
|
+
var gatewayImageWarningSchema = z.discriminatedUnion("type", [
|
|
1392
|
+
z.object({
|
|
1393
|
+
type: z.literal("unsupported"),
|
|
1394
|
+
feature: z.string(),
|
|
1395
|
+
details: z.string().optional()
|
|
1379
1396
|
}),
|
|
1380
|
-
|
|
1381
|
-
type:
|
|
1382
|
-
feature:
|
|
1383
|
-
details:
|
|
1397
|
+
z.object({
|
|
1398
|
+
type: z.literal("compatibility"),
|
|
1399
|
+
feature: z.string(),
|
|
1400
|
+
details: z.string().optional()
|
|
1384
1401
|
}),
|
|
1385
|
-
|
|
1386
|
-
type:
|
|
1387
|
-
setting:
|
|
1388
|
-
message:
|
|
1402
|
+
z.object({
|
|
1403
|
+
type: z.literal("deprecated"),
|
|
1404
|
+
setting: z.string(),
|
|
1405
|
+
message: z.string()
|
|
1389
1406
|
}),
|
|
1390
|
-
|
|
1391
|
-
type:
|
|
1392
|
-
message:
|
|
1407
|
+
z.object({
|
|
1408
|
+
type: z.literal("other"),
|
|
1409
|
+
message: z.string()
|
|
1393
1410
|
})
|
|
1394
1411
|
]);
|
|
1395
|
-
var gatewayImageUsageSchema =
|
|
1396
|
-
inputTokens:
|
|
1397
|
-
outputTokens:
|
|
1398
|
-
totalTokens:
|
|
1412
|
+
var gatewayImageUsageSchema = z.object({
|
|
1413
|
+
inputTokens: z.number().nullish(),
|
|
1414
|
+
outputTokens: z.number().nullish(),
|
|
1415
|
+
totalTokens: z.number().nullish()
|
|
1399
1416
|
});
|
|
1400
|
-
var gatewayImageResponseSchema =
|
|
1401
|
-
images:
|
|
1417
|
+
var gatewayImageResponseSchema = z.object({
|
|
1418
|
+
images: z.array(z.string()),
|
|
1402
1419
|
// Always base64 strings over the wire
|
|
1403
|
-
warnings:
|
|
1404
|
-
providerMetadata:
|
|
1420
|
+
warnings: z.array(gatewayImageWarningSchema).optional(),
|
|
1421
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema).optional(),
|
|
1405
1422
|
usage: gatewayImageUsageSchema.optional()
|
|
1406
1423
|
});
|
|
1407
1424
|
|
|
@@ -1418,7 +1435,6 @@ import {
|
|
|
1418
1435
|
postJsonToApi as postJsonToApi4,
|
|
1419
1436
|
resolve as resolve7
|
|
1420
1437
|
} from "@ai-sdk/provider-utils";
|
|
1421
|
-
import { z as z11 } from "zod/v4";
|
|
1422
1438
|
var GatewayVideoModel = class {
|
|
1423
1439
|
constructor(modelId, config) {
|
|
1424
1440
|
this.modelId = modelId;
|
|
@@ -1510,7 +1526,7 @@ var GatewayVideoModel = class {
|
|
|
1510
1526
|
};
|
|
1511
1527
|
},
|
|
1512
1528
|
failedResponseHandler: createJsonErrorResponseHandler7({
|
|
1513
|
-
errorSchema:
|
|
1529
|
+
errorSchema: z.any(),
|
|
1514
1530
|
errorToMessage: (data) => data
|
|
1515
1531
|
}),
|
|
1516
1532
|
...abortSignal && { abortSignal },
|
|
@@ -1565,7 +1581,7 @@ var GatewayVideoModel = class {
|
|
|
1565
1581
|
gatewayVideoStartResponseSchema
|
|
1566
1582
|
),
|
|
1567
1583
|
failedResponseHandler: createJsonErrorResponseHandler7({
|
|
1568
|
-
errorSchema:
|
|
1584
|
+
errorSchema: z.any(),
|
|
1569
1585
|
errorToMessage: (data) => data
|
|
1570
1586
|
}),
|
|
1571
1587
|
...abortSignal && { abortSignal },
|
|
@@ -1609,7 +1625,7 @@ var GatewayVideoModel = class {
|
|
|
1609
1625
|
gatewayVideoStatusResponseSchema
|
|
1610
1626
|
),
|
|
1611
1627
|
failedResponseHandler: createJsonErrorResponseHandler7({
|
|
1612
|
-
errorSchema:
|
|
1628
|
+
errorSchema: z.any(),
|
|
1613
1629
|
errorToMessage: (data) => data
|
|
1614
1630
|
}),
|
|
1615
1631
|
...abortSignal && { abortSignal },
|
|
@@ -1721,82 +1737,82 @@ function maybeEncodeVideoFile(file) {
|
|
|
1721
1737
|
}
|
|
1722
1738
|
return file;
|
|
1723
1739
|
}
|
|
1724
|
-
var providerMetadataEntrySchema2 =
|
|
1725
|
-
videos:
|
|
1726
|
-
}).catchall(
|
|
1727
|
-
var gatewayVideoDataSchema =
|
|
1728
|
-
|
|
1729
|
-
type:
|
|
1730
|
-
url:
|
|
1731
|
-
mediaType:
|
|
1740
|
+
var providerMetadataEntrySchema2 = z.object({
|
|
1741
|
+
videos: z.array(z.unknown()).optional()
|
|
1742
|
+
}).catchall(z.unknown());
|
|
1743
|
+
var gatewayVideoDataSchema = z.union([
|
|
1744
|
+
z.object({
|
|
1745
|
+
type: z.literal("url"),
|
|
1746
|
+
url: z.string(),
|
|
1747
|
+
mediaType: z.string()
|
|
1732
1748
|
}),
|
|
1733
|
-
|
|
1734
|
-
type:
|
|
1735
|
-
data:
|
|
1736
|
-
mediaType:
|
|
1749
|
+
z.object({
|
|
1750
|
+
type: z.literal("base64"),
|
|
1751
|
+
data: z.string(),
|
|
1752
|
+
mediaType: z.string()
|
|
1737
1753
|
})
|
|
1738
1754
|
]);
|
|
1739
|
-
var gatewayVideoWarningSchema =
|
|
1740
|
-
|
|
1741
|
-
type:
|
|
1742
|
-
feature:
|
|
1743
|
-
details:
|
|
1755
|
+
var gatewayVideoWarningSchema = z.discriminatedUnion("type", [
|
|
1756
|
+
z.object({
|
|
1757
|
+
type: z.literal("unsupported"),
|
|
1758
|
+
feature: z.string(),
|
|
1759
|
+
details: z.string().optional()
|
|
1744
1760
|
}),
|
|
1745
|
-
|
|
1746
|
-
type:
|
|
1747
|
-
feature:
|
|
1748
|
-
details:
|
|
1761
|
+
z.object({
|
|
1762
|
+
type: z.literal("compatibility"),
|
|
1763
|
+
feature: z.string(),
|
|
1764
|
+
details: z.string().optional()
|
|
1749
1765
|
}),
|
|
1750
|
-
|
|
1751
|
-
type:
|
|
1752
|
-
setting:
|
|
1753
|
-
message:
|
|
1766
|
+
z.object({
|
|
1767
|
+
type: z.literal("deprecated"),
|
|
1768
|
+
setting: z.string(),
|
|
1769
|
+
message: z.string()
|
|
1754
1770
|
}),
|
|
1755
|
-
|
|
1756
|
-
type:
|
|
1757
|
-
message:
|
|
1771
|
+
z.object({
|
|
1772
|
+
type: z.literal("other"),
|
|
1773
|
+
message: z.string()
|
|
1758
1774
|
})
|
|
1759
1775
|
]);
|
|
1760
|
-
var gatewayVideoEventSchema =
|
|
1761
|
-
|
|
1762
|
-
type:
|
|
1763
|
-
videos:
|
|
1764
|
-
warnings:
|
|
1765
|
-
providerMetadata:
|
|
1776
|
+
var gatewayVideoEventSchema = z.discriminatedUnion("type", [
|
|
1777
|
+
z.object({
|
|
1778
|
+
type: z.literal("result"),
|
|
1779
|
+
videos: z.array(gatewayVideoDataSchema),
|
|
1780
|
+
warnings: z.array(gatewayVideoWarningSchema).optional(),
|
|
1781
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).optional()
|
|
1766
1782
|
}),
|
|
1767
|
-
|
|
1768
|
-
type:
|
|
1769
|
-
message:
|
|
1770
|
-
errorType:
|
|
1771
|
-
statusCode:
|
|
1772
|
-
param:
|
|
1783
|
+
z.object({
|
|
1784
|
+
type: z.literal("error"),
|
|
1785
|
+
message: z.string(),
|
|
1786
|
+
errorType: z.string(),
|
|
1787
|
+
statusCode: z.number(),
|
|
1788
|
+
param: z.unknown().nullable()
|
|
1773
1789
|
})
|
|
1774
1790
|
]);
|
|
1775
|
-
var gatewayVideoStartResponseSchema =
|
|
1776
|
-
operation:
|
|
1777
|
-
warnings:
|
|
1778
|
-
providerMetadata:
|
|
1791
|
+
var gatewayVideoStartResponseSchema = z.object({
|
|
1792
|
+
operation: z.unknown(),
|
|
1793
|
+
warnings: z.array(gatewayVideoWarningSchema).nullish(),
|
|
1794
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).nullish()
|
|
1779
1795
|
});
|
|
1780
|
-
var gatewayVideoStatusResponseSchema =
|
|
1781
|
-
|
|
1782
|
-
status:
|
|
1783
|
-
warnings:
|
|
1784
|
-
providerMetadata:
|
|
1796
|
+
var gatewayVideoStatusResponseSchema = z.discriminatedUnion("status", [
|
|
1797
|
+
z.object({
|
|
1798
|
+
status: z.literal("pending"),
|
|
1799
|
+
warnings: z.array(gatewayVideoWarningSchema).nullish(),
|
|
1800
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).nullish()
|
|
1785
1801
|
}),
|
|
1786
|
-
|
|
1787
|
-
status:
|
|
1788
|
-
videos:
|
|
1789
|
-
warnings:
|
|
1790
|
-
providerMetadata:
|
|
1802
|
+
z.object({
|
|
1803
|
+
status: z.literal("completed"),
|
|
1804
|
+
videos: z.array(gatewayVideoDataSchema),
|
|
1805
|
+
warnings: z.array(gatewayVideoWarningSchema).nullish(),
|
|
1806
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).nullish()
|
|
1791
1807
|
}),
|
|
1792
|
-
|
|
1793
|
-
status:
|
|
1794
|
-
error:
|
|
1795
|
-
providerMetadata:
|
|
1808
|
+
z.object({
|
|
1809
|
+
status: z.literal("error"),
|
|
1810
|
+
error: z.string(),
|
|
1811
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).nullish()
|
|
1796
1812
|
}),
|
|
1797
|
-
|
|
1798
|
-
status:
|
|
1799
|
-
providerMetadata:
|
|
1813
|
+
z.object({
|
|
1814
|
+
status: z.literal("cancelled"),
|
|
1815
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema2).nullish()
|
|
1800
1816
|
})
|
|
1801
1817
|
]);
|
|
1802
1818
|
|
|
@@ -1810,7 +1826,6 @@ import {
|
|
|
1810
1826
|
resolve as resolve8,
|
|
1811
1827
|
zodSchema as zodSchema9
|
|
1812
1828
|
} from "@ai-sdk/provider-utils";
|
|
1813
|
-
import { z as z12 } from "zod/v4";
|
|
1814
1829
|
var GatewayRerankingModel = class {
|
|
1815
1830
|
constructor(modelId, config) {
|
|
1816
1831
|
this.modelId = modelId;
|
|
@@ -1853,7 +1868,7 @@ var GatewayRerankingModel = class {
|
|
|
1853
1868
|
gatewayRerankingResponseSchema
|
|
1854
1869
|
),
|
|
1855
1870
|
failedResponseHandler: createJsonErrorResponseHandler8({
|
|
1856
|
-
errorSchema:
|
|
1871
|
+
errorSchema: z.any(),
|
|
1857
1872
|
errorToMessage: (data) => data
|
|
1858
1873
|
}),
|
|
1859
1874
|
...abortSignal && { abortSignal },
|
|
@@ -1882,38 +1897,38 @@ var GatewayRerankingModel = class {
|
|
|
1882
1897
|
};
|
|
1883
1898
|
}
|
|
1884
1899
|
};
|
|
1885
|
-
var gatewayRerankingWarningSchema =
|
|
1886
|
-
|
|
1887
|
-
type:
|
|
1888
|
-
feature:
|
|
1889
|
-
details:
|
|
1900
|
+
var gatewayRerankingWarningSchema = z.discriminatedUnion("type", [
|
|
1901
|
+
z.object({
|
|
1902
|
+
type: z.literal("unsupported"),
|
|
1903
|
+
feature: z.string(),
|
|
1904
|
+
details: z.string().optional()
|
|
1890
1905
|
}),
|
|
1891
|
-
|
|
1892
|
-
type:
|
|
1893
|
-
feature:
|
|
1894
|
-
details:
|
|
1906
|
+
z.object({
|
|
1907
|
+
type: z.literal("compatibility"),
|
|
1908
|
+
feature: z.string(),
|
|
1909
|
+
details: z.string().optional()
|
|
1895
1910
|
}),
|
|
1896
|
-
|
|
1897
|
-
type:
|
|
1898
|
-
setting:
|
|
1899
|
-
message:
|
|
1911
|
+
z.object({
|
|
1912
|
+
type: z.literal("deprecated"),
|
|
1913
|
+
setting: z.string(),
|
|
1914
|
+
message: z.string()
|
|
1900
1915
|
}),
|
|
1901
|
-
|
|
1902
|
-
type:
|
|
1903
|
-
message:
|
|
1916
|
+
z.object({
|
|
1917
|
+
type: z.literal("other"),
|
|
1918
|
+
message: z.string()
|
|
1904
1919
|
})
|
|
1905
1920
|
]);
|
|
1906
1921
|
var gatewayRerankingResponseSchema = lazySchema9(
|
|
1907
1922
|
() => zodSchema9(
|
|
1908
|
-
|
|
1909
|
-
ranking:
|
|
1910
|
-
|
|
1911
|
-
index:
|
|
1912
|
-
relevanceScore:
|
|
1923
|
+
z.object({
|
|
1924
|
+
ranking: z.array(
|
|
1925
|
+
z.object({
|
|
1926
|
+
index: z.number(),
|
|
1927
|
+
relevanceScore: z.number()
|
|
1913
1928
|
})
|
|
1914
1929
|
),
|
|
1915
|
-
warnings:
|
|
1916
|
-
providerMetadata:
|
|
1930
|
+
warnings: z.array(gatewayRerankingWarningSchema).optional(),
|
|
1931
|
+
providerMetadata: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
1917
1932
|
})
|
|
1918
1933
|
)
|
|
1919
1934
|
);
|
|
@@ -1926,7 +1941,6 @@ import {
|
|
|
1926
1941
|
postJsonToApi as postJsonToApi6,
|
|
1927
1942
|
resolve as resolve9
|
|
1928
1943
|
} from "@ai-sdk/provider-utils";
|
|
1929
|
-
import { z as z13 } from "zod/v4";
|
|
1930
1944
|
var GatewaySpeechModel = class {
|
|
1931
1945
|
constructor(modelId, config) {
|
|
1932
1946
|
this.modelId = modelId;
|
|
@@ -1975,7 +1989,7 @@ var GatewaySpeechModel = class {
|
|
|
1975
1989
|
gatewaySpeechResponseSchema
|
|
1976
1990
|
),
|
|
1977
1991
|
failedResponseHandler: createJsonErrorResponseHandler9({
|
|
1978
|
-
errorSchema:
|
|
1992
|
+
errorSchema: z.any(),
|
|
1979
1993
|
errorToMessage: (data) => data
|
|
1980
1994
|
}),
|
|
1981
1995
|
...abortSignal && { abortSignal },
|
|
@@ -2009,32 +2023,32 @@ var GatewaySpeechModel = class {
|
|
|
2009
2023
|
};
|
|
2010
2024
|
}
|
|
2011
2025
|
};
|
|
2012
|
-
var providerMetadataEntrySchema3 =
|
|
2013
|
-
var gatewaySpeechWarningSchema =
|
|
2014
|
-
|
|
2015
|
-
type:
|
|
2016
|
-
feature:
|
|
2017
|
-
details:
|
|
2026
|
+
var providerMetadataEntrySchema3 = z.object({}).catchall(z.unknown());
|
|
2027
|
+
var gatewaySpeechWarningSchema = z.discriminatedUnion("type", [
|
|
2028
|
+
z.object({
|
|
2029
|
+
type: z.literal("unsupported"),
|
|
2030
|
+
feature: z.string(),
|
|
2031
|
+
details: z.string().optional()
|
|
2018
2032
|
}),
|
|
2019
|
-
|
|
2020
|
-
type:
|
|
2021
|
-
feature:
|
|
2022
|
-
details:
|
|
2033
|
+
z.object({
|
|
2034
|
+
type: z.literal("compatibility"),
|
|
2035
|
+
feature: z.string(),
|
|
2036
|
+
details: z.string().optional()
|
|
2023
2037
|
}),
|
|
2024
|
-
|
|
2025
|
-
type:
|
|
2026
|
-
setting:
|
|
2027
|
-
message:
|
|
2038
|
+
z.object({
|
|
2039
|
+
type: z.literal("deprecated"),
|
|
2040
|
+
setting: z.string(),
|
|
2041
|
+
message: z.string()
|
|
2028
2042
|
}),
|
|
2029
|
-
|
|
2030
|
-
type:
|
|
2031
|
-
message:
|
|
2043
|
+
z.object({
|
|
2044
|
+
type: z.literal("other"),
|
|
2045
|
+
message: z.string()
|
|
2032
2046
|
})
|
|
2033
2047
|
]);
|
|
2034
|
-
var gatewaySpeechResponseSchema =
|
|
2035
|
-
audio:
|
|
2036
|
-
warnings:
|
|
2037
|
-
providerMetadata:
|
|
2048
|
+
var gatewaySpeechResponseSchema = z.object({
|
|
2049
|
+
audio: z.string(),
|
|
2050
|
+
warnings: z.array(gatewaySpeechWarningSchema).optional(),
|
|
2051
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema3).optional()
|
|
2038
2052
|
});
|
|
2039
2053
|
|
|
2040
2054
|
// src/gateway-transcription-model.ts
|
|
@@ -2056,7 +2070,6 @@ import {
|
|
|
2056
2070
|
waitForWebSocketBufferDrain,
|
|
2057
2071
|
EXPERIMENTAL_TRANSCRIPTION_STREAM_START_FRAME_TYPE as TRANSCRIPTION_STREAM_START_FRAME_TYPE
|
|
2058
2072
|
} from "@ai-sdk/provider-utils";
|
|
2059
|
-
import { z as z14 } from "zod/v4";
|
|
2060
2073
|
var GatewayTranscriptionModel = class {
|
|
2061
2074
|
constructor(modelId, config) {
|
|
2062
2075
|
this.modelId = modelId;
|
|
@@ -2097,7 +2110,7 @@ var GatewayTranscriptionModel = class {
|
|
|
2097
2110
|
gatewayTranscriptionResponseSchema
|
|
2098
2111
|
),
|
|
2099
2112
|
failedResponseHandler: createJsonErrorResponseHandler10({
|
|
2100
|
-
errorSchema:
|
|
2113
|
+
errorSchema: z.any(),
|
|
2101
2114
|
errorToMessage: (data) => data
|
|
2102
2115
|
}),
|
|
2103
2116
|
...abortSignal && { abortSignal },
|
|
@@ -2326,41 +2339,41 @@ function createGatewayTranscriptionStream({
|
|
|
2326
2339
|
}
|
|
2327
2340
|
});
|
|
2328
2341
|
}
|
|
2329
|
-
var providerMetadataEntrySchema4 =
|
|
2330
|
-
var gatewayTranscriptionWarningSchema =
|
|
2331
|
-
|
|
2332
|
-
type:
|
|
2333
|
-
feature:
|
|
2334
|
-
details:
|
|
2342
|
+
var providerMetadataEntrySchema4 = z.object({}).catchall(z.unknown());
|
|
2343
|
+
var gatewayTranscriptionWarningSchema = z.discriminatedUnion("type", [
|
|
2344
|
+
z.object({
|
|
2345
|
+
type: z.literal("unsupported"),
|
|
2346
|
+
feature: z.string(),
|
|
2347
|
+
details: z.string().optional()
|
|
2335
2348
|
}),
|
|
2336
|
-
|
|
2337
|
-
type:
|
|
2338
|
-
feature:
|
|
2339
|
-
details:
|
|
2349
|
+
z.object({
|
|
2350
|
+
type: z.literal("compatibility"),
|
|
2351
|
+
feature: z.string(),
|
|
2352
|
+
details: z.string().optional()
|
|
2340
2353
|
}),
|
|
2341
|
-
|
|
2342
|
-
type:
|
|
2343
|
-
setting:
|
|
2344
|
-
message:
|
|
2354
|
+
z.object({
|
|
2355
|
+
type: z.literal("deprecated"),
|
|
2356
|
+
setting: z.string(),
|
|
2357
|
+
message: z.string()
|
|
2345
2358
|
}),
|
|
2346
|
-
|
|
2347
|
-
type:
|
|
2348
|
-
message:
|
|
2359
|
+
z.object({
|
|
2360
|
+
type: z.literal("other"),
|
|
2361
|
+
message: z.string()
|
|
2349
2362
|
})
|
|
2350
2363
|
]);
|
|
2351
|
-
var gatewayTranscriptionResponseSchema =
|
|
2352
|
-
text:
|
|
2353
|
-
segments:
|
|
2354
|
-
|
|
2355
|
-
text:
|
|
2356
|
-
startSecond:
|
|
2357
|
-
endSecond:
|
|
2364
|
+
var gatewayTranscriptionResponseSchema = z.object({
|
|
2365
|
+
text: z.string(),
|
|
2366
|
+
segments: z.array(
|
|
2367
|
+
z.object({
|
|
2368
|
+
text: z.string(),
|
|
2369
|
+
startSecond: z.number(),
|
|
2370
|
+
endSecond: z.number()
|
|
2358
2371
|
})
|
|
2359
2372
|
).optional(),
|
|
2360
|
-
language:
|
|
2361
|
-
durationInSeconds:
|
|
2362
|
-
warnings:
|
|
2363
|
-
providerMetadata:
|
|
2373
|
+
language: z.string().nullish(),
|
|
2374
|
+
durationInSeconds: z.number().nullish(),
|
|
2375
|
+
warnings: z.array(gatewayTranscriptionWarningSchema).optional(),
|
|
2376
|
+
providerMetadata: z.record(z.string(), providerMetadataEntrySchema4).optional()
|
|
2364
2377
|
});
|
|
2365
2378
|
async function errorControllerWithGatewayError(controller, error, authMethod) {
|
|
2366
2379
|
controller.error(await asGatewayError(error, authMethod));
|
|
@@ -2454,16 +2467,15 @@ import {
|
|
|
2454
2467
|
lazySchema as lazySchema10,
|
|
2455
2468
|
zodSchema as zodSchema10
|
|
2456
2469
|
} from "@ai-sdk/provider-utils";
|
|
2457
|
-
import { z as z15 } from "zod/v4";
|
|
2458
2470
|
var exaSearchInputSchema = lazySchema10(
|
|
2459
2471
|
() => zodSchema10(
|
|
2460
|
-
|
|
2461
|
-
query:
|
|
2462
|
-
type:
|
|
2472
|
+
z.object({
|
|
2473
|
+
query: z.string().describe("Natural-language web search query. This is required."),
|
|
2474
|
+
type: z.enum(["auto", "fast", "instant"]).optional().describe(
|
|
2463
2475
|
"Search method. Use auto for the default balance of speed and quality."
|
|
2464
2476
|
),
|
|
2465
|
-
num_results:
|
|
2466
|
-
category:
|
|
2477
|
+
num_results: z.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
|
|
2478
|
+
category: z.enum([
|
|
2467
2479
|
"company",
|
|
2468
2480
|
"people",
|
|
2469
2481
|
"research paper",
|
|
@@ -2471,20 +2483,20 @@ var exaSearchInputSchema = lazySchema10(
|
|
|
2471
2483
|
"personal site",
|
|
2472
2484
|
"financial report"
|
|
2473
2485
|
]).optional().describe("Optional content category to focus results."),
|
|
2474
|
-
user_location:
|
|
2475
|
-
include_domains:
|
|
2476
|
-
exclude_domains:
|
|
2477
|
-
start_published_date:
|
|
2478
|
-
end_published_date:
|
|
2479
|
-
contents:
|
|
2480
|
-
text:
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
max_characters:
|
|
2484
|
-
include_html_tags:
|
|
2485
|
-
verbosity:
|
|
2486
|
-
include_sections:
|
|
2487
|
-
|
|
2486
|
+
user_location: z.string().optional().describe("Two-letter ISO country code such as 'US'."),
|
|
2487
|
+
include_domains: z.array(z.string()).optional().describe("Only return results from these domains."),
|
|
2488
|
+
exclude_domains: z.array(z.string()).optional().describe("Exclude results from these domains."),
|
|
2489
|
+
start_published_date: z.string().optional().describe("Only return links published after this ISO 8601 date."),
|
|
2490
|
+
end_published_date: z.string().optional().describe("Only return links published before this ISO 8601 date."),
|
|
2491
|
+
contents: z.object({
|
|
2492
|
+
text: z.union([
|
|
2493
|
+
z.boolean(),
|
|
2494
|
+
z.object({
|
|
2495
|
+
max_characters: z.number().optional(),
|
|
2496
|
+
include_html_tags: z.boolean().optional(),
|
|
2497
|
+
verbosity: z.enum(["compact", "standard", "full"]).optional(),
|
|
2498
|
+
include_sections: z.array(
|
|
2499
|
+
z.enum([
|
|
2488
2500
|
"header",
|
|
2489
2501
|
"navigation",
|
|
2490
2502
|
"banner",
|
|
@@ -2494,8 +2506,8 @@ var exaSearchInputSchema = lazySchema10(
|
|
|
2494
2506
|
"metadata"
|
|
2495
2507
|
])
|
|
2496
2508
|
).optional(),
|
|
2497
|
-
exclude_sections:
|
|
2498
|
-
|
|
2509
|
+
exclude_sections: z.array(
|
|
2510
|
+
z.enum([
|
|
2499
2511
|
"header",
|
|
2500
2512
|
"navigation",
|
|
2501
2513
|
"banner",
|
|
@@ -2507,20 +2519,20 @@ var exaSearchInputSchema = lazySchema10(
|
|
|
2507
2519
|
).optional()
|
|
2508
2520
|
})
|
|
2509
2521
|
]).optional(),
|
|
2510
|
-
highlights:
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
query:
|
|
2514
|
-
max_characters:
|
|
2522
|
+
highlights: z.union([
|
|
2523
|
+
z.boolean(),
|
|
2524
|
+
z.object({
|
|
2525
|
+
query: z.string().optional(),
|
|
2526
|
+
max_characters: z.number().optional()
|
|
2515
2527
|
})
|
|
2516
2528
|
]).optional(),
|
|
2517
|
-
max_age_hours:
|
|
2518
|
-
livecrawl_timeout:
|
|
2519
|
-
subpages:
|
|
2520
|
-
subpage_target:
|
|
2521
|
-
extras:
|
|
2522
|
-
links:
|
|
2523
|
-
image_links:
|
|
2529
|
+
max_age_hours: z.number().optional(),
|
|
2530
|
+
livecrawl_timeout: z.number().optional(),
|
|
2531
|
+
subpages: z.number().optional(),
|
|
2532
|
+
subpage_target: z.union([z.string(), z.array(z.string())]).optional(),
|
|
2533
|
+
extras: z.object({
|
|
2534
|
+
links: z.number().optional(),
|
|
2535
|
+
image_links: z.number().optional()
|
|
2524
2536
|
}).optional()
|
|
2525
2537
|
}).optional().describe("Controls extracted page content and freshness.")
|
|
2526
2538
|
})
|
|
@@ -2528,38 +2540,38 @@ var exaSearchInputSchema = lazySchema10(
|
|
|
2528
2540
|
);
|
|
2529
2541
|
var exaSearchOutputSchema = lazySchema10(
|
|
2530
2542
|
() => zodSchema10(
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
requestId:
|
|
2534
|
-
searchType:
|
|
2535
|
-
resolvedSearchType:
|
|
2536
|
-
results:
|
|
2537
|
-
|
|
2538
|
-
title:
|
|
2539
|
-
url:
|
|
2540
|
-
id:
|
|
2541
|
-
publishedDate:
|
|
2542
|
-
author:
|
|
2543
|
-
image:
|
|
2544
|
-
favicon:
|
|
2545
|
-
text:
|
|
2546
|
-
highlights:
|
|
2547
|
-
highlightScores:
|
|
2548
|
-
summary:
|
|
2549
|
-
subpages:
|
|
2550
|
-
extras:
|
|
2551
|
-
links:
|
|
2552
|
-
imageLinks:
|
|
2543
|
+
z.union([
|
|
2544
|
+
z.object({
|
|
2545
|
+
requestId: z.string(),
|
|
2546
|
+
searchType: z.string().optional(),
|
|
2547
|
+
resolvedSearchType: z.string().optional(),
|
|
2548
|
+
results: z.array(
|
|
2549
|
+
z.object({
|
|
2550
|
+
title: z.string(),
|
|
2551
|
+
url: z.string(),
|
|
2552
|
+
id: z.string(),
|
|
2553
|
+
publishedDate: z.string().nullable().optional(),
|
|
2554
|
+
author: z.string().nullable().optional(),
|
|
2555
|
+
image: z.string().nullable().optional(),
|
|
2556
|
+
favicon: z.string().nullable().optional(),
|
|
2557
|
+
text: z.string().optional(),
|
|
2558
|
+
highlights: z.array(z.string()).optional(),
|
|
2559
|
+
highlightScores: z.array(z.number()).optional(),
|
|
2560
|
+
summary: z.string().optional(),
|
|
2561
|
+
subpages: z.array(z.any()).optional(),
|
|
2562
|
+
extras: z.object({
|
|
2563
|
+
links: z.array(z.string()).optional(),
|
|
2564
|
+
imageLinks: z.array(z.string()).optional()
|
|
2553
2565
|
}).optional()
|
|
2554
2566
|
})
|
|
2555
2567
|
),
|
|
2556
|
-
costDollars:
|
|
2557
|
-
total:
|
|
2558
|
-
search:
|
|
2568
|
+
costDollars: z.object({
|
|
2569
|
+
total: z.number().optional(),
|
|
2570
|
+
search: z.record(z.string(), z.number()).optional()
|
|
2559
2571
|
}).optional()
|
|
2560
2572
|
}),
|
|
2561
|
-
|
|
2562
|
-
error:
|
|
2573
|
+
z.object({
|
|
2574
|
+
error: z.enum([
|
|
2563
2575
|
"api_error",
|
|
2564
2576
|
"rate_limit",
|
|
2565
2577
|
"timeout",
|
|
@@ -2568,8 +2580,8 @@ var exaSearchOutputSchema = lazySchema10(
|
|
|
2568
2580
|
"execution_error",
|
|
2569
2581
|
"unknown"
|
|
2570
2582
|
]),
|
|
2571
|
-
statusCode:
|
|
2572
|
-
message:
|
|
2583
|
+
statusCode: z.number().optional(),
|
|
2584
|
+
message: z.string()
|
|
2573
2585
|
})
|
|
2574
2586
|
])
|
|
2575
2587
|
)
|
|
@@ -2587,41 +2599,40 @@ import {
|
|
|
2587
2599
|
lazySchema as lazySchema11,
|
|
2588
2600
|
zodSchema as zodSchema11
|
|
2589
2601
|
} from "@ai-sdk/provider-utils";
|
|
2590
|
-
import { z as z16 } from "zod/v4";
|
|
2591
2602
|
var parallelSearchInputSchema = lazySchema11(
|
|
2592
2603
|
() => zodSchema11(
|
|
2593
|
-
|
|
2594
|
-
objective:
|
|
2604
|
+
z.object({
|
|
2605
|
+
objective: z.string().describe(
|
|
2595
2606
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
2596
2607
|
),
|
|
2597
|
-
search_queries:
|
|
2608
|
+
search_queries: z.array(z.string()).optional().describe(
|
|
2598
2609
|
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
2599
2610
|
),
|
|
2600
|
-
mode:
|
|
2611
|
+
mode: z.enum(["one-shot", "agentic"]).optional().describe(
|
|
2601
2612
|
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
2602
2613
|
),
|
|
2603
|
-
max_results:
|
|
2614
|
+
max_results: z.number().optional().describe(
|
|
2604
2615
|
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
2605
2616
|
),
|
|
2606
|
-
source_policy:
|
|
2607
|
-
include_domains:
|
|
2617
|
+
source_policy: z.object({
|
|
2618
|
+
include_domains: z.array(z.string()).optional().describe(
|
|
2608
2619
|
"Limit results to these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
2609
2620
|
),
|
|
2610
|
-
exclude_domains:
|
|
2621
|
+
exclude_domains: z.array(z.string()).optional().describe(
|
|
2611
2622
|
"Exclude results from these domains. Use plain domain names only \u2014 e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page)."
|
|
2612
2623
|
),
|
|
2613
|
-
after_date:
|
|
2624
|
+
after_date: z.string().optional().describe(
|
|
2614
2625
|
"Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time."
|
|
2615
2626
|
)
|
|
2616
2627
|
}).optional().describe(
|
|
2617
2628
|
"Source policy for controlling which domains to include/exclude and freshness."
|
|
2618
2629
|
),
|
|
2619
|
-
excerpts:
|
|
2620
|
-
max_chars_per_result:
|
|
2621
|
-
max_chars_total:
|
|
2630
|
+
excerpts: z.object({
|
|
2631
|
+
max_chars_per_result: z.number().optional().describe("Maximum characters per result."),
|
|
2632
|
+
max_chars_total: z.number().optional().describe("Maximum total characters across all results.")
|
|
2622
2633
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
2623
|
-
fetch_policy:
|
|
2624
|
-
max_age_seconds:
|
|
2634
|
+
fetch_policy: z.object({
|
|
2635
|
+
max_age_seconds: z.number().optional().describe(
|
|
2625
2636
|
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
2626
2637
|
)
|
|
2627
2638
|
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
@@ -2630,23 +2641,23 @@ var parallelSearchInputSchema = lazySchema11(
|
|
|
2630
2641
|
);
|
|
2631
2642
|
var parallelSearchOutputSchema = lazySchema11(
|
|
2632
2643
|
() => zodSchema11(
|
|
2633
|
-
|
|
2644
|
+
z.union([
|
|
2634
2645
|
// Success response
|
|
2635
|
-
|
|
2636
|
-
searchId:
|
|
2637
|
-
results:
|
|
2638
|
-
|
|
2639
|
-
url:
|
|
2640
|
-
title:
|
|
2641
|
-
excerpt:
|
|
2642
|
-
publishDate:
|
|
2643
|
-
relevanceScore:
|
|
2646
|
+
z.object({
|
|
2647
|
+
searchId: z.string(),
|
|
2648
|
+
results: z.array(
|
|
2649
|
+
z.object({
|
|
2650
|
+
url: z.string(),
|
|
2651
|
+
title: z.string(),
|
|
2652
|
+
excerpt: z.string(),
|
|
2653
|
+
publishDate: z.string().nullable().optional(),
|
|
2654
|
+
relevanceScore: z.number().optional()
|
|
2644
2655
|
})
|
|
2645
2656
|
)
|
|
2646
2657
|
}),
|
|
2647
2658
|
// Error response
|
|
2648
|
-
|
|
2649
|
-
error:
|
|
2659
|
+
z.object({
|
|
2660
|
+
error: z.enum([
|
|
2650
2661
|
"api_error",
|
|
2651
2662
|
"rate_limit",
|
|
2652
2663
|
"timeout",
|
|
@@ -2654,8 +2665,8 @@ var parallelSearchOutputSchema = lazySchema11(
|
|
|
2654
2665
|
"configuration_error",
|
|
2655
2666
|
"unknown"
|
|
2656
2667
|
]),
|
|
2657
|
-
statusCode:
|
|
2658
|
-
message:
|
|
2668
|
+
statusCode: z.number().optional(),
|
|
2669
|
+
message: z.string()
|
|
2659
2670
|
})
|
|
2660
2671
|
])
|
|
2661
2672
|
)
|
|
@@ -2673,44 +2684,43 @@ import {
|
|
|
2673
2684
|
lazySchema as lazySchema12,
|
|
2674
2685
|
zodSchema as zodSchema12
|
|
2675
2686
|
} from "@ai-sdk/provider-utils";
|
|
2676
|
-
import { z as z17 } from "zod/v4";
|
|
2677
2687
|
var perplexitySearchInputSchema = lazySchema12(
|
|
2678
2688
|
() => zodSchema12(
|
|
2679
|
-
|
|
2680
|
-
query:
|
|
2689
|
+
z.object({
|
|
2690
|
+
query: z.union([z.string(), z.array(z.string())]).describe(
|
|
2681
2691
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
2682
2692
|
),
|
|
2683
|
-
max_results:
|
|
2693
|
+
max_results: z.number().optional().describe(
|
|
2684
2694
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
2685
2695
|
),
|
|
2686
|
-
max_tokens_per_page:
|
|
2696
|
+
max_tokens_per_page: z.number().optional().describe(
|
|
2687
2697
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
2688
2698
|
),
|
|
2689
|
-
max_tokens:
|
|
2699
|
+
max_tokens: z.number().optional().describe(
|
|
2690
2700
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
2691
2701
|
),
|
|
2692
|
-
country:
|
|
2702
|
+
country: z.string().optional().describe(
|
|
2693
2703
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
2694
2704
|
),
|
|
2695
|
-
search_domain_filter:
|
|
2705
|
+
search_domain_filter: z.array(z.string()).optional().describe(
|
|
2696
2706
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
2697
2707
|
),
|
|
2698
|
-
search_language_filter:
|
|
2708
|
+
search_language_filter: z.array(z.string()).optional().describe(
|
|
2699
2709
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
2700
2710
|
),
|
|
2701
|
-
search_after_date:
|
|
2711
|
+
search_after_date: z.string().optional().describe(
|
|
2702
2712
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
2703
2713
|
),
|
|
2704
|
-
search_before_date:
|
|
2714
|
+
search_before_date: z.string().optional().describe(
|
|
2705
2715
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
2706
2716
|
),
|
|
2707
|
-
last_updated_after_filter:
|
|
2717
|
+
last_updated_after_filter: z.string().optional().describe(
|
|
2708
2718
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
2709
2719
|
),
|
|
2710
|
-
last_updated_before_filter:
|
|
2720
|
+
last_updated_before_filter: z.string().optional().describe(
|
|
2711
2721
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
2712
2722
|
),
|
|
2713
|
-
search_recency_filter:
|
|
2723
|
+
search_recency_filter: z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
2714
2724
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
2715
2725
|
)
|
|
2716
2726
|
})
|
|
@@ -2718,31 +2728,31 @@ var perplexitySearchInputSchema = lazySchema12(
|
|
|
2718
2728
|
);
|
|
2719
2729
|
var perplexitySearchOutputSchema = lazySchema12(
|
|
2720
2730
|
() => zodSchema12(
|
|
2721
|
-
|
|
2731
|
+
z.union([
|
|
2722
2732
|
// Success response
|
|
2723
|
-
|
|
2724
|
-
results:
|
|
2725
|
-
|
|
2726
|
-
title:
|
|
2727
|
-
url:
|
|
2728
|
-
snippet:
|
|
2729
|
-
date:
|
|
2730
|
-
lastUpdated:
|
|
2733
|
+
z.object({
|
|
2734
|
+
results: z.array(
|
|
2735
|
+
z.object({
|
|
2736
|
+
title: z.string(),
|
|
2737
|
+
url: z.string(),
|
|
2738
|
+
snippet: z.string(),
|
|
2739
|
+
date: z.string().optional(),
|
|
2740
|
+
lastUpdated: z.string().optional()
|
|
2731
2741
|
})
|
|
2732
2742
|
),
|
|
2733
|
-
id:
|
|
2743
|
+
id: z.string()
|
|
2734
2744
|
}),
|
|
2735
2745
|
// Error response
|
|
2736
|
-
|
|
2737
|
-
error:
|
|
2746
|
+
z.object({
|
|
2747
|
+
error: z.enum([
|
|
2738
2748
|
"api_error",
|
|
2739
2749
|
"rate_limit",
|
|
2740
2750
|
"timeout",
|
|
2741
2751
|
"invalid_input",
|
|
2742
2752
|
"unknown"
|
|
2743
2753
|
]),
|
|
2744
|
-
statusCode:
|
|
2745
|
-
message:
|
|
2754
|
+
statusCode: z.number().optional(),
|
|
2755
|
+
message: z.string()
|
|
2746
2756
|
})
|
|
2747
2757
|
])
|
|
2748
2758
|
)
|
|
@@ -2792,13 +2802,13 @@ async function getVercelRequestId() {
|
|
|
2792
2802
|
}
|
|
2793
2803
|
|
|
2794
2804
|
// src/version.ts
|
|
2795
|
-
var VERSION = true ? "4.0.
|
|
2805
|
+
var VERSION = true ? "4.0.47" : "0.0.0-test";
|
|
2796
2806
|
|
|
2797
2807
|
// src/gateway-provider.ts
|
|
2798
2808
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
2799
|
-
var gatewayClientSecretResponseSchema =
|
|
2800
|
-
token:
|
|
2801
|
-
expiresAt:
|
|
2809
|
+
var gatewayClientSecretResponseSchema = z.object({
|
|
2810
|
+
token: z.string(),
|
|
2811
|
+
expiresAt: z.number().nullish()
|
|
2802
2812
|
});
|
|
2803
2813
|
function createGateway(options = {}) {
|
|
2804
2814
|
var _a11, _b11;
|
|
@@ -2861,7 +2871,7 @@ function createGateway(options = {}) {
|
|
|
2861
2871
|
gatewayClientSecretResponseSchema
|
|
2862
2872
|
),
|
|
2863
2873
|
failedResponseHandler: createJsonErrorResponseHandler11({
|
|
2864
|
-
errorSchema:
|
|
2874
|
+
errorSchema: z.any(),
|
|
2865
2875
|
errorToMessage: (data) => data
|
|
2866
2876
|
}),
|
|
2867
2877
|
fetch: options.fetch
|