@gullabs/google 0.6.1 → 0.8.0

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.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@gullabs/core');
4
+ var zod = require('zod');
4
5
 
5
6
  // src/adapter.ts
6
7
  function requireApiKey(auth) {
@@ -24,6 +25,10 @@ async function buildGoogleClient(auth) {
24
25
  async generateContent(params) {
25
26
  const result = await ai.models.generateContent(params);
26
27
  return result;
28
+ },
29
+ async countTokens(params) {
30
+ const result = await ai.models.countTokens(params);
31
+ return result;
27
32
  }
28
33
  }
29
34
  };
@@ -69,6 +74,7 @@ function isGeminiCapacityError(err) {
69
74
  // src/adapter.ts
70
75
  var ALLOWED_GOOGLE_PROVIDER_OPTION_KEYS = /* @__PURE__ */ new Set([
71
76
  "cachedContent",
77
+ "flexFallback",
72
78
  "httpOptions",
73
79
  "safetySettings",
74
80
  "tools"
@@ -199,7 +205,7 @@ function mapGoogleProviderOptions(googleOpts, model, structuredOutputRequested,
199
205
  throw badGoogleProviderOptions(
200
206
  `providerOptions.google contains unsupported keys [${unknownKeys.join(
201
207
  ", "
202
- )}] for model "${model}". Allowed keys: cachedContent, httpOptions, safetySettings, tools.`
208
+ )}] for model "${model}". Allowed keys: cachedContent, flexFallback, httpOptions, safetySettings, tools.`
203
209
  );
204
210
  }
205
211
  const mapped = {};
@@ -211,6 +217,14 @@ function mapGoogleProviderOptions(googleOpts, model, structuredOutputRequested,
211
217
  }
212
218
  mapped.cachedContent = googleOpts["cachedContent"];
213
219
  }
220
+ if (googleOpts["flexFallback"] !== void 0) {
221
+ if (typeof googleOpts["flexFallback"] !== "boolean") {
222
+ throw badGoogleProviderOptions(
223
+ `providerOptions.google.flexFallback must be a boolean for model "${model}".`
224
+ );
225
+ }
226
+ mapped.flexFallback = googleOpts["flexFallback"];
227
+ }
214
228
  if (googleOpts["httpOptions"] !== void 0) {
215
229
  if (!isPlainRecord(googleOpts["httpOptions"])) {
216
230
  throw badGoogleProviderOptions(
@@ -347,42 +361,51 @@ function mapUsage(meta) {
347
361
  };
348
362
  return usage;
349
363
  }
364
+ function mapPart(p) {
365
+ switch (p.kind) {
366
+ case "text":
367
+ return { text: p.text };
368
+ case "inline-media": {
369
+ return {
370
+ inlineData: {
371
+ mimeType: p.mimeType,
372
+ data: p.data
373
+ },
374
+ ...p.mediaResolution !== void 0 ? { mediaResolution: { level: mapMediaResolution(p.mediaResolution) } } : {}
375
+ };
376
+ }
377
+ case "file-uri": {
378
+ return {
379
+ fileData: {
380
+ mimeType: p.mimeType,
381
+ fileUri: p.uri
382
+ },
383
+ ...p.mediaResolution !== void 0 ? { mediaResolution: { level: mapMediaResolution(p.mediaResolution) } } : {}
384
+ };
385
+ }
386
+ default:
387
+ return core.assertNever(p);
388
+ }
389
+ }
390
+ function mapMessagesToGeminiContents(messages) {
391
+ return messages.map((msg) => ({
392
+ role: msg.role === "assistant" ? "model" : "user",
393
+ parts: msg.parts.map(mapPart)
394
+ }));
395
+ }
350
396
  function geminiAdapter(opts) {
351
397
  return {
352
398
  id: "google",
353
399
  async run(req, ctx) {
400
+ if (req.provider !== "google") {
401
+ throw new core.LlmError(
402
+ `geminiAdapter received a request for provider "${req.provider}", expected "google".`,
403
+ { kind: "bad_request", retryable: false }
404
+ );
405
+ }
354
406
  const warnings = [];
355
407
  const model = req.model;
356
- const mapPart = (p) => {
357
- switch (p.kind) {
358
- case "text":
359
- return { text: p.text };
360
- case "inline-media": {
361
- return {
362
- inlineData: {
363
- mimeType: p.mimeType,
364
- data: p.data
365
- },
366
- ...p.mediaResolution !== void 0 ? { mediaResolution: { level: mapMediaResolution(p.mediaResolution) } } : {}
367
- };
368
- }
369
- case "file-uri": {
370
- return {
371
- fileData: {
372
- mimeType: p.mimeType,
373
- fileUri: p.uri
374
- },
375
- ...p.mediaResolution !== void 0 ? { mediaResolution: { level: mapMediaResolution(p.mediaResolution) } } : {}
376
- };
377
- }
378
- default:
379
- return core.assertNever(p);
380
- }
381
- };
382
- const contents = req.messages.map((msg) => ({
383
- role: msg.role === "assistant" ? "model" : "user",
384
- parts: msg.parts.map(mapPart)
385
- }));
408
+ const contents = mapMessagesToGeminiContents(req.messages);
386
409
  const genConfig = req.config;
387
410
  const config = {};
388
411
  if (req.system !== void 0) {
@@ -566,7 +589,7 @@ function geminiAdapter(opts) {
566
589
  cause: classified.cause ?? rawErr,
567
590
  ...servedServiceTier !== void 0 ? { servedServiceTier } : {}
568
591
  });
569
- if (config.serviceTier === "flex" && genConfig.flexFallback !== false && isGeminiCapacityError(typed)) {
592
+ if (config.serviceTier === "flex" && googleProviderConfig.flexFallback !== false && isGeminiCapacityError(typed)) {
570
593
  config.serviceTier = "standard";
571
594
  servedServiceTier = "standard";
572
595
  const fallbackTimeout = genConfig.timeoutMs !== void 0 ? genConfig.timeoutMs + TRANSPORT_TIMEOUT_BUFFER_MS : STANDARD_DEFAULT_TIMEOUT_MS;
@@ -671,9 +694,2006 @@ function geminiAdapter(opts) {
671
694
  })()
672
695
  };
673
696
  return result;
697
+ },
698
+ async countTokens(req, ctx) {
699
+ if (req.provider !== "google") {
700
+ throw new core.LlmError(
701
+ `geminiAdapter received a request for provider "${req.provider}", expected "google".`,
702
+ { kind: "bad_request", retryable: false }
703
+ );
704
+ }
705
+ const contents = mapMessagesToGeminiContents(req.messages);
706
+ const params = {
707
+ model: req.model,
708
+ contents,
709
+ ...req.system !== void 0 || ctx.signal !== void 0 ? {
710
+ config: {
711
+ ...req.system !== void 0 ? { systemInstruction: { parts: [{ text: req.system }] } } : {},
712
+ ...ctx.signal !== void 0 ? { abortSignal: ctx.signal } : {}
713
+ }
714
+ } : {}
715
+ };
716
+ try {
717
+ const buildClient = opts?._clientFactory ?? buildGoogleClient;
718
+ const client = opts?.client !== void 0 ? opts.client : await buildClient(ctx.auth);
719
+ const response = await client.models.countTokens(params);
720
+ if (response.totalTokens === void 0) {
721
+ throw new core.LlmError(
722
+ "Gemini countTokens response is malformed: missing required field: totalTokens",
723
+ { kind: "server", retryable: true, provider: "google" }
724
+ );
725
+ }
726
+ const details = response.cachedContentTokenCount !== void 0 ? { cached: response.cachedContentTokenCount } : void 0;
727
+ return {
728
+ totalTokens: response.totalTokens,
729
+ ...details !== void 0 ? { details } : {},
730
+ raw: response
731
+ };
732
+ } catch (rawErr) {
733
+ if (rawErr instanceof core.LlmError) throw rawErr;
734
+ const classified = core.classifyError(rawErr);
735
+ throw new core.LlmError(classified.message, {
736
+ kind: classified.kind,
737
+ retryable: classified.retryable,
738
+ ...classified.httpStatus !== void 0 ? { httpStatus: classified.httpStatus } : {},
739
+ ...classified.retryAfterMs !== void 0 ? { retryAfterMs: classified.retryAfterMs } : {},
740
+ provider: "google",
741
+ cause: classified.cause ?? rawErr
742
+ });
743
+ }
674
744
  }
675
745
  };
676
746
  }
747
+
748
+ // src/pricing.ts
749
+ var pricingVersion = "gemini-2026-06-28";
750
+ var TIER_FACTOR = Object.freeze({
751
+ standard: 1,
752
+ flex: 0.5,
753
+ batch: 0.5
754
+ });
755
+ var GEMINI_PRICING = Object.freeze({
756
+ // ── Gemini 2.5 Pro ── $1.25/$10 (≤200k), $2.50/$15 (>200k); cached $0.125/$0.25
757
+ "gemini-2.5-pro": {
758
+ inputPerM: 125e4,
759
+ cachedPerM: 125e3,
760
+ outputPerM: 1e7,
761
+ gt200k: {
762
+ inputPerM: 25e5,
763
+ cachedPerM: 25e4,
764
+ outputPerM: 15e6
765
+ }
766
+ },
767
+ // ── Gemini 2.5 Flash ── input $0.30 (text), output $2.50, cached $0.03
768
+ "gemini-2.5-flash": {
769
+ inputPerM: 3e5,
770
+ cachedPerM: 3e4,
771
+ outputPerM: 25e5
772
+ },
773
+ // ── Gemini 2.5 Flash-Lite ── input $0.10 (text), output $0.40, cached $0.01
774
+ "gemini-2.5-flash-lite": {
775
+ inputPerM: 1e5,
776
+ cachedPerM: 1e4,
777
+ outputPerM: 4e5
778
+ },
779
+ // ── Gemini 3.5 Flash ── input $1.50, output $9.00, cached $0.15
780
+ "gemini-3.5-flash": {
781
+ inputPerM: 15e5,
782
+ cachedPerM: 15e4,
783
+ outputPerM: 9e6
784
+ },
785
+ // ── Gemini 3.1 Flash-Lite ── input $0.25 (text), output $1.50, cached $0.025
786
+ "gemini-3.1-flash-lite": {
787
+ inputPerM: 25e4,
788
+ cachedPerM: 25e3,
789
+ outputPerM: 15e5
790
+ },
791
+ // ── Gemini 3.1 Pro (preview) ── $2.00/$12 (≤200k), $4.00/$18 (>200k); cached $0.20/$0.40
792
+ "gemini-3.1-pro-preview": {
793
+ inputPerM: 2e6,
794
+ cachedPerM: 2e5,
795
+ outputPerM: 12e6,
796
+ gt200k: {
797
+ inputPerM: 4e6,
798
+ cachedPerM: 4e5,
799
+ outputPerM: 18e6
800
+ }
801
+ },
802
+ // ── Gemini 3 Flash (preview) ── input $0.50, output $3.00, cached $0.05 (90% discount)
803
+ "gemini-3-flash-preview": {
804
+ inputPerM: 5e5,
805
+ cachedPerM: 5e4,
806
+ outputPerM: 3e6
807
+ }
808
+ });
809
+
810
+ // src/cost.ts
811
+ function lookupRates(model) {
812
+ const exact = GEMINI_PRICING[model];
813
+ if (exact !== void 0) return exact;
814
+ let bestKey = "";
815
+ let bestRates;
816
+ for (const key of Object.keys(GEMINI_PRICING)) {
817
+ if (model.startsWith(key) && key.length > bestKey.length) {
818
+ bestKey = key;
819
+ bestRates = GEMINI_PRICING[key];
820
+ }
821
+ }
822
+ return bestRates;
823
+ }
824
+ function geminiPricingSource() {
825
+ return {
826
+ version: pricingVersion,
827
+ price(model, usage, tier) {
828
+ return core.computeCost(model, usage, tier, lookupRates, TIER_FACTOR, pricingVersion);
829
+ },
830
+ hasModel(model) {
831
+ return lookupRates(model) !== void 0;
832
+ },
833
+ listModels() {
834
+ return Object.keys(GEMINI_PRICING);
835
+ }
836
+ };
837
+ }
838
+ var Gemini25ProConfigSchema = zod.z.union([
839
+ zod.z.strictObject({
840
+ temperature: zod.z.number().min(0).max(2).optional().meta({
841
+ title: "Temperature",
842
+ description: "Sampling temperature for gemini-2.5-pro.",
843
+ examples: [0.7]
844
+ }),
845
+ topP: zod.z.number().min(0).max(1).optional().meta({
846
+ title: "Top P",
847
+ description: "Nucleus sampling probability for gemini-2.5-pro."
848
+ }),
849
+ topK: zod.z.number().int().positive().optional().meta({
850
+ title: "Top K",
851
+ description: "Top-k sampling limit for gemini-2.5-pro."
852
+ }),
853
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
854
+ title: "Max Output Tokens",
855
+ description: "Maximum output token cap for gemini-2.5-pro."
856
+ }),
857
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
858
+ title: "Stop Sequences",
859
+ description: "Up to five stop sequences for gemini-2.5-pro."
860
+ }),
861
+ serviceTier: zod.z.literal("flex").meta({
862
+ title: "Service Tier",
863
+ description: "Explicit flex tier for gemini-2.5-pro."
864
+ }),
865
+ reasoning: zod.z.union([
866
+ zod.z.strictObject({
867
+ effort: zod.z.enum(["low", "medium", "high"]).meta({
868
+ title: "Reasoning Effort",
869
+ description: "Reasoning effort for gemini-2.5-pro. Thinking off is not supported."
870
+ }),
871
+ includeThoughts: zod.z.boolean().optional().meta({
872
+ title: "Include Thoughts",
873
+ description: "Return provider thought summaries when supported."
874
+ })
875
+ }),
876
+ zod.z.strictObject({
877
+ budgetTokens: zod.z.number().int().min(128).max(32768).meta({
878
+ title: "Reasoning Budget Tokens",
879
+ description: "thinkingBudget token range for gemini-2.5-pro."
880
+ }),
881
+ includeThoughts: zod.z.boolean().optional().meta({
882
+ title: "Include Thoughts",
883
+ description: "Return provider thought summaries when supported."
884
+ })
885
+ }),
886
+ zod.z.strictObject({
887
+ includeThoughts: zod.z.boolean().meta({
888
+ title: "Include Thoughts",
889
+ description: "Return provider thought summaries when supported."
890
+ })
891
+ })
892
+ ]).optional().meta({
893
+ title: "Reasoning",
894
+ description: "Gemini 2.5 Pro thinkingBudget configuration."
895
+ }),
896
+ timeoutMs: zod.z.number().int().positive().optional().meta({
897
+ title: "Timeout",
898
+ description: "Logical request timeout in milliseconds."
899
+ }),
900
+ providerOptions: zod.z.strictObject({
901
+ google: zod.z.strictObject({
902
+ cachedContent: zod.z.string().min(1).optional().meta({
903
+ title: "Cached Content",
904
+ description: "Google cached content resource name."
905
+ }),
906
+ safetySettings: zod.z.array(
907
+ zod.z.strictObject({
908
+ category: zod.z.string().min(1).meta({
909
+ title: "Safety Category",
910
+ description: "Google safety category identifier."
911
+ }),
912
+ threshold: zod.z.string().min(1).meta({
913
+ title: "Safety Threshold",
914
+ description: "Google safety threshold identifier."
915
+ })
916
+ })
917
+ ).optional().meta({
918
+ title: "Safety Settings",
919
+ description: "Allowlisted Google safety settings."
920
+ }),
921
+ tools: zod.z.array(
922
+ zod.z.strictObject({
923
+ googleSearch: zod.z.strictObject({}).meta({
924
+ title: "Google Search",
925
+ description: "Google Search grounding tool."
926
+ })
927
+ })
928
+ ).min(1).optional().meta({
929
+ title: "Tools",
930
+ description: "Allowlisted Google tools for gemini-2.5-pro."
931
+ }),
932
+ httpOptions: zod.z.strictObject({
933
+ timeout: zod.z.number().int().positive().optional().meta({
934
+ title: "HTTP Timeout",
935
+ description: "Per-request Google transport timeout in milliseconds."
936
+ })
937
+ }).optional().meta({
938
+ title: "HTTP Options",
939
+ description: "Allowlisted Google transport options."
940
+ }),
941
+ flexFallback: zod.z.boolean().optional().meta({
942
+ title: "Flex Fallback",
943
+ description: "Allow provider fallback from flex when flex was explicitly selected."
944
+ })
945
+ }).optional().meta({
946
+ title: "Google Provider Options",
947
+ description: "Allowlisted Google provider options for gemini-2.5-pro."
948
+ })
949
+ }).optional().meta({
950
+ title: "Provider Options",
951
+ description: "Provider-specific options accepted for gemini-2.5-pro."
952
+ })
953
+ }),
954
+ zod.z.strictObject({
955
+ temperature: zod.z.number().min(0).max(2).optional().meta({
956
+ title: "Temperature",
957
+ description: "Sampling temperature for gemini-2.5-pro.",
958
+ examples: [0.7]
959
+ }),
960
+ topP: zod.z.number().min(0).max(1).optional().meta({
961
+ title: "Top P",
962
+ description: "Nucleus sampling probability for gemini-2.5-pro."
963
+ }),
964
+ topK: zod.z.number().int().positive().optional().meta({
965
+ title: "Top K",
966
+ description: "Top-k sampling limit for gemini-2.5-pro."
967
+ }),
968
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
969
+ title: "Max Output Tokens",
970
+ description: "Maximum output token cap for gemini-2.5-pro."
971
+ }),
972
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
973
+ title: "Stop Sequences",
974
+ description: "Up to five stop sequences for gemini-2.5-pro."
975
+ }),
976
+ serviceTier: zod.z.literal("standard").optional().meta({
977
+ title: "Service Tier",
978
+ description: "Standard tier or omitted tier for gemini-2.5-pro."
979
+ }),
980
+ reasoning: zod.z.union([
981
+ zod.z.strictObject({
982
+ effort: zod.z.enum(["low", "medium", "high"]).meta({
983
+ title: "Reasoning Effort",
984
+ description: "Reasoning effort for gemini-2.5-pro. Thinking off is not supported."
985
+ }),
986
+ includeThoughts: zod.z.boolean().optional().meta({
987
+ title: "Include Thoughts",
988
+ description: "Return provider thought summaries when supported."
989
+ })
990
+ }),
991
+ zod.z.strictObject({
992
+ budgetTokens: zod.z.number().int().min(128).max(32768).meta({
993
+ title: "Reasoning Budget Tokens",
994
+ description: "thinkingBudget token range for gemini-2.5-pro."
995
+ }),
996
+ includeThoughts: zod.z.boolean().optional().meta({
997
+ title: "Include Thoughts",
998
+ description: "Return provider thought summaries when supported."
999
+ })
1000
+ }),
1001
+ zod.z.strictObject({
1002
+ includeThoughts: zod.z.boolean().meta({
1003
+ title: "Include Thoughts",
1004
+ description: "Return provider thought summaries when supported."
1005
+ })
1006
+ })
1007
+ ]).optional().meta({
1008
+ title: "Reasoning",
1009
+ description: "Gemini 2.5 Pro thinkingBudget configuration."
1010
+ }),
1011
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1012
+ title: "Timeout",
1013
+ description: "Logical request timeout in milliseconds."
1014
+ }),
1015
+ providerOptions: zod.z.strictObject({
1016
+ google: zod.z.strictObject({
1017
+ cachedContent: zod.z.string().min(1).optional().meta({
1018
+ title: "Cached Content",
1019
+ description: "Google cached content resource name."
1020
+ }),
1021
+ safetySettings: zod.z.array(
1022
+ zod.z.strictObject({
1023
+ category: zod.z.string().min(1).meta({
1024
+ title: "Safety Category",
1025
+ description: "Google safety category identifier."
1026
+ }),
1027
+ threshold: zod.z.string().min(1).meta({
1028
+ title: "Safety Threshold",
1029
+ description: "Google safety threshold identifier."
1030
+ })
1031
+ })
1032
+ ).optional().meta({
1033
+ title: "Safety Settings",
1034
+ description: "Allowlisted Google safety settings."
1035
+ }),
1036
+ tools: zod.z.array(
1037
+ zod.z.strictObject({
1038
+ googleSearch: zod.z.strictObject({}).meta({
1039
+ title: "Google Search",
1040
+ description: "Google Search grounding tool."
1041
+ })
1042
+ })
1043
+ ).min(1).optional().meta({
1044
+ title: "Tools",
1045
+ description: "Allowlisted Google tools for gemini-2.5-pro."
1046
+ }),
1047
+ httpOptions: zod.z.strictObject({
1048
+ timeout: zod.z.number().int().positive().optional().meta({
1049
+ title: "HTTP Timeout",
1050
+ description: "Per-request Google transport timeout in milliseconds."
1051
+ })
1052
+ }).optional().meta({
1053
+ title: "HTTP Options",
1054
+ description: "Allowlisted Google transport options."
1055
+ })
1056
+ }).optional().meta({
1057
+ title: "Google Provider Options",
1058
+ description: "Allowlisted Google provider options for gemini-2.5-pro."
1059
+ })
1060
+ }).optional().meta({
1061
+ title: "Provider Options",
1062
+ description: "Provider-specific options accepted for gemini-2.5-pro."
1063
+ })
1064
+ })
1065
+ ]).meta({
1066
+ title: "Gemini25ProConfig",
1067
+ description: "Strict generateContent config for model gemini-2.5-pro. Budget reasoning, tunable sampling, flex/standard tiers, structured output, grounding, priced.",
1068
+ examples: [{ serviceTier: "flex", temperature: 0.7, reasoning: { effort: "high" } }]
1069
+ });
1070
+ var Gemini25FlashConfigSchema = zod.z.union([
1071
+ zod.z.strictObject({
1072
+ temperature: zod.z.number().min(0).max(2).optional().meta({
1073
+ title: "Temperature",
1074
+ description: "Sampling temperature for gemini-2.5-flash.",
1075
+ examples: [0.7]
1076
+ }),
1077
+ topP: zod.z.number().min(0).max(1).optional().meta({
1078
+ title: "Top P",
1079
+ description: "Nucleus sampling probability for gemini-2.5-flash."
1080
+ }),
1081
+ topK: zod.z.number().int().positive().optional().meta({
1082
+ title: "Top K",
1083
+ description: "Top-k sampling limit for gemini-2.5-flash."
1084
+ }),
1085
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1086
+ title: "Max Output Tokens",
1087
+ description: "Maximum output token cap for gemini-2.5-flash."
1088
+ }),
1089
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1090
+ title: "Stop Sequences",
1091
+ description: "Up to five stop sequences for gemini-2.5-flash."
1092
+ }),
1093
+ serviceTier: zod.z.literal("flex").meta({
1094
+ title: "Service Tier",
1095
+ description: "Explicit flex tier for gemini-2.5-flash."
1096
+ }),
1097
+ reasoning: zod.z.union([
1098
+ zod.z.strictObject({
1099
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1100
+ title: "Reasoning Effort",
1101
+ description: "Reasoning effort for gemini-2.5-flash."
1102
+ }),
1103
+ includeThoughts: zod.z.boolean().optional().meta({
1104
+ title: "Include Thoughts",
1105
+ description: "Return provider thought summaries when supported."
1106
+ })
1107
+ }),
1108
+ zod.z.strictObject({
1109
+ budgetTokens: zod.z.number().int().min(0).max(24576).meta({
1110
+ title: "Reasoning Budget Tokens",
1111
+ description: "thinkingBudget token range for gemini-2.5-flash."
1112
+ }),
1113
+ includeThoughts: zod.z.boolean().optional().meta({
1114
+ title: "Include Thoughts",
1115
+ description: "Return provider thought summaries when supported."
1116
+ })
1117
+ }),
1118
+ zod.z.strictObject({
1119
+ includeThoughts: zod.z.boolean().meta({
1120
+ title: "Include Thoughts",
1121
+ description: "Return provider thought summaries when supported."
1122
+ })
1123
+ })
1124
+ ]).optional().meta({
1125
+ title: "Reasoning",
1126
+ description: "Gemini 2.5 Flash thinkingBudget configuration."
1127
+ }),
1128
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1129
+ title: "Timeout",
1130
+ description: "Logical request timeout in milliseconds."
1131
+ }),
1132
+ providerOptions: zod.z.strictObject({
1133
+ google: zod.z.strictObject({
1134
+ cachedContent: zod.z.string().min(1).optional().meta({
1135
+ title: "Cached Content",
1136
+ description: "Google cached content resource name."
1137
+ }),
1138
+ safetySettings: zod.z.array(
1139
+ zod.z.strictObject({
1140
+ category: zod.z.string().min(1).meta({
1141
+ title: "Safety Category",
1142
+ description: "Google safety category identifier."
1143
+ }),
1144
+ threshold: zod.z.string().min(1).meta({
1145
+ title: "Safety Threshold",
1146
+ description: "Google safety threshold identifier."
1147
+ })
1148
+ })
1149
+ ).optional().meta({
1150
+ title: "Safety Settings",
1151
+ description: "Allowlisted Google safety settings."
1152
+ }),
1153
+ tools: zod.z.array(
1154
+ zod.z.strictObject({
1155
+ googleSearch: zod.z.strictObject({}).meta({
1156
+ title: "Google Search",
1157
+ description: "Google Search grounding tool."
1158
+ })
1159
+ })
1160
+ ).min(1).optional().meta({
1161
+ title: "Tools",
1162
+ description: "Allowlisted Google tools for gemini-2.5-flash."
1163
+ }),
1164
+ httpOptions: zod.z.strictObject({
1165
+ timeout: zod.z.number().int().positive().optional().meta({
1166
+ title: "HTTP Timeout",
1167
+ description: "Per-request Google transport timeout in milliseconds."
1168
+ })
1169
+ }).optional().meta({
1170
+ title: "HTTP Options",
1171
+ description: "Allowlisted Google transport options."
1172
+ }),
1173
+ flexFallback: zod.z.boolean().optional().meta({
1174
+ title: "Flex Fallback",
1175
+ description: "Allow provider fallback from flex when flex was explicitly selected."
1176
+ })
1177
+ }).optional().meta({
1178
+ title: "Google Provider Options",
1179
+ description: "Allowlisted Google provider options for gemini-2.5-flash."
1180
+ })
1181
+ }).optional().meta({
1182
+ title: "Provider Options",
1183
+ description: "Provider-specific options accepted for gemini-2.5-flash."
1184
+ })
1185
+ }),
1186
+ zod.z.strictObject({
1187
+ temperature: zod.z.number().min(0).max(2).optional().meta({
1188
+ title: "Temperature",
1189
+ description: "Sampling temperature for gemini-2.5-flash.",
1190
+ examples: [0.7]
1191
+ }),
1192
+ topP: zod.z.number().min(0).max(1).optional().meta({
1193
+ title: "Top P",
1194
+ description: "Nucleus sampling probability for gemini-2.5-flash."
1195
+ }),
1196
+ topK: zod.z.number().int().positive().optional().meta({
1197
+ title: "Top K",
1198
+ description: "Top-k sampling limit for gemini-2.5-flash."
1199
+ }),
1200
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1201
+ title: "Max Output Tokens",
1202
+ description: "Maximum output token cap for gemini-2.5-flash."
1203
+ }),
1204
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1205
+ title: "Stop Sequences",
1206
+ description: "Up to five stop sequences for gemini-2.5-flash."
1207
+ }),
1208
+ serviceTier: zod.z.literal("standard").optional().meta({
1209
+ title: "Service Tier",
1210
+ description: "Standard tier or omitted tier for gemini-2.5-flash."
1211
+ }),
1212
+ reasoning: zod.z.union([
1213
+ zod.z.strictObject({
1214
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1215
+ title: "Reasoning Effort",
1216
+ description: "Reasoning effort for gemini-2.5-flash."
1217
+ }),
1218
+ includeThoughts: zod.z.boolean().optional().meta({
1219
+ title: "Include Thoughts",
1220
+ description: "Return provider thought summaries when supported."
1221
+ })
1222
+ }),
1223
+ zod.z.strictObject({
1224
+ budgetTokens: zod.z.number().int().min(0).max(24576).meta({
1225
+ title: "Reasoning Budget Tokens",
1226
+ description: "thinkingBudget token range for gemini-2.5-flash."
1227
+ }),
1228
+ includeThoughts: zod.z.boolean().optional().meta({
1229
+ title: "Include Thoughts",
1230
+ description: "Return provider thought summaries when supported."
1231
+ })
1232
+ }),
1233
+ zod.z.strictObject({
1234
+ includeThoughts: zod.z.boolean().meta({
1235
+ title: "Include Thoughts",
1236
+ description: "Return provider thought summaries when supported."
1237
+ })
1238
+ })
1239
+ ]).optional().meta({
1240
+ title: "Reasoning",
1241
+ description: "Gemini 2.5 Flash thinkingBudget configuration."
1242
+ }),
1243
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1244
+ title: "Timeout",
1245
+ description: "Logical request timeout in milliseconds."
1246
+ }),
1247
+ providerOptions: zod.z.strictObject({
1248
+ google: zod.z.strictObject({
1249
+ cachedContent: zod.z.string().min(1).optional().meta({
1250
+ title: "Cached Content",
1251
+ description: "Google cached content resource name."
1252
+ }),
1253
+ safetySettings: zod.z.array(
1254
+ zod.z.strictObject({
1255
+ category: zod.z.string().min(1).meta({
1256
+ title: "Safety Category",
1257
+ description: "Google safety category identifier."
1258
+ }),
1259
+ threshold: zod.z.string().min(1).meta({
1260
+ title: "Safety Threshold",
1261
+ description: "Google safety threshold identifier."
1262
+ })
1263
+ })
1264
+ ).optional().meta({
1265
+ title: "Safety Settings",
1266
+ description: "Allowlisted Google safety settings."
1267
+ }),
1268
+ tools: zod.z.array(
1269
+ zod.z.strictObject({
1270
+ googleSearch: zod.z.strictObject({}).meta({
1271
+ title: "Google Search",
1272
+ description: "Google Search grounding tool."
1273
+ })
1274
+ })
1275
+ ).min(1).optional().meta({
1276
+ title: "Tools",
1277
+ description: "Allowlisted Google tools for gemini-2.5-flash."
1278
+ }),
1279
+ httpOptions: zod.z.strictObject({
1280
+ timeout: zod.z.number().int().positive().optional().meta({
1281
+ title: "HTTP Timeout",
1282
+ description: "Per-request Google transport timeout in milliseconds."
1283
+ })
1284
+ }).optional().meta({
1285
+ title: "HTTP Options",
1286
+ description: "Allowlisted Google transport options."
1287
+ })
1288
+ }).optional().meta({
1289
+ title: "Google Provider Options",
1290
+ description: "Allowlisted Google provider options for gemini-2.5-flash."
1291
+ })
1292
+ }).optional().meta({
1293
+ title: "Provider Options",
1294
+ description: "Provider-specific options accepted for gemini-2.5-flash."
1295
+ })
1296
+ })
1297
+ ]).meta({
1298
+ title: "Gemini25FlashConfig",
1299
+ description: "Strict generateContent config for model gemini-2.5-flash. Budget reasoning, tunable sampling, flex/standard tiers, structured output, grounding, priced.",
1300
+ examples: [{ serviceTier: "flex", temperature: 0.7, reasoning: { effort: "none" } }]
1301
+ });
1302
+ var Gemini25FlashLiteConfigSchema = zod.z.union([
1303
+ zod.z.strictObject({
1304
+ temperature: zod.z.number().min(0).max(2).optional().meta({
1305
+ title: "Temperature",
1306
+ description: "Sampling temperature for gemini-2.5-flash-lite.",
1307
+ examples: [0.7]
1308
+ }),
1309
+ topP: zod.z.number().min(0).max(1).optional().meta({
1310
+ title: "Top P",
1311
+ description: "Nucleus sampling probability for gemini-2.5-flash-lite."
1312
+ }),
1313
+ topK: zod.z.number().int().positive().optional().meta({
1314
+ title: "Top K",
1315
+ description: "Top-k sampling limit for gemini-2.5-flash-lite."
1316
+ }),
1317
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1318
+ title: "Max Output Tokens",
1319
+ description: "Maximum output token cap for gemini-2.5-flash-lite."
1320
+ }),
1321
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1322
+ title: "Stop Sequences",
1323
+ description: "Up to five stop sequences for gemini-2.5-flash-lite."
1324
+ }),
1325
+ serviceTier: zod.z.literal("flex").meta({
1326
+ title: "Service Tier",
1327
+ description: "Explicit flex tier for gemini-2.5-flash-lite."
1328
+ }),
1329
+ reasoning: zod.z.union([
1330
+ zod.z.strictObject({
1331
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1332
+ title: "Reasoning Effort",
1333
+ description: "Reasoning effort for gemini-2.5-flash-lite."
1334
+ }),
1335
+ includeThoughts: zod.z.boolean().optional().meta({
1336
+ title: "Include Thoughts",
1337
+ description: "Return provider thought summaries when supported."
1338
+ })
1339
+ }),
1340
+ zod.z.strictObject({
1341
+ budgetTokens: zod.z.union([zod.z.literal(0), zod.z.number().int().min(512).max(24576)]).meta({
1342
+ title: "Reasoning Budget Tokens",
1343
+ description: "thinkingBudget token range for gemini-2.5-flash-lite. Zero disables thinking; non-zero values must be 512..24576."
1344
+ }),
1345
+ includeThoughts: zod.z.boolean().optional().meta({
1346
+ title: "Include Thoughts",
1347
+ description: "Return provider thought summaries when supported."
1348
+ })
1349
+ }),
1350
+ zod.z.strictObject({
1351
+ includeThoughts: zod.z.boolean().meta({
1352
+ title: "Include Thoughts",
1353
+ description: "Return provider thought summaries when supported."
1354
+ })
1355
+ })
1356
+ ]).optional().meta({
1357
+ title: "Reasoning",
1358
+ description: "Gemini 2.5 Flash-Lite thinkingBudget configuration."
1359
+ }),
1360
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1361
+ title: "Timeout",
1362
+ description: "Logical request timeout in milliseconds."
1363
+ }),
1364
+ providerOptions: zod.z.strictObject({
1365
+ google: zod.z.strictObject({
1366
+ cachedContent: zod.z.string().min(1).optional().meta({
1367
+ title: "Cached Content",
1368
+ description: "Google cached content resource name."
1369
+ }),
1370
+ safetySettings: zod.z.array(
1371
+ zod.z.strictObject({
1372
+ category: zod.z.string().min(1).meta({
1373
+ title: "Safety Category",
1374
+ description: "Google safety category identifier."
1375
+ }),
1376
+ threshold: zod.z.string().min(1).meta({
1377
+ title: "Safety Threshold",
1378
+ description: "Google safety threshold identifier."
1379
+ })
1380
+ })
1381
+ ).optional().meta({
1382
+ title: "Safety Settings",
1383
+ description: "Allowlisted Google safety settings."
1384
+ }),
1385
+ tools: zod.z.array(
1386
+ zod.z.strictObject({
1387
+ googleSearch: zod.z.strictObject({}).meta({
1388
+ title: "Google Search",
1389
+ description: "Google Search grounding tool."
1390
+ })
1391
+ })
1392
+ ).min(1).optional().meta({
1393
+ title: "Tools",
1394
+ description: "Allowlisted Google tools for gemini-2.5-flash-lite."
1395
+ }),
1396
+ httpOptions: zod.z.strictObject({
1397
+ timeout: zod.z.number().int().positive().optional().meta({
1398
+ title: "HTTP Timeout",
1399
+ description: "Per-request Google transport timeout in milliseconds."
1400
+ })
1401
+ }).optional().meta({
1402
+ title: "HTTP Options",
1403
+ description: "Allowlisted Google transport options."
1404
+ }),
1405
+ flexFallback: zod.z.boolean().optional().meta({
1406
+ title: "Flex Fallback",
1407
+ description: "Allow provider fallback from flex when flex was explicitly selected."
1408
+ })
1409
+ }).optional().meta({
1410
+ title: "Google Provider Options",
1411
+ description: "Allowlisted Google provider options for gemini-2.5-flash-lite."
1412
+ })
1413
+ }).optional().meta({
1414
+ title: "Provider Options",
1415
+ description: "Provider-specific options accepted for gemini-2.5-flash-lite."
1416
+ })
1417
+ }),
1418
+ zod.z.strictObject({
1419
+ temperature: zod.z.number().min(0).max(2).optional().meta({
1420
+ title: "Temperature",
1421
+ description: "Sampling temperature for gemini-2.5-flash-lite.",
1422
+ examples: [0.7]
1423
+ }),
1424
+ topP: zod.z.number().min(0).max(1).optional().meta({
1425
+ title: "Top P",
1426
+ description: "Nucleus sampling probability for gemini-2.5-flash-lite."
1427
+ }),
1428
+ topK: zod.z.number().int().positive().optional().meta({
1429
+ title: "Top K",
1430
+ description: "Top-k sampling limit for gemini-2.5-flash-lite."
1431
+ }),
1432
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1433
+ title: "Max Output Tokens",
1434
+ description: "Maximum output token cap for gemini-2.5-flash-lite."
1435
+ }),
1436
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1437
+ title: "Stop Sequences",
1438
+ description: "Up to five stop sequences for gemini-2.5-flash-lite."
1439
+ }),
1440
+ serviceTier: zod.z.literal("standard").optional().meta({
1441
+ title: "Service Tier",
1442
+ description: "Standard tier or omitted tier for gemini-2.5-flash-lite."
1443
+ }),
1444
+ reasoning: zod.z.union([
1445
+ zod.z.strictObject({
1446
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1447
+ title: "Reasoning Effort",
1448
+ description: "Reasoning effort for gemini-2.5-flash-lite."
1449
+ }),
1450
+ includeThoughts: zod.z.boolean().optional().meta({
1451
+ title: "Include Thoughts",
1452
+ description: "Return provider thought summaries when supported."
1453
+ })
1454
+ }),
1455
+ zod.z.strictObject({
1456
+ budgetTokens: zod.z.union([zod.z.literal(0), zod.z.number().int().min(512).max(24576)]).meta({
1457
+ title: "Reasoning Budget Tokens",
1458
+ description: "thinkingBudget token range for gemini-2.5-flash-lite. Zero disables thinking; non-zero values must be 512..24576."
1459
+ }),
1460
+ includeThoughts: zod.z.boolean().optional().meta({
1461
+ title: "Include Thoughts",
1462
+ description: "Return provider thought summaries when supported."
1463
+ })
1464
+ }),
1465
+ zod.z.strictObject({
1466
+ includeThoughts: zod.z.boolean().meta({
1467
+ title: "Include Thoughts",
1468
+ description: "Return provider thought summaries when supported."
1469
+ })
1470
+ })
1471
+ ]).optional().meta({
1472
+ title: "Reasoning",
1473
+ description: "Gemini 2.5 Flash-Lite thinkingBudget configuration."
1474
+ }),
1475
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1476
+ title: "Timeout",
1477
+ description: "Logical request timeout in milliseconds."
1478
+ }),
1479
+ providerOptions: zod.z.strictObject({
1480
+ google: zod.z.strictObject({
1481
+ cachedContent: zod.z.string().min(1).optional().meta({
1482
+ title: "Cached Content",
1483
+ description: "Google cached content resource name."
1484
+ }),
1485
+ safetySettings: zod.z.array(
1486
+ zod.z.strictObject({
1487
+ category: zod.z.string().min(1).meta({
1488
+ title: "Safety Category",
1489
+ description: "Google safety category identifier."
1490
+ }),
1491
+ threshold: zod.z.string().min(1).meta({
1492
+ title: "Safety Threshold",
1493
+ description: "Google safety threshold identifier."
1494
+ })
1495
+ })
1496
+ ).optional().meta({
1497
+ title: "Safety Settings",
1498
+ description: "Allowlisted Google safety settings."
1499
+ }),
1500
+ tools: zod.z.array(
1501
+ zod.z.strictObject({
1502
+ googleSearch: zod.z.strictObject({}).meta({
1503
+ title: "Google Search",
1504
+ description: "Google Search grounding tool."
1505
+ })
1506
+ })
1507
+ ).min(1).optional().meta({
1508
+ title: "Tools",
1509
+ description: "Allowlisted Google tools for gemini-2.5-flash-lite."
1510
+ }),
1511
+ httpOptions: zod.z.strictObject({
1512
+ timeout: zod.z.number().int().positive().optional().meta({
1513
+ title: "HTTP Timeout",
1514
+ description: "Per-request Google transport timeout in milliseconds."
1515
+ })
1516
+ }).optional().meta({
1517
+ title: "HTTP Options",
1518
+ description: "Allowlisted Google transport options."
1519
+ })
1520
+ }).optional().meta({
1521
+ title: "Google Provider Options",
1522
+ description: "Allowlisted Google provider options for gemini-2.5-flash-lite."
1523
+ })
1524
+ }).optional().meta({
1525
+ title: "Provider Options",
1526
+ description: "Provider-specific options accepted for gemini-2.5-flash-lite."
1527
+ })
1528
+ })
1529
+ ]).meta({
1530
+ title: "Gemini25FlashLiteConfig",
1531
+ description: "Strict generateContent config for model gemini-2.5-flash-lite. Budget reasoning, tunable sampling, flex/standard tiers, structured output, grounding, priced.",
1532
+ examples: [{ serviceTier: "flex", temperature: 0.7, reasoning: { budgetTokens: 0 } }]
1533
+ });
1534
+ var Gemini35FlashConfigSchema = zod.z.union([
1535
+ zod.z.strictObject({
1536
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1537
+ title: "Max Output Tokens",
1538
+ description: "Maximum output token cap for gemini-3.5-flash."
1539
+ }),
1540
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1541
+ title: "Stop Sequences",
1542
+ description: "Up to five stop sequences for gemini-3.5-flash."
1543
+ }),
1544
+ serviceTier: zod.z.literal("flex").meta({
1545
+ title: "Service Tier",
1546
+ description: "Explicit flex tier for gemini-3.5-flash."
1547
+ }),
1548
+ reasoning: zod.z.union([
1549
+ zod.z.strictObject({
1550
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1551
+ title: "Reasoning Effort",
1552
+ description: "Reasoning effort for gemini-3.5-flash; none maps to minimal thinking."
1553
+ }),
1554
+ includeThoughts: zod.z.boolean().optional().meta({
1555
+ title: "Include Thoughts",
1556
+ description: "Return provider thought summaries when supported."
1557
+ })
1558
+ }),
1559
+ zod.z.strictObject({
1560
+ includeThoughts: zod.z.boolean().meta({
1561
+ title: "Include Thoughts",
1562
+ description: "Return provider thought summaries when supported."
1563
+ })
1564
+ })
1565
+ ]).optional().meta({
1566
+ title: "Reasoning",
1567
+ description: "Gemini 3.5 Flash thinkingLevel configuration."
1568
+ }),
1569
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1570
+ title: "Timeout",
1571
+ description: "Logical request timeout in milliseconds."
1572
+ }),
1573
+ providerOptions: zod.z.strictObject({
1574
+ google: zod.z.strictObject({
1575
+ cachedContent: zod.z.string().min(1).optional().meta({
1576
+ title: "Cached Content",
1577
+ description: "Google cached content resource name."
1578
+ }),
1579
+ safetySettings: zod.z.array(
1580
+ zod.z.strictObject({
1581
+ category: zod.z.string().min(1).meta({
1582
+ title: "Safety Category",
1583
+ description: "Google safety category identifier."
1584
+ }),
1585
+ threshold: zod.z.string().min(1).meta({
1586
+ title: "Safety Threshold",
1587
+ description: "Google safety threshold identifier."
1588
+ })
1589
+ })
1590
+ ).optional().meta({
1591
+ title: "Safety Settings",
1592
+ description: "Allowlisted Google safety settings."
1593
+ }),
1594
+ tools: zod.z.array(
1595
+ zod.z.strictObject({
1596
+ googleSearch: zod.z.strictObject({}).meta({
1597
+ title: "Google Search",
1598
+ description: "Google Search grounding tool."
1599
+ })
1600
+ })
1601
+ ).min(1).optional().meta({
1602
+ title: "Tools",
1603
+ description: "Allowlisted Google tools for gemini-3.5-flash."
1604
+ }),
1605
+ httpOptions: zod.z.strictObject({
1606
+ timeout: zod.z.number().int().positive().optional().meta({
1607
+ title: "HTTP Timeout",
1608
+ description: "Per-request Google transport timeout in milliseconds."
1609
+ })
1610
+ }).optional().meta({
1611
+ title: "HTTP Options",
1612
+ description: "Allowlisted Google transport options."
1613
+ }),
1614
+ flexFallback: zod.z.boolean().optional().meta({
1615
+ title: "Flex Fallback",
1616
+ description: "Allow provider fallback from flex when flex was explicitly selected."
1617
+ })
1618
+ }).optional().meta({
1619
+ title: "Google Provider Options",
1620
+ description: "Allowlisted Google provider options for gemini-3.5-flash."
1621
+ })
1622
+ }).optional().meta({
1623
+ title: "Provider Options",
1624
+ description: "Provider-specific options accepted for gemini-3.5-flash."
1625
+ })
1626
+ }),
1627
+ zod.z.strictObject({
1628
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1629
+ title: "Max Output Tokens",
1630
+ description: "Maximum output token cap for gemini-3.5-flash."
1631
+ }),
1632
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1633
+ title: "Stop Sequences",
1634
+ description: "Up to five stop sequences for gemini-3.5-flash."
1635
+ }),
1636
+ serviceTier: zod.z.literal("standard").optional().meta({
1637
+ title: "Service Tier",
1638
+ description: "Standard tier or omitted tier for gemini-3.5-flash."
1639
+ }),
1640
+ reasoning: zod.z.union([
1641
+ zod.z.strictObject({
1642
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1643
+ title: "Reasoning Effort",
1644
+ description: "Reasoning effort for gemini-3.5-flash; none maps to minimal thinking."
1645
+ }),
1646
+ includeThoughts: zod.z.boolean().optional().meta({
1647
+ title: "Include Thoughts",
1648
+ description: "Return provider thought summaries when supported."
1649
+ })
1650
+ }),
1651
+ zod.z.strictObject({
1652
+ includeThoughts: zod.z.boolean().meta({
1653
+ title: "Include Thoughts",
1654
+ description: "Return provider thought summaries when supported."
1655
+ })
1656
+ })
1657
+ ]).optional().meta({
1658
+ title: "Reasoning",
1659
+ description: "Gemini 3.5 Flash thinkingLevel configuration."
1660
+ }),
1661
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1662
+ title: "Timeout",
1663
+ description: "Logical request timeout in milliseconds."
1664
+ }),
1665
+ providerOptions: zod.z.strictObject({
1666
+ google: zod.z.strictObject({
1667
+ cachedContent: zod.z.string().min(1).optional().meta({
1668
+ title: "Cached Content",
1669
+ description: "Google cached content resource name."
1670
+ }),
1671
+ safetySettings: zod.z.array(
1672
+ zod.z.strictObject({
1673
+ category: zod.z.string().min(1).meta({
1674
+ title: "Safety Category",
1675
+ description: "Google safety category identifier."
1676
+ }),
1677
+ threshold: zod.z.string().min(1).meta({
1678
+ title: "Safety Threshold",
1679
+ description: "Google safety threshold identifier."
1680
+ })
1681
+ })
1682
+ ).optional().meta({
1683
+ title: "Safety Settings",
1684
+ description: "Allowlisted Google safety settings."
1685
+ }),
1686
+ tools: zod.z.array(
1687
+ zod.z.strictObject({
1688
+ googleSearch: zod.z.strictObject({}).meta({
1689
+ title: "Google Search",
1690
+ description: "Google Search grounding tool."
1691
+ })
1692
+ })
1693
+ ).min(1).optional().meta({
1694
+ title: "Tools",
1695
+ description: "Allowlisted Google tools for gemini-3.5-flash."
1696
+ }),
1697
+ httpOptions: zod.z.strictObject({
1698
+ timeout: zod.z.number().int().positive().optional().meta({
1699
+ title: "HTTP Timeout",
1700
+ description: "Per-request Google transport timeout in milliseconds."
1701
+ })
1702
+ }).optional().meta({
1703
+ title: "HTTP Options",
1704
+ description: "Allowlisted Google transport options."
1705
+ })
1706
+ }).optional().meta({
1707
+ title: "Google Provider Options",
1708
+ description: "Allowlisted Google provider options for gemini-3.5-flash."
1709
+ })
1710
+ }).optional().meta({
1711
+ title: "Provider Options",
1712
+ description: "Provider-specific options accepted for gemini-3.5-flash."
1713
+ })
1714
+ })
1715
+ ]).meta({
1716
+ title: "Gemini35FlashConfig",
1717
+ description: "Strict generateContent config for model gemini-3.5-flash. Level reasoning, fixed sampling, flex/standard tiers, structured output, grounding, priced.",
1718
+ examples: [{ serviceTier: "flex", reasoning: { effort: "high" } }]
1719
+ });
1720
+ var Gemini31FlashLiteConfigSchema = zod.z.union([
1721
+ zod.z.strictObject({
1722
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1723
+ title: "Max Output Tokens",
1724
+ description: "Maximum output token cap for gemini-3.1-flash-lite."
1725
+ }),
1726
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1727
+ title: "Stop Sequences",
1728
+ description: "Up to five stop sequences for gemini-3.1-flash-lite."
1729
+ }),
1730
+ serviceTier: zod.z.literal("flex").meta({
1731
+ title: "Service Tier",
1732
+ description: "Explicit flex tier for gemini-3.1-flash-lite."
1733
+ }),
1734
+ reasoning: zod.z.union([
1735
+ zod.z.strictObject({
1736
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1737
+ title: "Reasoning Effort",
1738
+ description: "Reasoning effort for gemini-3.1-flash-lite; none maps to minimal thinking."
1739
+ }),
1740
+ includeThoughts: zod.z.boolean().optional().meta({
1741
+ title: "Include Thoughts",
1742
+ description: "Return provider thought summaries when supported."
1743
+ })
1744
+ }),
1745
+ zod.z.strictObject({
1746
+ includeThoughts: zod.z.boolean().meta({
1747
+ title: "Include Thoughts",
1748
+ description: "Return provider thought summaries when supported."
1749
+ })
1750
+ })
1751
+ ]).optional().meta({
1752
+ title: "Reasoning",
1753
+ description: "Gemini 3.1 Flash-Lite thinkingLevel configuration."
1754
+ }),
1755
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1756
+ title: "Timeout",
1757
+ description: "Logical request timeout in milliseconds."
1758
+ }),
1759
+ providerOptions: zod.z.strictObject({
1760
+ google: zod.z.strictObject({
1761
+ cachedContent: zod.z.string().min(1).optional().meta({
1762
+ title: "Cached Content",
1763
+ description: "Google cached content resource name."
1764
+ }),
1765
+ safetySettings: zod.z.array(
1766
+ zod.z.strictObject({
1767
+ category: zod.z.string().min(1).meta({
1768
+ title: "Safety Category",
1769
+ description: "Google safety category identifier."
1770
+ }),
1771
+ threshold: zod.z.string().min(1).meta({
1772
+ title: "Safety Threshold",
1773
+ description: "Google safety threshold identifier."
1774
+ })
1775
+ })
1776
+ ).optional().meta({
1777
+ title: "Safety Settings",
1778
+ description: "Allowlisted Google safety settings."
1779
+ }),
1780
+ tools: zod.z.array(
1781
+ zod.z.strictObject({
1782
+ googleSearch: zod.z.strictObject({}).meta({
1783
+ title: "Google Search",
1784
+ description: "Google Search grounding tool."
1785
+ })
1786
+ })
1787
+ ).min(1).optional().meta({
1788
+ title: "Tools",
1789
+ description: "Allowlisted Google tools for gemini-3.1-flash-lite."
1790
+ }),
1791
+ httpOptions: zod.z.strictObject({
1792
+ timeout: zod.z.number().int().positive().optional().meta({
1793
+ title: "HTTP Timeout",
1794
+ description: "Per-request Google transport timeout in milliseconds."
1795
+ })
1796
+ }).optional().meta({
1797
+ title: "HTTP Options",
1798
+ description: "Allowlisted Google transport options."
1799
+ }),
1800
+ flexFallback: zod.z.boolean().optional().meta({
1801
+ title: "Flex Fallback",
1802
+ description: "Allow provider fallback from flex when flex was explicitly selected."
1803
+ })
1804
+ }).optional().meta({
1805
+ title: "Google Provider Options",
1806
+ description: "Allowlisted Google provider options for gemini-3.1-flash-lite."
1807
+ })
1808
+ }).optional().meta({
1809
+ title: "Provider Options",
1810
+ description: "Provider-specific options accepted for gemini-3.1-flash-lite."
1811
+ })
1812
+ }),
1813
+ zod.z.strictObject({
1814
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1815
+ title: "Max Output Tokens",
1816
+ description: "Maximum output token cap for gemini-3.1-flash-lite."
1817
+ }),
1818
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1819
+ title: "Stop Sequences",
1820
+ description: "Up to five stop sequences for gemini-3.1-flash-lite."
1821
+ }),
1822
+ serviceTier: zod.z.literal("standard").optional().meta({
1823
+ title: "Service Tier",
1824
+ description: "Standard tier or omitted tier for gemini-3.1-flash-lite."
1825
+ }),
1826
+ reasoning: zod.z.union([
1827
+ zod.z.strictObject({
1828
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
1829
+ title: "Reasoning Effort",
1830
+ description: "Reasoning effort for gemini-3.1-flash-lite; none maps to minimal thinking."
1831
+ }),
1832
+ includeThoughts: zod.z.boolean().optional().meta({
1833
+ title: "Include Thoughts",
1834
+ description: "Return provider thought summaries when supported."
1835
+ })
1836
+ }),
1837
+ zod.z.strictObject({
1838
+ includeThoughts: zod.z.boolean().meta({
1839
+ title: "Include Thoughts",
1840
+ description: "Return provider thought summaries when supported."
1841
+ })
1842
+ })
1843
+ ]).optional().meta({
1844
+ title: "Reasoning",
1845
+ description: "Gemini 3.1 Flash-Lite thinkingLevel configuration."
1846
+ }),
1847
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1848
+ title: "Timeout",
1849
+ description: "Logical request timeout in milliseconds."
1850
+ }),
1851
+ providerOptions: zod.z.strictObject({
1852
+ google: zod.z.strictObject({
1853
+ cachedContent: zod.z.string().min(1).optional().meta({
1854
+ title: "Cached Content",
1855
+ description: "Google cached content resource name."
1856
+ }),
1857
+ safetySettings: zod.z.array(
1858
+ zod.z.strictObject({
1859
+ category: zod.z.string().min(1).meta({
1860
+ title: "Safety Category",
1861
+ description: "Google safety category identifier."
1862
+ }),
1863
+ threshold: zod.z.string().min(1).meta({
1864
+ title: "Safety Threshold",
1865
+ description: "Google safety threshold identifier."
1866
+ })
1867
+ })
1868
+ ).optional().meta({
1869
+ title: "Safety Settings",
1870
+ description: "Allowlisted Google safety settings."
1871
+ }),
1872
+ tools: zod.z.array(
1873
+ zod.z.strictObject({
1874
+ googleSearch: zod.z.strictObject({}).meta({
1875
+ title: "Google Search",
1876
+ description: "Google Search grounding tool."
1877
+ })
1878
+ })
1879
+ ).min(1).optional().meta({
1880
+ title: "Tools",
1881
+ description: "Allowlisted Google tools for gemini-3.1-flash-lite."
1882
+ }),
1883
+ httpOptions: zod.z.strictObject({
1884
+ timeout: zod.z.number().int().positive().optional().meta({
1885
+ title: "HTTP Timeout",
1886
+ description: "Per-request Google transport timeout in milliseconds."
1887
+ })
1888
+ }).optional().meta({
1889
+ title: "HTTP Options",
1890
+ description: "Allowlisted Google transport options."
1891
+ })
1892
+ }).optional().meta({
1893
+ title: "Google Provider Options",
1894
+ description: "Allowlisted Google provider options for gemini-3.1-flash-lite."
1895
+ })
1896
+ }).optional().meta({
1897
+ title: "Provider Options",
1898
+ description: "Provider-specific options accepted for gemini-3.1-flash-lite."
1899
+ })
1900
+ })
1901
+ ]).meta({
1902
+ title: "Gemini31FlashLiteConfig",
1903
+ description: "Strict generateContent config for model gemini-3.1-flash-lite. Level reasoning, fixed sampling, flex/standard tiers, structured output, grounding, priced.",
1904
+ examples: [{ serviceTier: "flex", reasoning: { effort: "medium" } }]
1905
+ });
1906
+ var Gemini31ProPreviewConfigSchema = zod.z.union([
1907
+ zod.z.strictObject({
1908
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
1909
+ title: "Max Output Tokens",
1910
+ description: "Maximum output token cap for gemini-3.1-pro-preview."
1911
+ }),
1912
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
1913
+ title: "Stop Sequences",
1914
+ description: "Up to five stop sequences for gemini-3.1-pro-preview."
1915
+ }),
1916
+ serviceTier: zod.z.literal("flex").meta({
1917
+ title: "Service Tier",
1918
+ description: "Explicit flex tier for gemini-3.1-pro-preview."
1919
+ }),
1920
+ reasoning: zod.z.union([
1921
+ zod.z.strictObject({
1922
+ effort: zod.z.enum(["low", "medium", "high"]).meta({
1923
+ title: "Reasoning Effort",
1924
+ description: "Reasoning effort for gemini-3.1-pro-preview. Thinking off is not supported."
1925
+ }),
1926
+ includeThoughts: zod.z.boolean().optional().meta({
1927
+ title: "Include Thoughts",
1928
+ description: "Return provider thought summaries when supported."
1929
+ })
1930
+ }),
1931
+ zod.z.strictObject({
1932
+ includeThoughts: zod.z.boolean().meta({
1933
+ title: "Include Thoughts",
1934
+ description: "Return provider thought summaries when supported."
1935
+ })
1936
+ })
1937
+ ]).optional().meta({
1938
+ title: "Reasoning",
1939
+ description: "Gemini 3.1 Pro Preview thinkingLevel configuration."
1940
+ }),
1941
+ timeoutMs: zod.z.number().int().positive().optional().meta({
1942
+ title: "Timeout",
1943
+ description: "Logical request timeout in milliseconds."
1944
+ }),
1945
+ providerOptions: zod.z.strictObject({
1946
+ google: zod.z.strictObject({
1947
+ cachedContent: zod.z.string().min(1).optional().meta({
1948
+ title: "Cached Content",
1949
+ description: "Google cached content resource name."
1950
+ }),
1951
+ safetySettings: zod.z.array(
1952
+ zod.z.strictObject({
1953
+ category: zod.z.string().min(1).meta({
1954
+ title: "Safety Category",
1955
+ description: "Google safety category identifier."
1956
+ }),
1957
+ threshold: zod.z.string().min(1).meta({
1958
+ title: "Safety Threshold",
1959
+ description: "Google safety threshold identifier."
1960
+ })
1961
+ })
1962
+ ).optional().meta({
1963
+ title: "Safety Settings",
1964
+ description: "Allowlisted Google safety settings."
1965
+ }),
1966
+ tools: zod.z.array(
1967
+ zod.z.strictObject({
1968
+ googleSearch: zod.z.strictObject({}).meta({
1969
+ title: "Google Search",
1970
+ description: "Google Search grounding tool."
1971
+ })
1972
+ })
1973
+ ).min(1).optional().meta({
1974
+ title: "Tools",
1975
+ description: "Allowlisted Google tools for gemini-3.1-pro-preview."
1976
+ }),
1977
+ httpOptions: zod.z.strictObject({
1978
+ timeout: zod.z.number().int().positive().optional().meta({
1979
+ title: "HTTP Timeout",
1980
+ description: "Per-request Google transport timeout in milliseconds."
1981
+ })
1982
+ }).optional().meta({
1983
+ title: "HTTP Options",
1984
+ description: "Allowlisted Google transport options."
1985
+ }),
1986
+ flexFallback: zod.z.boolean().optional().meta({
1987
+ title: "Flex Fallback",
1988
+ description: "Allow provider fallback from flex when flex was explicitly selected."
1989
+ })
1990
+ }).optional().meta({
1991
+ title: "Google Provider Options",
1992
+ description: "Allowlisted Google provider options for gemini-3.1-pro-preview."
1993
+ })
1994
+ }).optional().meta({
1995
+ title: "Provider Options",
1996
+ description: "Provider-specific options accepted for gemini-3.1-pro-preview."
1997
+ })
1998
+ }),
1999
+ zod.z.strictObject({
2000
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
2001
+ title: "Max Output Tokens",
2002
+ description: "Maximum output token cap for gemini-3.1-pro-preview."
2003
+ }),
2004
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
2005
+ title: "Stop Sequences",
2006
+ description: "Up to five stop sequences for gemini-3.1-pro-preview."
2007
+ }),
2008
+ serviceTier: zod.z.literal("standard").optional().meta({
2009
+ title: "Service Tier",
2010
+ description: "Standard tier or omitted tier for gemini-3.1-pro-preview."
2011
+ }),
2012
+ reasoning: zod.z.union([
2013
+ zod.z.strictObject({
2014
+ effort: zod.z.enum(["low", "medium", "high"]).meta({
2015
+ title: "Reasoning Effort",
2016
+ description: "Reasoning effort for gemini-3.1-pro-preview. Thinking off is not supported."
2017
+ }),
2018
+ includeThoughts: zod.z.boolean().optional().meta({
2019
+ title: "Include Thoughts",
2020
+ description: "Return provider thought summaries when supported."
2021
+ })
2022
+ }),
2023
+ zod.z.strictObject({
2024
+ includeThoughts: zod.z.boolean().meta({
2025
+ title: "Include Thoughts",
2026
+ description: "Return provider thought summaries when supported."
2027
+ })
2028
+ })
2029
+ ]).optional().meta({
2030
+ title: "Reasoning",
2031
+ description: "Gemini 3.1 Pro Preview thinkingLevel configuration."
2032
+ }),
2033
+ timeoutMs: zod.z.number().int().positive().optional().meta({
2034
+ title: "Timeout",
2035
+ description: "Logical request timeout in milliseconds."
2036
+ }),
2037
+ providerOptions: zod.z.strictObject({
2038
+ google: zod.z.strictObject({
2039
+ cachedContent: zod.z.string().min(1).optional().meta({
2040
+ title: "Cached Content",
2041
+ description: "Google cached content resource name."
2042
+ }),
2043
+ safetySettings: zod.z.array(
2044
+ zod.z.strictObject({
2045
+ category: zod.z.string().min(1).meta({
2046
+ title: "Safety Category",
2047
+ description: "Google safety category identifier."
2048
+ }),
2049
+ threshold: zod.z.string().min(1).meta({
2050
+ title: "Safety Threshold",
2051
+ description: "Google safety threshold identifier."
2052
+ })
2053
+ })
2054
+ ).optional().meta({
2055
+ title: "Safety Settings",
2056
+ description: "Allowlisted Google safety settings."
2057
+ }),
2058
+ tools: zod.z.array(
2059
+ zod.z.strictObject({
2060
+ googleSearch: zod.z.strictObject({}).meta({
2061
+ title: "Google Search",
2062
+ description: "Google Search grounding tool."
2063
+ })
2064
+ })
2065
+ ).min(1).optional().meta({
2066
+ title: "Tools",
2067
+ description: "Allowlisted Google tools for gemini-3.1-pro-preview."
2068
+ }),
2069
+ httpOptions: zod.z.strictObject({
2070
+ timeout: zod.z.number().int().positive().optional().meta({
2071
+ title: "HTTP Timeout",
2072
+ description: "Per-request Google transport timeout in milliseconds."
2073
+ })
2074
+ }).optional().meta({
2075
+ title: "HTTP Options",
2076
+ description: "Allowlisted Google transport options."
2077
+ })
2078
+ }).optional().meta({
2079
+ title: "Google Provider Options",
2080
+ description: "Allowlisted Google provider options for gemini-3.1-pro-preview."
2081
+ })
2082
+ }).optional().meta({
2083
+ title: "Provider Options",
2084
+ description: "Provider-specific options accepted for gemini-3.1-pro-preview."
2085
+ })
2086
+ })
2087
+ ]).meta({
2088
+ title: "Gemini31ProPreviewConfig",
2089
+ description: "Strict generateContent config for model gemini-3.1-pro-preview. Level reasoning, fixed sampling, flex/standard tiers, structured output, grounding, priced.",
2090
+ examples: [{ serviceTier: "flex", reasoning: { effort: "high" } }]
2091
+ });
2092
+ var Gemini3FlashPreviewConfigSchema = zod.z.union([
2093
+ zod.z.strictObject({
2094
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
2095
+ title: "Max Output Tokens",
2096
+ description: "Maximum output token cap for gemini-3-flash-preview."
2097
+ }),
2098
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
2099
+ title: "Stop Sequences",
2100
+ description: "Up to five stop sequences for gemini-3-flash-preview."
2101
+ }),
2102
+ serviceTier: zod.z.literal("flex").meta({
2103
+ title: "Service Tier",
2104
+ description: "Explicit flex tier for gemini-3-flash-preview."
2105
+ }),
2106
+ reasoning: zod.z.union([
2107
+ zod.z.strictObject({
2108
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
2109
+ title: "Reasoning Effort",
2110
+ description: "Reasoning effort for gemini-3-flash-preview; none maps to minimal thinking."
2111
+ }),
2112
+ includeThoughts: zod.z.boolean().optional().meta({
2113
+ title: "Include Thoughts",
2114
+ description: "Return provider thought summaries when supported."
2115
+ })
2116
+ }),
2117
+ zod.z.strictObject({
2118
+ includeThoughts: zod.z.boolean().meta({
2119
+ title: "Include Thoughts",
2120
+ description: "Return provider thought summaries when supported."
2121
+ })
2122
+ })
2123
+ ]).optional().meta({
2124
+ title: "Reasoning",
2125
+ description: "Gemini 3 Flash Preview thinkingLevel configuration."
2126
+ }),
2127
+ timeoutMs: zod.z.number().int().positive().optional().meta({
2128
+ title: "Timeout",
2129
+ description: "Logical request timeout in milliseconds."
2130
+ }),
2131
+ providerOptions: zod.z.strictObject({
2132
+ google: zod.z.strictObject({
2133
+ cachedContent: zod.z.string().min(1).optional().meta({
2134
+ title: "Cached Content",
2135
+ description: "Google cached content resource name."
2136
+ }),
2137
+ safetySettings: zod.z.array(
2138
+ zod.z.strictObject({
2139
+ category: zod.z.string().min(1).meta({
2140
+ title: "Safety Category",
2141
+ description: "Google safety category identifier."
2142
+ }),
2143
+ threshold: zod.z.string().min(1).meta({
2144
+ title: "Safety Threshold",
2145
+ description: "Google safety threshold identifier."
2146
+ })
2147
+ })
2148
+ ).optional().meta({
2149
+ title: "Safety Settings",
2150
+ description: "Allowlisted Google safety settings."
2151
+ }),
2152
+ tools: zod.z.array(
2153
+ zod.z.strictObject({
2154
+ googleSearch: zod.z.strictObject({}).meta({
2155
+ title: "Google Search",
2156
+ description: "Google Search grounding tool."
2157
+ })
2158
+ })
2159
+ ).min(1).optional().meta({
2160
+ title: "Tools",
2161
+ description: "Allowlisted Google tools for gemini-3-flash-preview."
2162
+ }),
2163
+ httpOptions: zod.z.strictObject({
2164
+ timeout: zod.z.number().int().positive().optional().meta({
2165
+ title: "HTTP Timeout",
2166
+ description: "Per-request Google transport timeout in milliseconds."
2167
+ })
2168
+ }).optional().meta({
2169
+ title: "HTTP Options",
2170
+ description: "Allowlisted Google transport options."
2171
+ }),
2172
+ flexFallback: zod.z.boolean().optional().meta({
2173
+ title: "Flex Fallback",
2174
+ description: "Allow provider fallback from flex when flex was explicitly selected."
2175
+ })
2176
+ }).optional().meta({
2177
+ title: "Google Provider Options",
2178
+ description: "Allowlisted Google provider options for gemini-3-flash-preview."
2179
+ })
2180
+ }).optional().meta({
2181
+ title: "Provider Options",
2182
+ description: "Provider-specific options accepted for gemini-3-flash-preview."
2183
+ })
2184
+ }),
2185
+ zod.z.strictObject({
2186
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
2187
+ title: "Max Output Tokens",
2188
+ description: "Maximum output token cap for gemini-3-flash-preview."
2189
+ }),
2190
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
2191
+ title: "Stop Sequences",
2192
+ description: "Up to five stop sequences for gemini-3-flash-preview."
2193
+ }),
2194
+ serviceTier: zod.z.literal("standard").optional().meta({
2195
+ title: "Service Tier",
2196
+ description: "Standard tier or omitted tier for gemini-3-flash-preview."
2197
+ }),
2198
+ reasoning: zod.z.union([
2199
+ zod.z.strictObject({
2200
+ effort: zod.z.enum(["none", "low", "medium", "high"]).meta({
2201
+ title: "Reasoning Effort",
2202
+ description: "Reasoning effort for gemini-3-flash-preview; none maps to minimal thinking."
2203
+ }),
2204
+ includeThoughts: zod.z.boolean().optional().meta({
2205
+ title: "Include Thoughts",
2206
+ description: "Return provider thought summaries when supported."
2207
+ })
2208
+ }),
2209
+ zod.z.strictObject({
2210
+ includeThoughts: zod.z.boolean().meta({
2211
+ title: "Include Thoughts",
2212
+ description: "Return provider thought summaries when supported."
2213
+ })
2214
+ })
2215
+ ]).optional().meta({
2216
+ title: "Reasoning",
2217
+ description: "Gemini 3 Flash Preview thinkingLevel configuration."
2218
+ }),
2219
+ timeoutMs: zod.z.number().int().positive().optional().meta({
2220
+ title: "Timeout",
2221
+ description: "Logical request timeout in milliseconds."
2222
+ }),
2223
+ providerOptions: zod.z.strictObject({
2224
+ google: zod.z.strictObject({
2225
+ cachedContent: zod.z.string().min(1).optional().meta({
2226
+ title: "Cached Content",
2227
+ description: "Google cached content resource name."
2228
+ }),
2229
+ safetySettings: zod.z.array(
2230
+ zod.z.strictObject({
2231
+ category: zod.z.string().min(1).meta({
2232
+ title: "Safety Category",
2233
+ description: "Google safety category identifier."
2234
+ }),
2235
+ threshold: zod.z.string().min(1).meta({
2236
+ title: "Safety Threshold",
2237
+ description: "Google safety threshold identifier."
2238
+ })
2239
+ })
2240
+ ).optional().meta({
2241
+ title: "Safety Settings",
2242
+ description: "Allowlisted Google safety settings."
2243
+ }),
2244
+ tools: zod.z.array(
2245
+ zod.z.strictObject({
2246
+ googleSearch: zod.z.strictObject({}).meta({
2247
+ title: "Google Search",
2248
+ description: "Google Search grounding tool."
2249
+ })
2250
+ })
2251
+ ).min(1).optional().meta({
2252
+ title: "Tools",
2253
+ description: "Allowlisted Google tools for gemini-3-flash-preview."
2254
+ }),
2255
+ httpOptions: zod.z.strictObject({
2256
+ timeout: zod.z.number().int().positive().optional().meta({
2257
+ title: "HTTP Timeout",
2258
+ description: "Per-request Google transport timeout in milliseconds."
2259
+ })
2260
+ }).optional().meta({
2261
+ title: "HTTP Options",
2262
+ description: "Allowlisted Google transport options."
2263
+ })
2264
+ }).optional().meta({
2265
+ title: "Google Provider Options",
2266
+ description: "Allowlisted Google provider options for gemini-3-flash-preview."
2267
+ })
2268
+ }).optional().meta({
2269
+ title: "Provider Options",
2270
+ description: "Provider-specific options accepted for gemini-3-flash-preview."
2271
+ })
2272
+ })
2273
+ ]).meta({
2274
+ title: "Gemini3FlashPreviewConfig",
2275
+ description: "Strict generateContent config for model gemini-3-flash-preview. Level reasoning, fixed sampling, flex/standard tiers, structured output, grounding, priced.",
2276
+ examples: [{ serviceTier: "flex", reasoning: { effort: "medium" } }]
2277
+ });
2278
+ var Gemma431bItConfigSchema = zod.z.strictObject({
2279
+ temperature: zod.z.number().min(0).max(2).optional().meta({
2280
+ title: "Temperature",
2281
+ description: "Sampling temperature for gemma-4-31b-it.",
2282
+ examples: [0.7]
2283
+ }),
2284
+ topP: zod.z.number().min(0).max(1).optional().meta({
2285
+ title: "Top P",
2286
+ description: "Nucleus sampling probability for gemma-4-31b-it."
2287
+ }),
2288
+ topK: zod.z.number().int().positive().optional().meta({
2289
+ title: "Top K",
2290
+ description: "Top-k sampling limit for gemma-4-31b-it."
2291
+ }),
2292
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
2293
+ title: "Max Output Tokens",
2294
+ description: "Maximum output token cap for gemma-4-31b-it."
2295
+ }),
2296
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
2297
+ title: "Stop Sequences",
2298
+ description: "Up to five stop sequences for gemma-4-31b-it."
2299
+ }),
2300
+ reasoning: zod.z.union([
2301
+ zod.z.strictObject({
2302
+ effort: zod.z.enum(["none", "high"]).meta({
2303
+ title: "Reasoning Effort",
2304
+ description: "Reasoning effort for gemma-4-31b-it."
2305
+ }),
2306
+ includeThoughts: zod.z.boolean().optional().meta({
2307
+ title: "Include Thoughts",
2308
+ description: "Return provider thought summaries when supported."
2309
+ })
2310
+ }),
2311
+ zod.z.strictObject({
2312
+ includeThoughts: zod.z.boolean().meta({
2313
+ title: "Include Thoughts",
2314
+ description: "Return provider thought summaries when supported."
2315
+ })
2316
+ })
2317
+ ]).optional().meta({
2318
+ title: "Reasoning",
2319
+ description: "Gemma 4 31B IT thinkingLevel configuration."
2320
+ }),
2321
+ timeoutMs: zod.z.number().int().positive().optional().meta({
2322
+ title: "Timeout",
2323
+ description: "Logical request timeout in milliseconds."
2324
+ }),
2325
+ providerOptions: zod.z.strictObject({
2326
+ google: zod.z.strictObject({
2327
+ cachedContent: zod.z.string().min(1).optional().meta({
2328
+ title: "Cached Content",
2329
+ description: "Google cached content resource name."
2330
+ }),
2331
+ safetySettings: zod.z.array(
2332
+ zod.z.strictObject({
2333
+ category: zod.z.string().min(1).meta({
2334
+ title: "Safety Category",
2335
+ description: "Google safety category identifier."
2336
+ }),
2337
+ threshold: zod.z.string().min(1).meta({
2338
+ title: "Safety Threshold",
2339
+ description: "Google safety threshold identifier."
2340
+ })
2341
+ })
2342
+ ).optional().meta({
2343
+ title: "Safety Settings",
2344
+ description: "Allowlisted Google safety settings."
2345
+ }),
2346
+ tools: zod.z.array(
2347
+ zod.z.strictObject({
2348
+ googleSearch: zod.z.strictObject({}).meta({
2349
+ title: "Google Search",
2350
+ description: "Google Search grounding tool."
2351
+ })
2352
+ })
2353
+ ).min(1).optional().meta({
2354
+ title: "Tools",
2355
+ description: "Allowlisted Google tools for gemma-4-31b-it."
2356
+ }),
2357
+ httpOptions: zod.z.strictObject({
2358
+ timeout: zod.z.number().int().positive().optional().meta({
2359
+ title: "HTTP Timeout",
2360
+ description: "Per-request Google transport timeout in milliseconds."
2361
+ })
2362
+ }).optional().meta({
2363
+ title: "HTTP Options",
2364
+ description: "Allowlisted Google transport options."
2365
+ })
2366
+ }).optional().meta({
2367
+ title: "Google Provider Options",
2368
+ description: "Allowlisted Google provider options for gemma-4-31b-it."
2369
+ })
2370
+ }).optional().meta({
2371
+ title: "Provider Options",
2372
+ description: "Provider-specific options accepted for gemma-4-31b-it."
2373
+ })
2374
+ }).meta({
2375
+ title: "Gemma431bItConfig",
2376
+ description: "Strict generateContent config for model gemma-4-31b-it. Level reasoning, tunable sampling, no service tier, structured output, grounding, intentionally unpriced.",
2377
+ examples: [{ temperature: 0.7, reasoning: { effort: "high" } }]
2378
+ });
2379
+ var Gemma426bA4bItConfigSchema = zod.z.strictObject({
2380
+ temperature: zod.z.number().min(0).max(2).optional().meta({
2381
+ title: "Temperature",
2382
+ description: "Sampling temperature for gemma-4-26b-a4b-it.",
2383
+ examples: [0.7]
2384
+ }),
2385
+ topP: zod.z.number().min(0).max(1).optional().meta({
2386
+ title: "Top P",
2387
+ description: "Nucleus sampling probability for gemma-4-26b-a4b-it."
2388
+ }),
2389
+ topK: zod.z.number().int().positive().optional().meta({
2390
+ title: "Top K",
2391
+ description: "Top-k sampling limit for gemma-4-26b-a4b-it."
2392
+ }),
2393
+ maxOutputTokens: zod.z.number().int().positive().optional().meta({
2394
+ title: "Max Output Tokens",
2395
+ description: "Maximum output token cap for gemma-4-26b-a4b-it."
2396
+ }),
2397
+ stopSequences: zod.z.array(zod.z.string()).max(5).optional().meta({
2398
+ title: "Stop Sequences",
2399
+ description: "Up to five stop sequences for gemma-4-26b-a4b-it."
2400
+ }),
2401
+ reasoning: zod.z.union([
2402
+ zod.z.strictObject({
2403
+ effort: zod.z.enum(["none", "high"]).meta({
2404
+ title: "Reasoning Effort",
2405
+ description: "Reasoning effort for gemma-4-26b-a4b-it."
2406
+ }),
2407
+ includeThoughts: zod.z.boolean().optional().meta({
2408
+ title: "Include Thoughts",
2409
+ description: "Return provider thought summaries when supported."
2410
+ })
2411
+ }),
2412
+ zod.z.strictObject({
2413
+ includeThoughts: zod.z.boolean().meta({
2414
+ title: "Include Thoughts",
2415
+ description: "Return provider thought summaries when supported."
2416
+ })
2417
+ })
2418
+ ]).optional().meta({
2419
+ title: "Reasoning",
2420
+ description: "Gemma 4 26B A4B IT thinkingLevel configuration."
2421
+ }),
2422
+ timeoutMs: zod.z.number().int().positive().optional().meta({
2423
+ title: "Timeout",
2424
+ description: "Logical request timeout in milliseconds."
2425
+ }),
2426
+ providerOptions: zod.z.strictObject({
2427
+ google: zod.z.strictObject({
2428
+ cachedContent: zod.z.string().min(1).optional().meta({
2429
+ title: "Cached Content",
2430
+ description: "Google cached content resource name."
2431
+ }),
2432
+ safetySettings: zod.z.array(
2433
+ zod.z.strictObject({
2434
+ category: zod.z.string().min(1).meta({
2435
+ title: "Safety Category",
2436
+ description: "Google safety category identifier."
2437
+ }),
2438
+ threshold: zod.z.string().min(1).meta({
2439
+ title: "Safety Threshold",
2440
+ description: "Google safety threshold identifier."
2441
+ })
2442
+ })
2443
+ ).optional().meta({
2444
+ title: "Safety Settings",
2445
+ description: "Allowlisted Google safety settings."
2446
+ }),
2447
+ tools: zod.z.array(
2448
+ zod.z.strictObject({
2449
+ googleSearch: zod.z.strictObject({}).meta({
2450
+ title: "Google Search",
2451
+ description: "Google Search grounding tool."
2452
+ })
2453
+ })
2454
+ ).min(1).optional().meta({
2455
+ title: "Tools",
2456
+ description: "Allowlisted Google tools for gemma-4-26b-a4b-it."
2457
+ }),
2458
+ httpOptions: zod.z.strictObject({
2459
+ timeout: zod.z.number().int().positive().optional().meta({
2460
+ title: "HTTP Timeout",
2461
+ description: "Per-request Google transport timeout in milliseconds."
2462
+ })
2463
+ }).optional().meta({
2464
+ title: "HTTP Options",
2465
+ description: "Allowlisted Google transport options."
2466
+ })
2467
+ }).optional().meta({
2468
+ title: "Google Provider Options",
2469
+ description: "Allowlisted Google provider options for gemma-4-26b-a4b-it."
2470
+ })
2471
+ }).optional().meta({
2472
+ title: "Provider Options",
2473
+ description: "Provider-specific options accepted for gemma-4-26b-a4b-it."
2474
+ })
2475
+ }).meta({
2476
+ title: "Gemma426bA4bItConfig",
2477
+ description: "Strict generateContent config for model gemma-4-26b-a4b-it. Level reasoning, tunable sampling, no service tier, structured output, grounding, intentionally unpriced.",
2478
+ examples: [{ temperature: 0.7, reasoning: { effort: "none" } }]
2479
+ });
2480
+ var GEMINI_25_PRO_REASONING_EFFORTS = [
2481
+ "low",
2482
+ "medium",
2483
+ "high"
2484
+ ];
2485
+ var GEMINI_LEVEL_REASONING_EFFORTS = [
2486
+ "none",
2487
+ "low",
2488
+ "medium",
2489
+ "high"
2490
+ ];
2491
+ var GEMINI_LEVEL_PRO_PREVIEW_REASONING_EFFORTS = [
2492
+ "low",
2493
+ "medium",
2494
+ "high"
2495
+ ];
2496
+ var GEMINI_25_FLASH_REASONING_EFFORTS = [
2497
+ "none",
2498
+ "low",
2499
+ "medium",
2500
+ "high"
2501
+ ];
2502
+ var GEMMA_REASONING_EFFORTS = [
2503
+ "none",
2504
+ "high"
2505
+ ];
2506
+ var geminiModelDescriptors = [
2507
+ {
2508
+ model: "gemini-2.5-pro",
2509
+ provider: "google",
2510
+ pricingFamily: "gemini-2.5-pro",
2511
+ capabilities: {
2512
+ reasoning: true,
2513
+ structuredOutput: true,
2514
+ nativeStructuredOutput: true,
2515
+ vision: true,
2516
+ reasoningApi: "budget",
2517
+ admittedReasoningEfforts: GEMINI_25_PRO_REASONING_EFFORTS,
2518
+ sampling: "tunable",
2519
+ caching: { explicit: true, minTokens: 2048 },
2520
+ grounding: true,
2521
+ serviceTiers: ["flex", "standard"]
2522
+ },
2523
+ configSchema: Gemini25ProConfigSchema,
2524
+ configJsonSchema: core.toConfigJsonSchema(Gemini25ProConfigSchema),
2525
+ validateConfig: core.zodToStandardSchema(Gemini25ProConfigSchema)
2526
+ },
2527
+ {
2528
+ model: "gemini-2.5-flash",
2529
+ provider: "google",
2530
+ pricingFamily: "gemini-2.5-flash",
2531
+ capabilities: {
2532
+ reasoning: true,
2533
+ structuredOutput: true,
2534
+ nativeStructuredOutput: true,
2535
+ vision: true,
2536
+ reasoningApi: "budget",
2537
+ admittedReasoningEfforts: GEMINI_25_FLASH_REASONING_EFFORTS,
2538
+ sampling: "tunable",
2539
+ caching: { explicit: true, minTokens: 2048 },
2540
+ grounding: true,
2541
+ serviceTiers: ["flex", "standard"]
2542
+ },
2543
+ configSchema: Gemini25FlashConfigSchema,
2544
+ configJsonSchema: core.toConfigJsonSchema(Gemini25FlashConfigSchema),
2545
+ validateConfig: core.zodToStandardSchema(Gemini25FlashConfigSchema)
2546
+ },
2547
+ {
2548
+ model: "gemini-2.5-flash-lite",
2549
+ provider: "google",
2550
+ pricingFamily: "gemini-2.5-flash-lite",
2551
+ capabilities: {
2552
+ reasoning: true,
2553
+ structuredOutput: true,
2554
+ nativeStructuredOutput: true,
2555
+ vision: true,
2556
+ reasoningApi: "budget",
2557
+ admittedReasoningEfforts: GEMINI_25_FLASH_REASONING_EFFORTS,
2558
+ sampling: "tunable",
2559
+ caching: { explicit: true, minTokens: 2048 },
2560
+ grounding: true,
2561
+ serviceTiers: ["flex", "standard"]
2562
+ },
2563
+ configSchema: Gemini25FlashLiteConfigSchema,
2564
+ configJsonSchema: core.toConfigJsonSchema(Gemini25FlashLiteConfigSchema),
2565
+ validateConfig: core.zodToStandardSchema(Gemini25FlashLiteConfigSchema)
2566
+ },
2567
+ {
2568
+ model: "gemini-3.5-flash",
2569
+ provider: "google",
2570
+ pricingFamily: "gemini-3.5-flash",
2571
+ capabilities: {
2572
+ reasoning: true,
2573
+ structuredOutput: true,
2574
+ nativeStructuredOutput: true,
2575
+ vision: true,
2576
+ reasoningApi: "level",
2577
+ admittedReasoningEfforts: GEMINI_LEVEL_REASONING_EFFORTS,
2578
+ sampling: "fixed",
2579
+ caching: { explicit: true, minTokens: 2048 },
2580
+ grounding: true,
2581
+ serviceTiers: ["flex", "standard"]
2582
+ },
2583
+ configSchema: Gemini35FlashConfigSchema,
2584
+ configJsonSchema: core.toConfigJsonSchema(Gemini35FlashConfigSchema),
2585
+ validateConfig: core.zodToStandardSchema(Gemini35FlashConfigSchema)
2586
+ },
2587
+ {
2588
+ model: "gemini-3.1-flash-lite",
2589
+ provider: "google",
2590
+ pricingFamily: "gemini-3.1-flash-lite",
2591
+ capabilities: {
2592
+ reasoning: true,
2593
+ structuredOutput: true,
2594
+ nativeStructuredOutput: true,
2595
+ vision: true,
2596
+ reasoningApi: "level",
2597
+ admittedReasoningEfforts: GEMINI_LEVEL_REASONING_EFFORTS,
2598
+ sampling: "fixed",
2599
+ caching: { explicit: true, minTokens: 2048 },
2600
+ grounding: true,
2601
+ serviceTiers: ["flex", "standard"]
2602
+ },
2603
+ configSchema: Gemini31FlashLiteConfigSchema,
2604
+ configJsonSchema: core.toConfigJsonSchema(Gemini31FlashLiteConfigSchema),
2605
+ validateConfig: core.zodToStandardSchema(Gemini31FlashLiteConfigSchema)
2606
+ },
2607
+ {
2608
+ model: "gemini-3.1-pro-preview",
2609
+ provider: "google",
2610
+ pricingFamily: "gemini-3.1-pro-preview",
2611
+ capabilities: {
2612
+ reasoning: true,
2613
+ structuredOutput: true,
2614
+ nativeStructuredOutput: true,
2615
+ vision: true,
2616
+ reasoningApi: "level",
2617
+ admittedReasoningEfforts: GEMINI_LEVEL_PRO_PREVIEW_REASONING_EFFORTS,
2618
+ sampling: "fixed",
2619
+ caching: { explicit: true, minTokens: 2048 },
2620
+ grounding: true,
2621
+ serviceTiers: ["flex", "standard"]
2622
+ },
2623
+ configSchema: Gemini31ProPreviewConfigSchema,
2624
+ configJsonSchema: core.toConfigJsonSchema(Gemini31ProPreviewConfigSchema),
2625
+ validateConfig: core.zodToStandardSchema(Gemini31ProPreviewConfigSchema)
2626
+ },
2627
+ {
2628
+ model: "gemini-3-flash-preview",
2629
+ provider: "google",
2630
+ pricingFamily: "gemini-3-flash-preview",
2631
+ capabilities: {
2632
+ reasoning: true,
2633
+ structuredOutput: true,
2634
+ nativeStructuredOutput: true,
2635
+ vision: true,
2636
+ reasoningApi: "level",
2637
+ admittedReasoningEfforts: GEMINI_LEVEL_REASONING_EFFORTS,
2638
+ sampling: "fixed",
2639
+ caching: { explicit: true, minTokens: 2048 },
2640
+ grounding: true,
2641
+ serviceTiers: ["flex", "standard"]
2642
+ },
2643
+ configSchema: Gemini3FlashPreviewConfigSchema,
2644
+ configJsonSchema: core.toConfigJsonSchema(Gemini3FlashPreviewConfigSchema),
2645
+ validateConfig: core.zodToStandardSchema(Gemini3FlashPreviewConfigSchema)
2646
+ }
2647
+ ];
2648
+ var gemmaModelDescriptors = [
2649
+ {
2650
+ model: "gemma-4-31b-it",
2651
+ provider: "google",
2652
+ capabilities: {
2653
+ reasoning: true,
2654
+ reasoningApi: "level",
2655
+ admittedReasoningEfforts: GEMMA_REASONING_EFFORTS,
2656
+ structuredOutput: true,
2657
+ nativeStructuredOutput: true,
2658
+ grounding: true,
2659
+ vision: true,
2660
+ sampling: "tunable"
2661
+ },
2662
+ configSchema: Gemma431bItConfigSchema,
2663
+ configJsonSchema: core.toConfigJsonSchema(Gemma431bItConfigSchema),
2664
+ validateConfig: core.zodToStandardSchema(Gemma431bItConfigSchema)
2665
+ },
2666
+ {
2667
+ model: "gemma-4-26b-a4b-it",
2668
+ provider: "google",
2669
+ capabilities: {
2670
+ reasoning: true,
2671
+ reasoningApi: "level",
2672
+ admittedReasoningEfforts: GEMMA_REASONING_EFFORTS,
2673
+ structuredOutput: true,
2674
+ nativeStructuredOutput: true,
2675
+ grounding: true,
2676
+ vision: true,
2677
+ sampling: "tunable"
2678
+ },
2679
+ configSchema: Gemma426bA4bItConfigSchema,
2680
+ configJsonSchema: core.toConfigJsonSchema(Gemma426bA4bItConfigSchema),
2681
+ validateConfig: core.zodToStandardSchema(Gemma426bA4bItConfigSchema)
2682
+ }
2683
+ ];
2684
+ var defaultGeminiRegistry = core.createModelRegistry([
2685
+ ...geminiModelDescriptors,
2686
+ ...gemmaModelDescriptors
2687
+ ]);
2688
+
2689
+ // src/provider.ts
2690
+ function googleProvider(opts) {
2691
+ return {
2692
+ adapter: geminiAdapter(opts),
2693
+ modelDescriptors: [...geminiModelDescriptors, ...gemmaModelDescriptors],
2694
+ pricingSource: geminiPricingSource()
2695
+ };
2696
+ }
677
2697
  var DEFAULT_INTERVAL_MS = 3e3;
678
2698
  var DEFAULT_TIMEOUT_MS = 3e5;
679
2699
  var realSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -775,8 +2795,9 @@ var GoogleFileStore = class {
775
2795
  const { name, uri } = uploadResp;
776
2796
  if (name === void 0 || name.length === 0 || uri === void 0 || uri.length === 0) {
777
2797
  throw new core.LlmError("File upload response missing required fields (name or uri)", {
778
- kind: "bad_request",
779
- retryable: false
2798
+ kind: "server",
2799
+ retryable: false,
2800
+ provider: "google"
780
2801
  });
781
2802
  }
782
2803
  const fallback = { name, uri, mimeType };
@@ -889,6 +2910,7 @@ var GoogleCacheStore = class {
889
2910
  onDeleteError;
890
2911
  logger;
891
2912
  now;
2913
+ preflight;
892
2914
  /** Memoised client promise — built at most once per store instance. */
893
2915
  clientPromise;
894
2916
  /** In-process cache of live handles, keyed by `${model}:${stableKey}`. */
@@ -915,6 +2937,7 @@ var GoogleCacheStore = class {
915
2937
  }
916
2938
  });
917
2939
  this.now = opts.now ?? (() => Date.now());
2940
+ this.preflight = opts.preflight;
918
2941
  }
919
2942
  getClient() {
920
2943
  if (this.clientOverride !== void 0) return Promise.resolve(this.clientOverride);
@@ -934,6 +2957,19 @@ var GoogleCacheStore = class {
934
2957
  * `now + ttlSeconds * 1000`.
935
2958
  */
936
2959
  async create(input) {
2960
+ if (this.preflight !== void 0) {
2961
+ const counted = await this.preflight.countTokens({
2962
+ model: input.model,
2963
+ ...input.contents !== void 0 ? { contents: input.contents } : {},
2964
+ ...input.systemInstruction !== void 0 ? { systemInstruction: input.systemInstruction } : {}
2965
+ });
2966
+ if (counted < this.preflight.minTokens) {
2967
+ throw new core.LlmError(
2968
+ `GoogleCacheStore preflight: counted ${counted} token(s), below the configured minimum of ${this.preflight.minTokens} for model "${input.model}".`,
2969
+ { kind: "bad_request", retryable: false }
2970
+ );
2971
+ }
2972
+ }
937
2973
  const client = await this.getClient();
938
2974
  const config = { ttl: `${input.ttlSeconds}s` };
939
2975
  if (input.contents !== void 0) config.contents = input.contents;
@@ -948,8 +2984,9 @@ var GoogleCacheStore = class {
948
2984
  }
949
2985
  if (resp.name === void 0 || resp.name.length === 0) {
950
2986
  throw new core.LlmError("Cache create response missing required field: name", {
951
- kind: "bad_request",
952
- retryable: false
2987
+ kind: "server",
2988
+ retryable: false,
2989
+ provider: "google"
953
2990
  });
954
2991
  }
955
2992
  const fallbackExpiry = new Date(this.now() + input.ttlSeconds * 1e3);
@@ -1111,16 +3148,195 @@ function normalizeGroundingCitations(groundingMetadata) {
1111
3148
  }
1112
3149
  return citations;
1113
3150
  }
3151
+ function badRequest(message) {
3152
+ return new core.LlmError(message, { kind: "bad_request", retryable: false });
3153
+ }
3154
+ function definedKeys(obj) {
3155
+ return Object.keys(obj).filter(
3156
+ (key) => obj[key] !== void 0
3157
+ );
3158
+ }
3159
+ function mapMediaResolutionLevel(level, location) {
3160
+ switch (level) {
3161
+ case "MEDIA_RESOLUTION_LOW":
3162
+ return "low";
3163
+ case "MEDIA_RESOLUTION_MEDIUM":
3164
+ return "medium";
3165
+ case "MEDIA_RESOLUTION_HIGH":
3166
+ return "high";
3167
+ default:
3168
+ throw badRequest(
3169
+ `${location}: unsupported Part.mediaResolution.level "${level}" \u2014 any-llm only supports MEDIA_RESOLUTION_LOW, MEDIA_RESOLUTION_MEDIUM, MEDIA_RESOLUTION_HIGH.`
3170
+ );
3171
+ }
3172
+ }
3173
+ function convertMediaResolution(mediaResolution, location) {
3174
+ const extraKeys = definedKeys(mediaResolution).filter((key) => key !== "level");
3175
+ if (extraKeys.length > 0) {
3176
+ throw badRequest(
3177
+ `${location}: Part.mediaResolution keys [${extraKeys.join(", ")}] are not representable in any-llm \u2014 only mediaResolution.level is supported.`
3178
+ );
3179
+ }
3180
+ if (mediaResolution.level === void 0) {
3181
+ throw badRequest(
3182
+ `${location}: Part.mediaResolution is present but carries no level \u2014 an explicit-but-empty mediaResolution is ambiguous; set level or omit the field.`
3183
+ );
3184
+ }
3185
+ return mapMediaResolutionLevel(mediaResolution.level, location);
3186
+ }
3187
+ function convertPart(part, location) {
3188
+ const keys = definedKeys(part);
3189
+ const baseKeys = keys.filter(
3190
+ (key) => key === "text" || key === "inlineData" || key === "fileData"
3191
+ );
3192
+ if (baseKeys.length === 0) {
3193
+ if (keys.length === 0) {
3194
+ throw badRequest(
3195
+ `${location}: Part has no recognized fields set (expected exactly one of text, inlineData, fileData).`
3196
+ );
3197
+ }
3198
+ throw badRequest(
3199
+ `${location}: Part keys [${keys.join(", ")}] are not supported by geminiContentToMessages \u2014 only text, inlineData, and fileData parts can be represented in any-llm.`
3200
+ );
3201
+ }
3202
+ if (baseKeys.length > 1) {
3203
+ throw badRequest(
3204
+ `${location}: Part has more than one of text/inlineData/fileData set ([${baseKeys.join(", ")}]) \u2014 geminiContentToMessages requires exactly one.`
3205
+ );
3206
+ }
3207
+ const base = baseKeys[0];
3208
+ const extraKeys = keys.filter(
3209
+ (key) => key !== base && !(base !== "text" && key === "mediaResolution")
3210
+ );
3211
+ if (extraKeys.length > 0) {
3212
+ throw badRequest(
3213
+ `${location}: Part keys [${extraKeys.join(", ")}] cannot be represented in any-llm alongside ${base} \u2014 nothing is silently dropped.`
3214
+ );
3215
+ }
3216
+ if (part.text !== void 0) {
3217
+ return { kind: "text", text: part.text };
3218
+ }
3219
+ if (part.inlineData !== void 0) {
3220
+ const inlineData = part.inlineData;
3221
+ const inlineExtraKeys = definedKeys(inlineData).filter(
3222
+ (key) => key !== "mimeType" && key !== "data"
3223
+ );
3224
+ if (inlineExtraKeys.length > 0) {
3225
+ throw badRequest(
3226
+ `${location}: Part.inlineData keys [${inlineExtraKeys.join(", ")}] are not representable in any-llm.`
3227
+ );
3228
+ }
3229
+ if (inlineData.mimeType === void 0) {
3230
+ throw badRequest(`${location}: Part.inlineData.mimeType is required.`);
3231
+ }
3232
+ if (inlineData.data === void 0) {
3233
+ throw badRequest(`${location}: Part.inlineData.data is required.`);
3234
+ }
3235
+ return {
3236
+ kind: "inline-media",
3237
+ mimeType: inlineData.mimeType,
3238
+ data: inlineData.data,
3239
+ ...part.mediaResolution !== void 0 ? { mediaResolution: convertMediaResolution(part.mediaResolution, location) } : {}
3240
+ };
3241
+ }
3242
+ if (part.fileData !== void 0) {
3243
+ const fileData = part.fileData;
3244
+ const fileExtraKeys = definedKeys(fileData).filter(
3245
+ (key) => key !== "fileUri" && key !== "mimeType"
3246
+ );
3247
+ if (fileExtraKeys.length > 0) {
3248
+ throw badRequest(
3249
+ `${location}: Part.fileData keys [${fileExtraKeys.join(", ")}] are not representable in any-llm.`
3250
+ );
3251
+ }
3252
+ if (fileData.fileUri === void 0) {
3253
+ throw badRequest(`${location}: Part.fileData.fileUri is required.`);
3254
+ }
3255
+ if (fileData.mimeType === void 0) {
3256
+ throw badRequest(`${location}: Part.fileData.mimeType is required.`);
3257
+ }
3258
+ return {
3259
+ kind: "file-uri",
3260
+ uri: fileData.fileUri,
3261
+ mimeType: fileData.mimeType,
3262
+ ...part.mediaResolution !== void 0 ? { mediaResolution: convertMediaResolution(part.mediaResolution, location) } : {}
3263
+ };
3264
+ }
3265
+ throw badRequest(`${location}: Part has no recognized fields set.`);
3266
+ }
3267
+ function convertRole(role, location) {
3268
+ if (role === "user") return "user";
3269
+ if (role === "model") return "assistant";
3270
+ throw badRequest(
3271
+ `${location}: Content.role "${String(role)}" is not supported \u2014 only "user" and "model" are recognized. any-llm never infers a missing role.`
3272
+ );
3273
+ }
3274
+ function convertSystemInstruction(systemInstruction) {
3275
+ if (typeof systemInstruction === "string") {
3276
+ return systemInstruction;
3277
+ }
3278
+ const envelopeExtraKeys = definedKeys(systemInstruction).filter(
3279
+ (key) => key !== "parts"
3280
+ );
3281
+ if (envelopeExtraKeys.length > 0) {
3282
+ throw badRequest(
3283
+ `systemInstruction: Content keys [${envelopeExtraKeys.join(", ")}] are not supported on a system instruction \u2014 only parts is allowed.`
3284
+ );
3285
+ }
3286
+ const parts = systemInstruction.parts ?? [];
3287
+ const textFragments = [];
3288
+ parts.forEach((part, index) => {
3289
+ const keys = definedKeys(part);
3290
+ if (keys.length !== 1 || keys[0] !== "text" || part.text === void 0) {
3291
+ const offending = keys.filter((key) => key !== "text");
3292
+ const named = offending.length > 0 ? offending : keys;
3293
+ throw badRequest(
3294
+ `systemInstruction.parts[${index}]: only text parts are allowed in a system instruction \u2014 part keys [${named.length > 0 ? named.join(", ") : "none"}] are not supported.`
3295
+ );
3296
+ }
3297
+ textFragments.push(part.text);
3298
+ });
3299
+ return textFragments.join("");
3300
+ }
3301
+ function geminiContentToMessages(input) {
3302
+ const system = input.systemInstruction !== void 0 ? convertSystemInstruction(input.systemInstruction) : void 0;
3303
+ const messages = input.contents.map((content, contentIndex) => {
3304
+ const location = `contents[${contentIndex}]`;
3305
+ const envelopeExtraKeys = definedKeys(content).filter(
3306
+ (key) => key !== "role" && key !== "parts"
3307
+ );
3308
+ if (envelopeExtraKeys.length > 0) {
3309
+ throw badRequest(
3310
+ `${location}: Content keys [${envelopeExtraKeys.join(", ")}] are not supported \u2014 only role and parts are allowed.`
3311
+ );
3312
+ }
3313
+ const role = convertRole(content.role, location);
3314
+ const parts = (content.parts ?? []).map(
3315
+ (part, partIndex) => convertPart(part, `${location}.parts[${partIndex}]`)
3316
+ );
3317
+ return { role, parts };
3318
+ });
3319
+ return { ...system !== void 0 ? { system } : {}, messages };
3320
+ }
1114
3321
 
1115
3322
  exports.FLEX_DEFAULT_TIMEOUT_MS = FLEX_DEFAULT_TIMEOUT_MS;
3323
+ exports.GEMINI_PRICING = GEMINI_PRICING;
1116
3324
  exports.GoogleCacheStore = GoogleCacheStore;
1117
3325
  exports.GoogleFileStore = GoogleFileStore;
1118
3326
  exports.STANDARD_DEFAULT_TIMEOUT_MS = STANDARD_DEFAULT_TIMEOUT_MS;
3327
+ exports.TIER_FACTOR = TIER_FACTOR;
1119
3328
  exports.TRANSPORT_TIMEOUT_BUFFER_MS = TRANSPORT_TIMEOUT_BUFFER_MS;
1120
3329
  exports.buildGoogleClient = buildGoogleClient;
3330
+ exports.defaultGeminiRegistry = defaultGeminiRegistry;
1121
3331
  exports.geminiAdapter = geminiAdapter;
3332
+ exports.geminiContentToMessages = geminiContentToMessages;
3333
+ exports.geminiModelDescriptors = geminiModelDescriptors;
3334
+ exports.geminiPricingSource = geminiPricingSource;
3335
+ exports.gemmaModelDescriptors = gemmaModelDescriptors;
3336
+ exports.googleProvider = googleProvider;
1122
3337
  exports.isGeminiCapacityError = isGeminiCapacityError;
1123
3338
  exports.normalizeGroundingCitations = normalizeGroundingCitations;
3339
+ exports.pricingVersion = pricingVersion;
1124
3340
  exports.requireApiKey = requireApiKey;
1125
3341
  //# sourceMappingURL=index.cjs.map
1126
3342
  //# sourceMappingURL=index.cjs.map