@ai-sdk/gateway 2.0.64 → 2.0.65

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/dist/index.mjs CHANGED
@@ -518,16 +518,125 @@ var gatewayCreditsResponseSchema = lazyValidator4(
518
518
  )
519
519
  );
520
520
 
521
+ // src/gateway-spend-report.ts
522
+ import {
523
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
524
+ createJsonResponseHandler as createJsonResponseHandler2,
525
+ getFromApi as getFromApi2,
526
+ lazySchema,
527
+ resolve as resolve2,
528
+ zodSchema as zodSchema5
529
+ } from "@ai-sdk/provider-utils";
530
+ import { z as z5 } from "zod/v4";
531
+ var GatewaySpendReport = class {
532
+ constructor(config) {
533
+ this.config = config;
534
+ }
535
+ async getSpendReport(params) {
536
+ try {
537
+ const baseUrl = new URL(this.config.baseURL);
538
+ const searchParams = new URLSearchParams();
539
+ searchParams.set("start_date", params.startDate);
540
+ searchParams.set("end_date", params.endDate);
541
+ if (params.groupBy) {
542
+ searchParams.set("group_by", params.groupBy);
543
+ }
544
+ if (params.datePart) {
545
+ searchParams.set("date_part", params.datePart);
546
+ }
547
+ if (params.userId) {
548
+ searchParams.set("user_id", params.userId);
549
+ }
550
+ if (params.model) {
551
+ searchParams.set("model", params.model);
552
+ }
553
+ if (params.provider) {
554
+ searchParams.set("provider", params.provider);
555
+ }
556
+ if (params.credentialType) {
557
+ searchParams.set("credential_type", params.credentialType);
558
+ }
559
+ if (params.tags && params.tags.length > 0) {
560
+ searchParams.set("tags", params.tags.join(","));
561
+ }
562
+ const { value } = await getFromApi2({
563
+ url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
564
+ headers: await resolve2(this.config.headers()),
565
+ successfulResponseHandler: createJsonResponseHandler2(
566
+ gatewaySpendReportResponseSchema
567
+ ),
568
+ failedResponseHandler: createJsonErrorResponseHandler2({
569
+ errorSchema: z5.any(),
570
+ errorToMessage: (data) => data
571
+ }),
572
+ fetch: this.config.fetch
573
+ });
574
+ return value;
575
+ } catch (error) {
576
+ throw await asGatewayError(error);
577
+ }
578
+ }
579
+ };
580
+ var gatewaySpendReportResponseSchema = lazySchema(
581
+ () => zodSchema5(
582
+ z5.object({
583
+ results: z5.array(
584
+ z5.object({
585
+ day: z5.string().optional(),
586
+ hour: z5.string().optional(),
587
+ user: z5.string().optional(),
588
+ model: z5.string().optional(),
589
+ tag: z5.string().optional(),
590
+ provider: z5.string().optional(),
591
+ credential_type: z5.enum(["byok", "system"]).optional(),
592
+ total_cost: z5.number(),
593
+ market_cost: z5.number().optional(),
594
+ input_tokens: z5.number().optional(),
595
+ output_tokens: z5.number().optional(),
596
+ cached_input_tokens: z5.number().optional(),
597
+ cache_creation_input_tokens: z5.number().optional(),
598
+ reasoning_tokens: z5.number().optional(),
599
+ request_count: z5.number().optional()
600
+ }).transform(
601
+ ({
602
+ credential_type,
603
+ total_cost,
604
+ market_cost,
605
+ input_tokens,
606
+ output_tokens,
607
+ cached_input_tokens,
608
+ cache_creation_input_tokens,
609
+ reasoning_tokens,
610
+ request_count,
611
+ ...rest
612
+ }) => ({
613
+ ...rest,
614
+ ...credential_type !== void 0 ? { credentialType: credential_type } : {},
615
+ totalCost: total_cost,
616
+ ...market_cost !== void 0 ? { marketCost: market_cost } : {},
617
+ ...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
618
+ ...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
619
+ ...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
620
+ ...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
621
+ ...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
622
+ ...request_count !== void 0 ? { requestCount: request_count } : {}
623
+ })
624
+ )
625
+ )
626
+ })
627
+ )
628
+ );
629
+
521
630
  // src/gateway-language-model.ts
