@ai-sdk/gateway 2.0.64 → 2.0.66

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.js CHANGED
@@ -34,7 +34,7 @@ __export(index_exports, {
34
34
  module.exports = __toCommonJS(index_exports);
35
35
 
36
36
  // src/gateway-provider.ts
37
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
37
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
38
38
 
39
39
  // src/errors/as-gateway-error.ts
40
40
  var import_provider = require("@ai-sdk/provider");
@@ -535,9 +535,111 @@ var gatewayCreditsResponseSchema = (0, import_provider_utils4.lazyValidator)(
535
535
  )
536
536
  );
537
537
 
538
- // src/gateway-language-model.ts
538
+ // src/gateway-spend-report.ts
539
539
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
540
540
  var import_v45 = require("zod/v4");
541
+ var GatewaySpendReport = class {
542
+ constructor(config) {
543
+ this.config = config;
544
+ }
545
+ async getSpendReport(params) {
546
+ try {
547
+ const baseUrl = new URL(this.config.baseURL);
548
+ const searchParams = new URLSearchParams();
549
+ searchParams.set("start_date", params.startDate);
550
+ searchParams.set("end_date", params.endDate);
551
+ if (params.groupBy) {
552
+ searchParams.set("group_by", params.groupBy);
553
+ }
554
+ if (params.datePart) {
555
+ searchParams.set("date_part", params.datePart);
556
+ }
557
+ if (params.userId) {
558
+ searchParams.set("user_id", params.userId);
559
+ }
560
+ if (params.model) {
561
+ searchParams.set("model", params.model);
562
+ }
563
+ if (params.provider) {
564
+ searchParams.set("provider", params.provider);
565
+ }
566
+ if (params.credentialType) {
567
+ searchParams.set("credential_type", params.credentialType);
568
+ }
569
+ if (params.tags && params.tags.length > 0) {
570
+ searchParams.set("tags", params.tags.join(","));
571
+ }
572
+ const { value } = await (0, import_provider_utils5.getFromApi)({
573
+ url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
574
+ headers: await (0, import_provider_utils5.resolve)(this.config.headers()),
575
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
576
+ gatewaySpendReportResponseSchema
577
+ ),
578
+ failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
579
+ errorSchema: import_v45.z.any(),
580
+ errorToMessage: (data) => data
581
+ }),
582
+ fetch: this.config.fetch
583
+ });
584
+ return value;
585
+ } catch (error) {
586
+ throw await asGatewayError(error);
587
+ }
588
+ }
589
+ };
590
+ var gatewaySpendReportResponseSchema = (0, import_provider_utils5.lazySchema)(
591
+ () => (0, import_provider_utils5.zodSchema)(
592
+ import_v45.z.object({
593
+ results: import_v45.z.array(
594
+ import_v45.z.object({
595
+ day: import_v45.z.string().optional(),
596
+ hour: import_v45.z.string().optional(),
597
+ user: import_v45.z.string().optional(),
598
+ model: import_v45.z.string().optional(),
599
+ tag: import_v45.z.string().optional(),
600
+ provider: import_v45.z.string().optional(),
601
+ credential_type: import_v45.z.enum(["byok", "system"]).optional(),
602
+ total_cost: import_v45.z.number(),
603
+ market_cost: import_v45.z.number().optional(),
604
+ input_tokens: import_v45.z.number().optional(),
605
+ output_tokens: import_v45.z.number().optional(),
606
+ cached_input_tokens: import_v45.z.number().optional(),
607
+ cache_creation_input_tokens: import_v45.z.number().optional(),
608
+ reasoning_tokens: import_v45.z.number().optional(),
609
+ request_count: import_v45.z.number().optional()
610
+ }).transform(
611
+ ({
612
+ credential_type,
613
+ total_cost,
614
+ market_cost,
615
+ input_tokens,
616
+ output_tokens,
617
+ cached_input_tokens,
618
+ cache_creation_input_tokens,
619
+ reasoning_tokens,
620
+ request_count,
621
+ ...rest
622
+ }) => ({
623
+ ...rest,
624
+ ...credential_type !== void 0 ? { credentialType: credential_type } : {},
625
+ totalCost: total_cost,
626
+ ...market_cost !== void 0 ? { marketCost: market_cost } : {},
627
+ ...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
628
+ ...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
629
+ ...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
630
+ ...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
631
+ ...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
632
+ ...request_count !== void 0 ? { requestCount: request_count } : {}
633
+ })
634
+ )
635
+ )
636
+ })
637
+ )
638
+ );
639
+
640
+ // src/gateway-language-model.ts
641
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
642
+ var import_v46 = require("zod/v4");
541
643
  var GatewayLanguageModel = class {
542
644
  constructor(modelId, config) {
543
645
  this.modelId = modelId;
@@ -558,24 +660,24 @@ var GatewayLanguageModel = class {
558
660
  async doGenerate(options) {
559
661
  const { args, warnings } = await this.getArgs(options);
560
662
  const { abortSignal } = options;
561
- const resolvedHeaders = await (0, import_provider_utils5.resolve)(this.config.headers());
663
+ const resolvedHeaders = await (0, import_provider_utils6.resolve)(this.config.headers());
562
664
  try {
563
665
  const {
564
666
  responseHeaders,
565
667
  value: responseBody,
566
668
  rawValue: rawResponse
567
- } = await (0, import_provider_utils5.postJsonToApi)({
669
+ } = await (0, import_provider_utils6.postJsonToApi)({
568
670
  url: this.getUrl(),
569
- headers: (0, import_provider_utils5.combineHeaders)(
671
+ headers: (0, import_provider_utils6.combineHeaders)(
570
672
  resolvedHeaders,
571
673
  options.headers,
572
674
  this.getModelConfigHeaders(this.modelId, false),
573
- await (0, import_provider_utils5.resolve)(this.config.o11yHeaders)
675
+ await (0, import_provider_utils6.resolve)(this.config.o11yHeaders)
574
676
  ),
575
677
  body: args,
576
- successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(import_v45.z.any()),
577
- failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
578
- errorSchema: import_v45.z.any(),
678
+ successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(import_v46.z.any()),
679
+ failedResponseHandler: (0, import_provider_utils6.createJsonErrorResponseHandler)({
680
+ errorSchema: import_v46.z.any(),
579
681
  errorToMessage: (data) => data
580
682
  }),
581
683
  ...abortSignal && { abortSignal },
@@ -594,20 +696,20 @@ var GatewayLanguageModel = class {
594
696
  async doStream(options) {
595
697
  const { args, warnings } = await this.getArgs(options);
596
698
  const { abortSignal } = options;
597
- const resolvedHeaders = await (0, import_provider_utils5.resolve)(this.config.headers());
699
+ const resolvedHeaders = await (0, import_provider_utils6.resolve)(this.config.headers());
598
700
  try {
599
- const { value: response, responseHeaders } = await (0, import_provider_utils5.postJsonToApi)({
701
+ const { value: response, responseHeaders } = await (0, import_provider_utils6.postJsonToApi)({
600
702
  url: this.getUrl(),
601
- headers: (0, import_provider_utils5.combineHeaders)(
703
+ headers: (0, import_provider_utils6.combineHeaders)(
602
704
  resolvedHeaders,
603
705
  options.headers,
604
706
  this.getModelConfigHeaders(this.modelId, true),
605
- await (0, import_provider_utils5.resolve)(this.config.o11yHeaders)
707
+ await (0, import_provider_utils6.resolve)(this.config.o11yHeaders)
606
708
  ),
607
709
  body: args,
608
- successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(import_v45.z.any()),
609
- failedResponseHandler: (0, import_provider_utils5.createJsonErrorResponseHandler)({
610
- errorSchema: import_v45.z.any(),
710
+ successfulResponseHandler: (0, import_provider_utils6.createEventSourceResponseHandler)(import_v46.z.any()),
711
+ failedResponseHandler: (0, import_provider_utils6.createJsonErrorResponseHandler)({
712
+ errorSchema: import_v46.z.any(),
611
713
  errorToMessage: (data) => data
612
714
  }),
613
715
  ...abortSignal && { abortSignal },
@@ -685,8 +787,8 @@ var GatewayLanguageModel = class {
685
787
  };
686
788
 
687
789
  // src/gateway-embedding-model.ts
688
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
689
- var import_v46 = require("zod/v4");
790
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
791
+ var import_v47 = require("zod/v4");
690
792
  var GatewayEmbeddingModel = class {
691
793
  constructor(modelId, config) {
692
794
  this.modelId = modelId;
@@ -705,29 +807,29 @@ var GatewayEmbeddingModel = class {
705
807
  providerOptions
706
808
  }) {
707
809
  var _a9;
708
- const resolvedHeaders = await (0, import_provider_utils6.resolve)(this.config.headers());
810
+ const resolvedHeaders = await (0, import_provider_utils7.resolve)(this.config.headers());
709
811
  try {
710
812
  const {
711
813
  responseHeaders,
712
814
  value: responseBody,
713
815
  rawValue
714
- } = await (0, import_provider_utils6.postJsonToApi)({
816
+ } = await (0, import_provider_utils7.postJsonToApi)({
715
817
  url: this.getUrl(),
716
- headers: (0, import_provider_utils6.combineHeaders)(
818
+ headers: (0, import_provider_utils7.combineHeaders)(
717
819
  resolvedHeaders,
718
820
  headers != null ? headers : {},
719
821
  this.getModelConfigHeaders(),
720
- await (0, import_provider_utils6.resolve)(this.config.o11yHeaders)
822
+ await (0, import_provider_utils7.resolve)(this.config.o11yHeaders)
721
823
  ),
722
824
  body: {
723
825
  input: values.length === 1 ? values[0] : values,
724
826
  ...providerOptions ? { providerOptions } : {}
725
827
  },
726
- successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
828
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
727
829
  gatewayEmbeddingResponseSchema
728
830
  ),
729
- failedResponseHandler: (0, import_provider_utils6.createJsonErrorResponseHandler)({
730
- errorSchema: import_v46.z.any(),
831
+ failedResponseHandler: (0, import_provider_utils7.createJsonErrorResponseHandler)({
832
+ errorSchema: import_v47.z.any(),
731
833
  errorToMessage: (data) => data
732
834
  }),
733
835
  ...abortSignal && { abortSignal },
@@ -753,19 +855,19 @@ var GatewayEmbeddingModel = class {
753
855
  };
754
856
  }
755
857
  };
756
- var gatewayEmbeddingResponseSchema = (0, import_provider_utils6.lazyValidator)(
757
- () => (0, import_provider_utils6.zodSchema)(
758
- import_v46.z.object({
759
- embeddings: import_v46.z.array(import_v46.z.array(import_v46.z.number())),
760
- usage: import_v46.z.object({ tokens: import_v46.z.number() }).nullish(),
761
- providerMetadata: import_v46.z.record(import_v46.z.string(), import_v46.z.record(import_v46.z.string(), import_v46.z.unknown())).optional()
858
+ var gatewayEmbeddingResponseSchema = (0, import_provider_utils7.lazyValidator)(
859
+ () => (0, import_provider_utils7.zodSchema)(
860
+ import_v47.z.object({
861
+ embeddings: import_v47.z.array(import_v47.z.array(import_v47.z.number())),
862
+ usage: import_v47.z.object({ tokens: import_v47.z.number() }).nullish(),
863
+ providerMetadata: import_v47.z.record(import_v47.z.string(), import_v47.z.record(import_v47.z.string(), import_v47.z.unknown())).optional()
762
864
  })
763
865
  )
764
866
  );
765
867
 
766
868
  // src/gateway-image-model.ts
767
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
768
- var import_v47 = require("zod/v4");
869
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
870
+ var import_v48 = require("zod/v4");
769
871
  var GatewayImageModel = class {
770
872
  constructor(modelId, config) {
771
873
  this.modelId = modelId;
@@ -788,19 +890,19 @@ var GatewayImageModel = class {
788
890
  abortSignal
789
891
  }) {
790
892
  var _a9, _b9, _c, _d;
791
- const resolvedHeaders = await (0, import_provider_utils7.resolve)(this.config.headers());
893
+ const resolvedHeaders = await (0, import_provider_utils8.resolve)(this.config.headers());
792
894
  try {
793
895
  const {
794
896
  responseHeaders,
795
897
  value: responseBody,
796
898
  rawValue
797
- } = await (0, import_provider_utils7.postJsonToApi)({
899
+ } = await (0, import_provider_utils8.postJsonToApi)({
798
900
  url: this.getUrl(),
799
- headers: (0, import_provider_utils7.combineHeaders)(
901
+ headers: (0, import_provider_utils8.combineHeaders)(
800
902
  resolvedHeaders,
801
903
  headers != null ? headers : {},
802
904
  this.getModelConfigHeaders(),
803
- await (0, import_provider_utils7.resolve)(this.config.o11yHeaders)
905
+ await (0, import_provider_utils8.resolve)(this.config.o11yHeaders)
804
906
  ),
805
907
  body: {
806
908
  prompt,
@@ -810,11 +912,11 @@ var GatewayImageModel = class {
810
912
  ...seed && { seed },
811
913
  ...providerOptions && { providerOptions }
812
914
  },
813
- successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
915
+ successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
814
916
  gatewayImageResponseSchema
815
917
  ),
816
- failedResponseHandler: (0, import_provider_utils7.createJsonErrorResponseHandler)({
817
- errorSchema: import_v47.z.any(),
918
+ failedResponseHandler: (0, import_provider_utils8.createJsonErrorResponseHandler)({
919
+ errorSchema: import_v48.z.any(),
818
920
  errorToMessage: (data) => data
819
921
  }),
820
922
  ...abortSignal && { abortSignal },
@@ -852,32 +954,32 @@ var GatewayImageModel = class {
852
954
  };
853
955
  }
854
956
  };
855
- var providerMetadataEntrySchema = import_v47.z.object({
856
- images: import_v47.z.array(import_v47.z.unknown()).optional()
857
- }).catchall(import_v47.z.unknown());
858
- var gatewayImageUsageSchema = import_v47.z.object({
859
- inputTokens: import_v47.z.number().nullish(),
860
- outputTokens: import_v47.z.number().nullish(),
861
- totalTokens: import_v47.z.number().nullish()
957
+ var providerMetadataEntrySchema = import_v48.z.object({
958
+ images: import_v48.z.array(import_v48.z.unknown()).optional()
959
+ }).catchall(import_v48.z.unknown());
960
+ var gatewayImageUsageSchema = import_v48.z.object({
961
+ inputTokens: import_v48.z.number().nullish(),
962
+ outputTokens: import_v48.z.number().nullish(),
963
+ totalTokens: import_v48.z.number().nullish()
862
964
  });
863
- var gatewayImageResponseSchema = import_v47.z.object({
864
- images: import_v47.z.array(import_v47.z.string()),
965
+ var gatewayImageResponseSchema = import_v48.z.object({
966
+ images: import_v48.z.array(import_v48.z.string()),
865
967
  // Always base64 strings over the wire
866
- warnings: import_v47.z.array(
867
- import_v47.z.object({
868
- type: import_v47.z.literal("other"),
869
- message: import_v47.z.string()
968
+ warnings: import_v48.z.array(
969
+ import_v48.z.object({
970
+ type: import_v48.z.literal("other"),
971
+ message: import_v48.z.string()
870
972
  })
871
973
  ).optional(),
872
- providerMetadata: import_v47.z.record(import_v47.z.string(), providerMetadataEntrySchema).optional(),
974
+ providerMetadata: import_v48.z.record(import_v48.z.string(), providerMetadataEntrySchema).optional(),
873
975
  usage: gatewayImageUsageSchema.optional()
874
976
  });
875
977
 
876
978
  // src/tool/parallel-search.ts
877
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
979
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
878
980
  var import_zod = require("zod");
879
- var parallelSearchInputSchema = (0, import_provider_utils8.lazySchema)(
880
- () => (0, import_provider_utils8.zodSchema)(
981
+ var parallelSearchInputSchema = (0, import_provider_utils9.lazySchema)(
982
+ () => (0, import_provider_utils9.zodSchema)(
881
983
  import_zod.z.object({
882
984
  objective: import_zod.z.string().describe(
883
985
  "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
@@ -912,8 +1014,8 @@ var parallelSearchInputSchema = (0, import_provider_utils8.lazySchema)(
912
1014
  })
913
1015
  )
914
1016
  );
915
- var parallelSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
916
- () => (0, import_provider_utils8.zodSchema)(
1017
+ var parallelSearchOutputSchema = (0, import_provider_utils9.lazySchema)(
1018
+ () => (0, import_provider_utils9.zodSchema)(
917
1019
  import_zod.z.union([
918
1020
  // Success response
919
1021
  import_zod.z.object({
@@ -944,7 +1046,7 @@ var parallelSearchOutputSchema = (0, import_provider_utils8.lazySchema)(
944
1046
  ])
945
1047
  )
946
1048
  );
947
- var parallelSearchToolFactory = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1049
+ var parallelSearchToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
948
1050
  id: "gateway.parallel_search",
949
1051
  name: "parallel_search",
950
1052
  inputSchema: parallelSearchInputSchema,
@@ -953,10 +1055,10 @@ var parallelSearchToolFactory = (0, import_provider_utils8.createProviderDefined
953
1055
  var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
954
1056
 
955
1057
  // src/tool/perplexity-search.ts
956
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1058
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
957
1059
  var import_zod2 = require("zod");
958
- var perplexitySearchInputSchema = (0, import_provider_utils9.lazySchema)(
959
- () => (0, import_provider_utils9.zodSchema)(
1060
+ var perplexitySearchInputSchema = (0, import_provider_utils10.lazySchema)(
1061
+ () => (0, import_provider_utils10.zodSchema)(
960
1062
  import_zod2.z.object({
961
1063
  query: import_zod2.z.union([import_zod2.z.string(), import_zod2.z.array(import_zod2.z.string())]).describe(
962
1064
  "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
@@ -997,8 +1099,8 @@ var perplexitySearchInputSchema = (0, import_provider_utils9.lazySchema)(
997
1099
  })
998
1100
  )
999
1101
  );
1000
- var perplexitySearchOutputSchema = (0, import_provider_utils9.lazySchema)(
1001
- () => (0, import_provider_utils9.zodSchema)(
1102
+ var perplexitySearchOutputSchema = (0, import_provider_utils10.lazySchema)(
1103
+ () => (0, import_provider_utils10.zodSchema)(
1002
1104
  import_zod2.z.union([
1003
1105
  // Success response
1004
1106
  import_zod2.z.object({
@@ -1028,7 +1130,7 @@ var perplexitySearchOutputSchema = (0, import_provider_utils9.lazySchema)(
1028
1130
  ])
1029
1131
  )
1030
1132
  );
1031
- var perplexitySearchToolFactory = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1133
+ var perplexitySearchToolFactory = (0, import_provider_utils10.createProviderDefinedToolFactoryWithOutputSchema)({
1032
1134
  id: "gateway.perplexity_search",
1033
1135
  name: "perplexity_search",
1034
1136
  inputSchema: perplexitySearchInputSchema,
@@ -1066,10 +1168,10 @@ async function getVercelRequestId() {
1066
1168
  }
1067
1169
 
1068
1170
  // src/gateway-provider.ts
1069
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1171
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1070
1172
 
1071
1173
  // src/version.ts
1072
- var VERSION = true ? "2.0.64" : "0.0.0-test";
1174
+ var VERSION = true ? "2.0.66" : "0.0.0-test";
1073
1175
 
1074
1176
  // src/gateway-provider.ts
1075
1177
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
@@ -1079,11 +1181,11 @@ function createGatewayProvider(options = {}) {
1079
1181
  let metadataCache = null;
1080
1182
  const cacheRefreshMillis = (_a9 = options.metadataCacheRefreshMillis) != null ? _a9 : 1e3 * 60 * 5;
1081
1183
  let lastFetchTime = 0;
1082
- const baseURL = (_b9 = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _b9 : "https://ai-gateway.vercel.sh/v1/ai";
1184
+ const baseURL = (_b9 = (0, import_provider_utils11.withoutTrailingSlash)(options.baseURL)) != null ? _b9 : "https://ai-gateway.vercel.sh/v1/ai";
1083
1185
  const getHeaders = async () => {
1084
1186
  const auth = await getGatewayAuthToken(options);
1085
1187
  if (auth) {
1086
- return (0, import_provider_utils11.withUserAgentSuffix)(
1188
+ return (0, import_provider_utils12.withUserAgentSuffix)(
1087
1189
  {
1088
1190
  Authorization: `Bearer ${auth.token}`,
1089
1191
  "ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
@@ -1100,19 +1202,19 @@ function createGatewayProvider(options = {}) {
1100
1202
  });
1101
1203
  };
1102
1204
  const createO11yHeaders = () => {
1103
- const deploymentId = (0, import_provider_utils10.loadOptionalSetting)({
1205
+ const deploymentId = (0, import_provider_utils11.loadOptionalSetting)({
1104
1206
  settingValue: void 0,
1105
1207
  environmentVariableName: "VERCEL_DEPLOYMENT_ID"
1106
1208
  });
1107
- const environment = (0, import_provider_utils10.loadOptionalSetting)({
1209
+ const environment = (0, import_provider_utils11.loadOptionalSetting)({
1108
1210
  settingValue: void 0,
1109
1211
  environmentVariableName: "VERCEL_ENV"
1110
1212
  });
1111
- const region = (0, import_provider_utils10.loadOptionalSetting)({
1213
+ const region = (0, import_provider_utils11.loadOptionalSetting)({
1112
1214
  settingValue: void 0,
1113
1215
  environmentVariableName: "VERCEL_REGION"
1114
1216
  });
1115
- const projectId = (0, import_provider_utils10.loadOptionalSetting)({
1217
+ const projectId = (0, import_provider_utils11.loadOptionalSetting)({
1116
1218
  settingValue: void 0,
1117
1219
  environmentVariableName: "VERCEL_PROJECT_ID"
1118
1220
  });
@@ -1169,6 +1271,18 @@ function createGatewayProvider(options = {}) {
1169
1271
  );
1170
1272
  });
1171
1273
  };
1274
+ const getSpendReport = async (params) => {
1275
+ return new GatewaySpendReport({
1276
+ baseURL,
1277
+ headers: getHeaders,
1278
+ fetch: options.fetch
1279
+ }).getSpendReport(params).catch(async (error) => {
1280
+ throw await asGatewayError(
1281
+ error,
1282
+ await parseAuthMethod(await getHeaders())
1283
+ );
1284
+ });
1285
+ };
1172
1286
  const provider = function(modelId) {
1173
1287
  if (new.target) {
1174
1288
  throw new Error(
@@ -1179,6 +1293,7 @@ function createGatewayProvider(options = {}) {
1179
1293
  };
1180
1294
  provider.getAvailableModels = getAvailableModels;
1181
1295
  provider.getCredits = getCredits;
1296
+ provider.getSpendReport = getSpendReport;
1182
1297
  provider.imageModel = (modelId) => {
1183
1298
  return new GatewayImageModel(modelId, {
1184
1299
  provider: "gateway",
@@ -1203,7 +1318,7 @@ function createGatewayProvider(options = {}) {
1203
1318
  }
1204
1319
  var gateway = createGatewayProvider();
1205
1320
  async function getGatewayAuthToken(options) {
1206
- const apiKey = (0, import_provider_utils10.loadOptionalSetting)({
1321
+ const apiKey = (0, import_provider_utils11.loadOptionalSetting)({
1207
1322
  settingValue: options.apiKey,
1208
1323
  environmentVariableName: "AI_GATEWAY_API_KEY"
1209
1324
  });