522
631
  import {
523
632
  combineHeaders,
524
633
  createEventSourceResponseHandler,
525
- createJsonErrorResponseHandler as createJsonErrorResponseHandler2,
526
- createJsonResponseHandler as createJsonResponseHandler2,
634
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
635
+ createJsonResponseHandler as createJsonResponseHandler3,
527
636
  postJsonToApi,
528
- resolve as resolve2
637
+ resolve as resolve3
529
638
  } from "@ai-sdk/provider-utils";
530
- import { z as z5 } from "zod/v4";
639
+ import { z as z6 } from "zod/v4";
531
640
  var GatewayLanguageModel = class {
532
641
  constructor(modelId, config) {
533
642
  this.modelId = modelId;
@@ -548,7 +657,7 @@ var GatewayLanguageModel = class {
548
657
  async doGenerate(options) {
549
658
  const { args, warnings } = await this.getArgs(options);
550
659
  const { abortSignal } = options;
551
- const resolvedHeaders = await resolve2(this.config.headers());
660
+ const resolvedHeaders = await resolve3(this.config.headers());
552
661
  try {
553
662
  const {
554
663
  responseHeaders,
@@ -560,12 +669,12 @@ var GatewayLanguageModel = class {
560
669
  resolvedHeaders,
561
670
  options.headers,
562
671
  this.getModelConfigHeaders(this.modelId, false),
563
- await resolve2(this.config.o11yHeaders)
672
+ await resolve3(this.config.o11yHeaders)
564
673
  ),
565
674
  body: args,
566
- successfulResponseHandler: createJsonResponseHandler2(z5.any()),
567
- failedResponseHandler: createJsonErrorResponseHandler2({
568
- errorSchema: z5.any(),
675
+ successfulResponseHandler: createJsonResponseHandler3(z6.any()),
676
+ failedResponseHandler: createJsonErrorResponseHandler3({
677
+ errorSchema: z6.any(),
569
678
  errorToMessage: (data) => data
570
679
  }),
571
680
  ...abortSignal && { abortSignal },
@@ -584,7 +693,7 @@ var GatewayLanguageModel = class {
584
693
  async doStream(options) {
585
694
  const { args, warnings } = await this.getArgs(options);
586
695
  const { abortSignal } = options;
587
- const resolvedHeaders = await resolve2(this.config.headers());
696
+ const resolvedHeaders = await resolve3(this.config.headers());
588
697
  try {
589
698
  const { value: response, responseHeaders } = await postJsonToApi({
590
699
  url: this.getUrl(),
@@ -592,12 +701,12 @@ var GatewayLanguageModel = class {
592
701
  resolvedHeaders,
593
702
  options.headers,
594
703
  this.getModelConfigHeaders(this.modelId, true),
595
- await resolve2(this.config.o11yHeaders)
704
+ await resolve3(this.config.o11yHeaders)
596
705
  ),
597
706
  body: args,
598
- successfulResponseHandler: createEventSourceResponseHandler(z5.any()),
599
- failedResponseHandler: createJsonErrorResponseHandler2({
600
- errorSchema: z5.any(),
707
+ successfulResponseHandler: createEventSourceResponseHandler(z6.any()),
708
+ failedResponseHandler: createJsonErrorResponseHandler3({
709
+ errorSchema: z6.any(),
601
710
  errorToMessage: (data) => data
602
711
  }),
603
712
  ...abortSignal && { abortSignal },
@@ -677,14 +786,14 @@ var GatewayLanguageModel = class {
677
786
  // src/gateway-embedding-model.ts
678
787
  import {
679
788
  combineHeaders as combineHeaders2,
680
- createJsonErrorResponseHandler as createJsonErrorResponseHandler3,
681
- createJsonResponseHandler as createJsonResponseHandler3,
789
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
790
+ createJsonResponseHandler as createJsonResponseHandler4,
682
791
  lazyValidator as lazyValidator5,
683
792
  postJsonToApi as postJsonToApi2,
684
- resolve as resolve3,
685
- zodSchema as zodSchema5
793
+ resolve as resolve4,
794
+ zodSchema as zodSchema6
686
795
  } from "@ai-sdk/provider-utils";
687
- import { z as z6 } from "zod/v4";
796
+ import { z as z7 } from "zod/v4";
688
797
  var GatewayEmbeddingModel = class {
689
798
  constructor(modelId, config) {
690
799
  this.modelId = modelId;
@@ -703,7 +812,7 @@ var GatewayEmbeddingModel = class {
703
812
  providerOptions
704
813
  }) {
705
814
  var _a9;
706
- const resolvedHeaders = await resolve3(this.config.headers());
815
+ const resolvedHeaders = await resolve4(this.config.headers());
707
816
  try {
708
817
  const {
709
818
  responseHeaders,
@@ -715,17 +824,17 @@ var GatewayEmbeddingModel = class {
715
824
  resolvedHeaders,
716
825
  headers != null ? headers : {},
717
826
  this.getModelConfigHeaders(),
718
- await resolve3(this.config.o11yHeaders)
827
+ await resolve4(this.config.o11yHeaders)
719
828
  ),
720
829
  body: {
721
830
  input: values.length === 1 ? values[0] : values,
722
831
  ...providerOptions ? { providerOptions } : {}
723
832
  },
724
- successfulResponseHandler: createJsonResponseHandler3(
833
+ successfulResponseHandler: createJsonResponseHandler4(
725
834
  gatewayEmbeddingResponseSchema
726
835
  ),
727
- failedResponseHandler: createJsonErrorResponseHandler3({
728
- errorSchema: z6.any(),
836
+ failedResponseHandler: createJsonErrorResponseHandler4({
837
+ errorSchema: z7.any(),
729
838
  errorToMessage: (data) => data
730
839
  }),
731
840
  ...abortSignal && { abortSignal },
@@ -752,11 +861,11 @@ var GatewayEmbeddingModel = class {
752
861
  }
753
862
  };
754
863
  var gatewayEmbeddingResponseSchema = lazyValidator5(
755
- () => zodSchema5(
756
- z6.object({
757
- embeddings: z6.array(z6.array(z6.number())),
758
- usage: z6.object({ tokens: z6.number() }).nullish(),
759
- providerMetadata: z6.record(z6.string(), z6.record(z6.string(), z6.unknown())).optional()
864
+ () => zodSchema6(
865
+ z7.object({
866
+ embeddings: z7.array(z7.array(z7.number())),
867
+ usage: z7.object({ tokens: z7.number() }).nullish(),
868
+ providerMetadata: z7.record(z7.string(), z7.record(z7.string(), z7.unknown())).optional()
760
869
  })
761
870
  )
762
871
  );
@@ -764,12 +873,12 @@ var gatewayEmbeddingResponseSchema = lazyValidator5(
764
873
  // src/gateway-image-model.ts
765
874
  import {
766
875
  combineHeaders as combineHeaders3,
767
- createJsonResponseHandler as createJsonResponseHandler4,
768
- createJsonErrorResponseHandler as createJsonErrorResponseHandler4,
876
+ createJsonResponseHandler as createJsonResponseHandler5,
877
+ createJsonErrorResponseHandler as createJsonErrorResponseHandler5,
769
878
  postJsonToApi as postJsonToApi3,
770
- resolve as resolve4
879
+ resolve as resolve5
771
880
  } from "@ai-sdk/provider-utils";
772
- import { z as z7 } from "zod/v4";
881
+ import { z as z8 } from "zod/v4";
773
882
  var GatewayImageModel = class {
774
883
  constructor(modelId, config) {
775
884
  this.modelId = modelId;
@@ -792,7 +901,7 @@ var GatewayImageModel = class {
792
901
  abortSignal
793
902
  }) {
794
903
  var _a9, _b9, _c, _d;
795
- const resolvedHeaders = await resolve4(this.config.headers());
904
+ const resolvedHeaders = await resolve5(this.config.headers());
796
905
  try {
797
906
  const {
798
907
  responseHeaders,
@@ -804,7 +913,7 @@ var GatewayImageModel = class {
804
913
  resolvedHeaders,
805
914
  headers != null ? headers : {},
806
915
  this.getModelConfigHeaders(),
807
- await resolve4(this.config.o11yHeaders)
916
+ await resolve5(this.config.o11yHeaders)
808
917
  ),
809
918
  body: {
810
919
  prompt,
@@ -814,11 +923,11 @@ var GatewayImageModel = class {
814
923
  ...seed && { seed },
815
924
  ...providerOptions && { providerOptions }
816
925
  },
817
- successfulResponseHandler: createJsonResponseHandler4(
926
+ successfulResponseHandler: createJsonResponseHandler5(
818
927
  gatewayImageResponseSchema
819
928
  ),
820
- failedResponseHandler: createJsonErrorResponseHandler4({
821
- errorSchema: z7.any(),
929
+ failedResponseHandler: createJsonErrorResponseHandler5({
930
+ errorSchema: z8.any(),
822
931
  errorToMessage: (data) => data
823
932
  }),
824
933
  ...abortSignal && { abortSignal },
@@ -856,89 +965,89 @@ var GatewayImageModel = class {
856
965
  };
857
966
  }
858
967
  };
859
- var providerMetadataEntrySchema = z7.object({
860
- images: z7.array(z7.unknown()).optional()
861
- }).catchall(z7.unknown());
862
- var gatewayImageUsageSchema = z7.object({
863
- inputTokens: z7.number().nullish(),
864
- outputTokens: z7.number().nullish(),
865
- totalTokens: z7.number().nullish()
968
+ var providerMetadataEntrySchema = z8.object({
969
+ images: z8.array(z8.unknown()).optional()
970
+ }).catchall(z8.unknown());
971
+ var gatewayImageUsageSchema = z8.object({
972
+ inputTokens: z8.number().nullish(),
973
+ outputTokens: z8.number().nullish(),
974
+ totalTokens: z8.number().nullish()
866
975
  });
867
- var gatewayImageResponseSchema = z7.object({
868
- images: z7.array(z7.string()),
976
+ var gatewayImageResponseSchema = z8.object({
977
+ images: z8.array(z8.string()),
869
978
  // Always base64 strings over the wire
870
- warnings: z7.array(
871
- z7.object({
872
- type: z7.literal("other"),
873
- message: z7.string()
979
+ warnings: z8.array(
980
+ z8.object({
981
+ type: z8.literal("other"),
982
+ message: z8.string()
874
983
  })
875
984
  ).optional(),
876
- providerMetadata: z7.record(z7.string(), providerMetadataEntrySchema).optional(),
985
+ providerMetadata: z8.record(z8.string(), providerMetadataEntrySchema).optional(),
877
986
  usage: gatewayImageUsageSchema.optional()
878
987
  });
879
988
 
880
989
  // src/tool/parallel-search.ts
881
990
  import {
882
991
  createProviderDefinedToolFactoryWithOutputSchema,
883
- lazySchema,
884
- zodSchema as zodSchema6
992
+ lazySchema as lazySchema2,
993
+ zodSchema as zodSchema7
885
994
  } from "@ai-sdk/provider-utils";
886
- import { z as z8 } from "zod";
887
- var parallelSearchInputSchema = lazySchema(
888
- () => zodSchema6(
889
- z8.object({
890
- objective: z8.string().describe(
995
+ import { z as z9 } from "zod";
996
+ var parallelSearchInputSchema = lazySchema2(
997
+ () => zodSchema7(
998
+ z9.object({
999
+ objective: z9.string().describe(
891
1000
  "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
892
1001
  ),
893
- search_queries: z8.array(z8.string()).optional().describe(
1002
+ search_queries: z9.array(z9.string()).optional().describe(
894
1003
  "Optional search queries to supplement the objective. Maximum 200 characters per query."
895
1004
  ),
896
- mode: z8.enum(["one-shot", "agentic"]).optional().describe(
1005
+ mode: z9.enum(["one-shot", "agentic"]).optional().describe(
897
1006
  'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
898
1007
  ),
899
- max_results: z8.number().optional().describe(
1008
+ max_results: z9.number().optional().describe(
900
1009
  "Maximum number of results to return (1-20). Defaults to 10 if not specified."
901
1010
  ),
902
- source_policy: z8.object({
903
- include_domains: z8.array(z8.string()).optional().describe("List of domains to include in search results."),
904
- exclude_domains: z8.array(z8.string()).optional().describe("List of domains to exclude from search results."),
905
- after_date: z8.string().optional().describe(
1011
+ source_policy: z9.object({
1012
+ include_domains: z9.array(z9.string()).optional().describe("List of domains to include in search results."),
1013
+ exclude_domains: z9.array(z9.string()).optional().describe("List of domains to exclude from search results."),
1014
+ after_date: z9.string().optional().describe(
906
1015
  "Only include results published after this date (ISO 8601 format)."
907
1016
  )
908
1017
  }).optional().describe(
909
1018
  "Source policy for controlling which domains to include/exclude and freshness."
910
1019
  ),
911
- excerpts: z8.object({
912
- max_chars_per_result: z8.number().optional().describe("Maximum characters per result."),
913
- max_chars_total: z8.number().optional().describe("Maximum total characters across all results.")
1020
+ excerpts: z9.object({
1021
+ max_chars_per_result: z9.number().optional().describe("Maximum characters per result."),
1022
+ max_chars_total: z9.number().optional().describe("Maximum total characters across all results.")
914
1023
  }).optional().describe("Excerpt configuration for controlling result length."),
915
- fetch_policy: z8.object({
916
- max_age_seconds: z8.number().optional().describe(
1024
+ fetch_policy: z9.object({
1025
+ max_age_seconds: z9.number().optional().describe(
917
1026
  "Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
918
1027
  )
919
1028
  }).optional().describe("Fetch policy for controlling content freshness.")
920
1029
  })
921
1030
  )
922
1031
  );
923
- var parallelSearchOutputSchema = lazySchema(
924
- () => zodSchema6(
925
- z8.union([
1032
+ var parallelSearchOutputSchema = lazySchema2(
1033
+ () => zodSchema7(
1034
+ z9.union([
926
1035
  // Success response
927
- z8.object({
928
- searchId: z8.string(),
929
- results: z8.array(
930
- z8.object({
931
- url: z8.string(),
932
- title: z8.string(),
933
- excerpt: z8.string(),
934
- publishDate: z8.string().nullable().optional(),
935
- relevanceScore: z8.number().optional()
1036
+ z9.object({
1037
+ searchId: z9.string(),
1038
+ results: z9.array(
1039
+ z9.object({
1040
+ url: z9.string(),
1041
+ title: z9.string(),
1042
+ excerpt: z9.string(),
1043
+ publishDate: z9.string().nullable().optional(),
1044
+ relevanceScore: z9.number().optional()
936
1045
  })
937
1046
  )
938
1047
  }),
939
1048
  // Error response
940
- z8.object({
941
- error: z8.enum([
1049
+ z9.object({
1050
+ error: z9.enum([
942
1051
  "api_error",
943
1052
  "rate_limit",
944
1053
  "timeout",
@@ -946,8 +1055,8 @@ var parallelSearchOutputSchema = lazySchema(
946
1055
  "configuration_error",
947
1056
  "unknown"
948
1057
  ]),
949
- statusCode: z8.number().optional(),
950
- message: z8.string()
1058
+ statusCode: z9.number().optional(),
1059
+ message: z9.string()
951
1060
  })
952
1061
  ])
953
1062
  )
@@ -963,79 +1072,79 @@ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
963
1072
  // src/tool/perplexity-search.ts
964
1073
  import {
965
1074
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
966
- lazySchema as lazySchema2,
967
- zodSchema as zodSchema7
1075
+ lazySchema as lazySchema3,
1076
+ zodSchema as zodSchema8
968
1077
  } from "@ai-sdk/provider-utils";
969
- import { z as z9 } from "zod";
970
- var perplexitySearchInputSchema = lazySchema2(
971
- () => zodSchema7(
972
- z9.object({
973
- query: z9.union([z9.string(), z9.array(z9.string())]).describe(
1078
+ import { z as z10 } from "zod";
1079
+ var perplexitySearchInputSchema = lazySchema3(
1080
+ () => zodSchema8(
1081
+ z10.object({
1082
+ query: z10.union([z10.string(), z10.array(z10.string())]).describe(
974
1083
  "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
975
1084
  ),
976
- max_results: z9.number().optional().describe(
1085
+ max_results: z10.number().optional().describe(
977
1086
  "Maximum number of search results to return (1-20, default: 10)"
978
1087
  ),
979
- max_tokens_per_page: z9.number().optional().describe(
1088
+ max_tokens_per_page: z10.number().optional().describe(
980
1089
  "Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
981
1090
  ),
982
- max_tokens: z9.number().optional().describe(
1091
+ max_tokens: z10.number().optional().describe(
983
1092
  "Maximum total tokens across all search results (default: 25000, max: 1000000)"
984
1093
  ),
985
- country: z9.string().optional().describe(
1094
+ country: z10.string().optional().describe(
986
1095
  "Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
987
1096
  ),
988
- search_domain_filter: z9.array(z9.string()).optional().describe(
1097
+ search_domain_filter: z10.array(z10.string()).optional().describe(
989
1098
  "List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
990
1099
  ),
991
- search_language_filter: z9.array(z9.string()).optional().describe(
1100
+ search_language_filter: z10.array(z10.string()).optional().describe(
992
1101
  "List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
993
1102
  ),
994
- search_after_date: z9.string().optional().describe(
1103
+ search_after_date: z10.string().optional().describe(
995
1104
  "Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
996
1105
  ),
997
- search_before_date: z9.string().optional().describe(
1106
+ search_before_date: z10.string().optional().describe(
998
1107
  "Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
999
1108
  ),
1000
- last_updated_after_filter: z9.string().optional().describe(
1109
+ last_updated_after_filter: z10.string().optional().describe(
1001
1110
  "Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
1002
1111
  ),
1003
- last_updated_before_filter: z9.string().optional().describe(
1112
+ last_updated_before_filter: z10.string().optional().describe(
1004
1113
  "Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
1005
1114
  ),
1006
- search_recency_filter: z9.enum(["day", "week", "month", "year"]).optional().describe(
1115
+ search_recency_filter: z10.enum(["day", "week", "month", "year"]).optional().describe(
1007
1116
  "Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
1008
1117
  )
1009
1118
  })
1010
1119
  )
1011
1120
  );
1012
- var perplexitySearchOutputSchema = lazySchema2(
1013
- () => zodSchema7(
1014
- z9.union([
1121
+ var perplexitySearchOutputSchema = lazySchema3(
1122
+ () => zodSchema8(
1123
+ z10.union([
1015
1124
  // Success response
1016
- z9.object({
1017
- results: z9.array(
1018
- z9.object({
1019
- title: z9.string(),
1020
- url: z9.string(),
1021
- snippet: z9.string(),
1022
- date: z9.string().optional(),
1023
- lastUpdated: z9.string().optional()
1125
+ z10.object({
1126
+ results: z10.array(
1127
+ z10.object({
1128
+ title: z10.string(),
1129
+ url: z10.string(),
1130
+ snippet: z10.string(),
1131
+ date: z10.string().optional(),
1132
+ lastUpdated: z10.string().optional()
1024
1133
  })
1025
1134
  ),
1026
- id: z9.string()
1135
+ id: z10.string()
1027
1136
  }),
1028
1137
  // Error response
1029
- z9.object({
1030
- error: z9.enum([
1138
+ z10.object({
1139
+ error: z10.enum([
1031
1140
  "api_error",
1032
1141
  "rate_limit",
1033
1142
  "timeout",
1034
1143
  "invalid_input",
1035
1144
  "unknown"
1036
1145
  ]),
1037
- statusCode: z9.number().optional(),
1038
- message: z9.string()
1146
+ statusCode: z10.number().optional(),
1147
+ message: z10.string()
1039
1148
  })
1040
1149
  ])
1041
1150
  )
@@ -1081,7 +1190,7 @@ async function getVercelRequestId() {
1081
1190
  import { withUserAgentSuffix } from "@ai-sdk/provider-utils";
1082
1191
 
1083
1192
  // src/version.ts
1084
- var VERSION = true ? "2.0.64" : "0.0.0-test";
1193
+ var VERSION = true ? "2.0.65" : "0.0.0-test";
1085
1194
 
1086
1195
  // src/gateway-provider.ts
1087
1196
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
@@ -1181,6 +1290,18 @@ function createGatewayProvider(options = {}) {
1181
1290
  );
1182
1291
  });
1183
1292
  };
1293
+ const getSpendReport = async (params) => {
1294
+ return new GatewaySpendReport({
1295
+ baseURL,
1296
+ headers: getHeaders,
1297
+ fetch: options.fetch
1298
+ }).getSpendReport(params).catch(async (error) => {
1299
+ throw await asGatewayError(
1300
+ error,
1301
+ await parseAuthMethod(await getHeaders())
1302
+ );
1303
+ });
1304
+ };
1184
1305
  const provider = function(modelId) {
1185
1306
  if (new.target) {
1186
1307
  throw new Error(
@@ -1191,6 +1312,7 @@ function createGatewayProvider(options = {}) {
1191
1312
  };
1192
1313
  provider.getAvailableModels = getAvailableModels;
1193
1314
  provider.getCredits = getCredits;
1315
+ provider.getSpendReport = getSpendReport;
1194
1316
  provider.imageModel = (modelId) => {
1195
1317
  return new GatewayImageModel(modelId, {
1196
1318
  provider: "gateway",