@adaline/google 1.16.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,17 +2,17 @@ import { z } from 'zod';
2
2
  import { RangeConfigItem, CHAT_CONFIG, SelectStringConfigItem, PairedSelectConfigItem, SelectBooleanConfigItem, ObjectSchemaConfigItem, ChatModelSchema, EmbeddingModelSchema, MultiStringConfigItem, EMBEDDING_CONFIG, ProviderError, urlWithoutTrailingSlash, InvalidModelRequestError, removeUndefinedEntries, InvalidMessagesError, InvalidConfigError, InvalidToolsError, ModelResponseError, InvalidEmbeddingRequestsError, convertBase64ToUint8Array, isRunningInBrowser } from '@adaline/provider';
3
3
  import { ResponseSchema, SystemRoleLiteral, UserRoleLiteral, AssistantRoleLiteral, ToolRoleLiteral, TextModalityLiteral, ImageModalityLiteral, PdfModalityLiteral, ToolCallModalityLiteral, ToolResponseModalityLiteral, ReasoningModalityLiteral, SearchResultModalityLiteral, ErrorModalityLiteral, EmbeddingTextModalityLiteral, Config, Base64ImageContentTypeLiteral, Message, Tool, createReasoningContent, createTextContent, createToolCallContent, createSearchResultGoogleContent, createSafetyErrorContent, EmbeddingRequests, FloatEmbeddingLiteral, createPartialReasoningMessage, createPartialTextMessage, createPartialToolCallMessage, createPartialSearchResultGoogleMessage, createPartialSafetyErrorMessage } from '@adaline/types';
4
4
 
5
- var Kt=Object.defineProperty,Yt=Object.defineProperties;var Vt=Object.getOwnPropertyDescriptors;var Io=Object.getOwnPropertySymbols;var Wt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var te=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Xt=a=>{throw TypeError(a)};var Lo=(a,e,o)=>e in a?Kt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[e]=o,E=(a,e)=>{for(var o in e||(e={}))Wt.call(e,o)&&Lo(a,o,e[o]);if(Io)for(var o of Io(e))Jt.call(e,o)&&Lo(a,o,e[o]);return a},D=(a,e)=>Yt(a,Vt(e));var R=(a,e,o)=>new Promise((t,s)=>{var p=r=>{try{n(o.next(r));}catch(i){s(i);}},m=r=>{try{n(o.throw(r));}catch(i){s(i);}},n=r=>r.done?t(r.value):Promise.resolve(r.value).then(p,m);n((o=o.apply(a,e)).next());}),No=function(a,e){this[0]=a,this[1]=e;},We=(a,e,o)=>{var t=(m,n,r,i)=>{try{var c=o[m](n),h=(n=c.value)instanceof No,T=c.done;Promise.resolve(h?n[0]:n).then(d=>h?t(m==="return"?m:"next",n[1]?{done:d.done,value:d.value}:d,r,i):r({value:d,done:T})).catch(d=>t("throw",d,r,i));}catch(d){i(d);}},s=m=>p[m]=n=>new Promise((r,i)=>t(m,n,r,i)),p={};return o=o.apply(a,e),p[te("asyncIterator")]=()=>p,s("next"),s("throw"),s("return"),p},Do=a=>{var e=a[te("asyncIterator")],o=!1,t,s={};return e==null?(e=a[te("iterator")](),t=p=>s[p]=m=>e[p](m)):(e=e.call(a),t=p=>s[p]=m=>{if(o){if(o=!1,p==="throw")throw m;return m}return o=!0,{done:!1,value:new No(new Promise(n=>{var r=e[p](m);r instanceof Object||Xt("Object expected"),n(r);}),1)}}),s[te("iterator")]=()=>s,t("next"),"throw"in e?t("throw"):s.throw=p=>{throw p},"return"in e&&t("return"),s};var en=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],on=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Bo=(a,e)=>a.replace(e,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),tn=en.map(a=>({value:a,label:Bo(a,"HARM_CATEGORY_")})),nn=on.map(a=>({value:a,label:Bo(a,"HARM_BLOCK_THRESHOLD_")})),Je=(a,e)=>RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:a,step:.01,default:e}),Xe=a=>RangeConfigItem({param:"maxOutputTokens",title:CHAT_CONFIG.MAX_TOKENS.title,description:CHAT_CONFIG.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),Qe=a=>MultiStringConfigItem({param:"stopSequences",title:CHAT_CONFIG.STOP(a).title,description:CHAT_CONFIG.STOP(a).description,max:a}),Ze=a=>RangeConfigItem({param:"topP",title:CHAT_CONFIG.TOP_P.title,description:CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:a}),ji=a=>RangeConfigItem({param:"topK",title:CHAT_CONFIG.TOP_K.title,description:CHAT_CONFIG.TOP_K.description,min:1,max:40,step:1,default:a}),Ai=RangeConfigItem({param:"frequencyPenalty",title:CHAT_CONFIG.FREQUENCY_PENALTY.title,description:CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),zi=RangeConfigItem({param:"presencePenalty",title:CHAT_CONFIG.PRESENCE_PENALTY.title,description:CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),qi=RangeConfigItem({param:"seed",title:CHAT_CONFIG.SEED.title,description:CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),eo=SelectStringConfigItem({param:"toolChoice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any","none"]}),oo=PairedSelectConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",fields:[{key:"category",label:"Category",choices:tn},{key:"threshold",label:"Threshold",choices:nn}],uniqueByField:"category"}),to=SelectBooleanConfigItem({param:"reasoningEnabled",title:"Reasoning Enabled",description:"Controls whether the model is allowed to think for a longer period of time before generating a response. This can be useful for complex tasks that require more time to think.",default:!1}),no=(a,e)=>RangeConfigItem({param:"thinkingBudget",title:"Thinking budget",description:"Specify the total tokens for thinking (or reasoning), where one token approximates four English characters.",min:a,max:e,step:1,default:0}),io=SelectStringConfigItem({param:"thinkingLevel",title:"Thinking Level",description:"Controls the depth of the model's reasoning process. Higher levels may result in more thorough reasoning but use more tokens.",default:"LOW",choices:["LOW","HIGH"]}),so=SelectBooleanConfigItem({param:"googleSearch",title:"Google Search Tool",description:"Controls whether the model is allowed to use the Google Search tool. Powered by Google.",default:!1});var ne=(a,e,o,t,s)=>z.object({temperature:Je(a,e).schema,maxTokens:Xe(o).schema,stop:Qe(t).schema,topP:Ze(s).schema,toolChoice:eo.schema,safetySettings:oo.schema,googleSearchTool:so.schema}),ie=(a,e,o,t,s)=>({temperature:Je(a,e).def,maxTokens:Xe(o).def,stop:Qe(t).def,topP:Ze(s).def,toolChoice:eo.def,safetySettings:oo.def,googleSearchTool:so.def});var jo=ObjectSchemaConfigItem({param:"response_schema",title:CHAT_CONFIG.RESPONSE_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:ResponseSchema}),Ao=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),ae=(a,e,o,t,s)=>D(E({},ie(a,e,o,t,s)),{responseFormat:Ao.def,responseSchema:jo.def}),re=(a,e,o,t,s)=>ne(a,e,o,t,s).extend({responseFormat:Ao.schema,responseSchema:jo.schema});var zo=(a,e,o,t,s,p,m)=>re(a,e,o,t,s).extend({reasoningEnabled:to.schema,maxReasoningTokens:no(p,m).schema,reasoningEffort:io.schema}),qo=(a,e,o,t,s,p,m)=>D(E({},ae(a,e,o,t,s)),{reasoningEnabled:to.def,maxReasoningTokens:no(p,m).def,reasoningEffort:io.def});var ao=a=>RangeConfigItem({param:"outputDimensionality",title:EMBEDDING_CONFIG.DIMENSIONS.title,description:EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:a,step:1,default:a});var Ko=a=>z.object({dimensions:ao(a).schema}),Yo=a=>({dimensions:ao(a).def});var u={base:(a,e,o,t,s)=>({def:ie(a,e,o,t,s),schema:ne(a,e,o,t,s)}),responseSchema:(a,e,o,t,s)=>({def:ae(a,e,o,t,s),schema:re(a,e,o,t,s)}),reasoning:(a,e,o,t,s,p,m)=>({def:qo(a,e,o,t,s,p,m),schema:zo(a,e,o,t,s,p,m)})},q={base:a=>({def:Yo(a),schema:Ko(a)})};var pn="google",A=class{constructor(){this.version="v1";this.name=pn;this.chatModelFactories={[le]:{model:me,modelOptions:Wo,modelSchema:ro},[de]:{model:pe,modelOptions:Jo,modelSchema:lo},[ce]:{model:ge,modelOptions:Xo,modelSchema:mo},[he]:{model:fe,modelOptions:Qo,modelSchema:po},[ue]:{model:ye,modelOptions:Zo,modelSchema:co},[Ce]:{model:Te,modelOptions:et,modelSchema:go},[Me]:{model:Ge,modelOptions:ot,modelSchema:ho},[be]:{model:Pe,modelOptions:tt,modelSchema:fo},[_e]:{model:Se,modelOptions:nt,modelSchema:uo},[we]:{model:ke,modelOptions:st,modelSchema:Co},[ve]:{model:Fe,modelOptions:rt,modelSchema:Mo},[Re]:{model:xe,modelOptions:at,modelSchema:To},[Ie]:{model:Le,modelOptions:lt,modelSchema:Go},[Ne]:{model:De,modelOptions:mt,modelSchema:bo},[Ue]:{model:$e,modelOptions:dt,modelSchema:Po},[Ee]:{model:Oe,modelOptions:it,modelSchema:yo}};this.embeddingModelFactories={[_o]:{model:Be,modelOptions:pt,modelSchema:So},[Eo]:{model:je,modelOptions:ct,modelSchema:Oo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}chatModel(e){let o=e.modelName;if(!(o in this.chatModelFactories))throw new ProviderError({info:`Google chat model: ${o} not found`,cause:new Error(`Google chat model: ${o} not found, available chat models:
5
+ var en=Object.defineProperty,on=Object.defineProperties;var tn=Object.getOwnPropertyDescriptors;var Bo=Object.getOwnPropertySymbols;var nn=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable;var te=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),an=r=>{throw TypeError(r)};var Ao=(r,e,o)=>e in r?en(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,E=(r,e)=>{for(var o in e||(e={}))nn.call(e,o)&&Ao(r,o,e[o]);if(Bo)for(var o of Bo(e))sn.call(e,o)&&Ao(r,o,e[o]);return r},N=(r,e)=>on(r,tn(e));var R=(r,e,o)=>new Promise((t,s)=>{var c=n=>{try{m(o.next(n));}catch(i){s(i);}},a=n=>{try{m(o.throw(n));}catch(i){s(i);}},m=n=>n.done?t(n.value):Promise.resolve(n.value).then(c,a);m((o=o.apply(r,e)).next());}),jo=function(r,e){this[0]=r,this[1]=e;},Ze=(r,e,o)=>{var t=(a,m,n,i)=>{try{var l=o[a](m),h=(m=l.value)instanceof jo,S=l.done;Promise.resolve(h?m[0]:m).then(p=>h?t(a==="return"?a:"next",m[1]?{done:p.done,value:p.value}:p,n,i):n({value:p,done:S})).catch(p=>t("throw",p,n,i));}catch(p){i(p);}},s=a=>c[a]=m=>new Promise((n,i)=>t(a,m,n,i)),c={};return o=o.apply(r,e),c[te("asyncIterator")]=()=>c,s("next"),s("throw"),s("return"),c},zo=r=>{var e=r[te("asyncIterator")],o=!1,t,s={};return e==null?(e=r[te("iterator")](),t=c=>s[c]=a=>e[c](a)):(e=e.call(r),t=c=>s[c]=a=>{if(o){if(o=!1,c==="throw")throw a;return a}return o=!0,{done:!1,value:new jo(new Promise(m=>{var n=e[c](a);n instanceof Object||an("Object expected"),m(n);}),1)}}),s[te("iterator")]=()=>s,t("next"),"throw"in e?t("throw"):s.throw=c=>{throw c},"return"in e&&t("return"),s};var mn=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],dn=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Ko=(r,e)=>r.replace(e,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),pn=mn.map(r=>({value:r,label:Ko(r,"HARM_CATEGORY_")})),cn=dn.map(r=>({value:r,label:Ko(r,"HARM_BLOCK_THRESHOLD_")})),eo=(r,e)=>RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:r,step:.01,default:e}),oo=r=>RangeConfigItem({param:"maxOutputTokens",title:CHAT_CONFIG.MAX_TOKENS.title,description:CHAT_CONFIG.MAX_TOKENS.description,min:0,max:r,step:1,default:0}),to=r=>MultiStringConfigItem({param:"stopSequences",title:CHAT_CONFIG.STOP(r).title,description:CHAT_CONFIG.STOP(r).description,max:r}),no=r=>RangeConfigItem({param:"topP",title:CHAT_CONFIG.TOP_P.title,description:CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:r}),Zi=r=>RangeConfigItem({param:"topK",title:CHAT_CONFIG.TOP_K.title,description:CHAT_CONFIG.TOP_K.description,min:1,max:40,step:1,default:r}),es=RangeConfigItem({param:"frequencyPenalty",title:CHAT_CONFIG.FREQUENCY_PENALTY.title,description:CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),os=RangeConfigItem({param:"presencePenalty",title:CHAT_CONFIG.PRESENCE_PENALTY.title,description:CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),ts=RangeConfigItem({param:"seed",title:CHAT_CONFIG.SEED.title,description:CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),io=SelectStringConfigItem({param:"toolChoice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any","none"]}),so=PairedSelectConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",fields:[{key:"category",label:"Category",choices:pn},{key:"threshold",label:"Threshold",choices:cn}],uniqueByField:"category"}),ao=SelectBooleanConfigItem({param:"reasoningEnabled",title:"Reasoning Enabled",description:"Controls whether the model is allowed to think for a longer period of time before generating a response. This can be useful for complex tasks that require more time to think.",default:!1}),ro=(r,e)=>RangeConfigItem({param:"thinkingBudget",title:"Thinking budget",description:"Specify the total tokens for thinking (or reasoning), where one token approximates four English characters.",min:r,max:e,step:1,default:0}),lo=SelectStringConfigItem({param:"thinkingLevel",title:"Thinking Level",description:"Controls the depth of the model's reasoning process. Higher levels may result in more thorough reasoning but use more tokens.",default:"LOW",choices:["LOW","HIGH"]}),mo=SelectBooleanConfigItem({param:"googleSearch",title:"Google Search Tool",description:"Controls whether the model is allowed to use the Google Search tool. Powered by Google.",default:!1});var ne=(r,e,o,t,s)=>z.object({temperature:eo(r,e).schema,maxTokens:oo(o).schema,stop:to(t).schema,topP:no(s).schema,toolChoice:io.schema,safetySettings:so.schema,googleSearchTool:mo.schema}),ie=(r,e,o,t,s)=>({temperature:eo(r,e).def,maxTokens:oo(o).def,stop:to(t).def,topP:no(s).def,toolChoice:io.def,safetySettings:so.def,googleSearchTool:mo.def});var Yo=ObjectSchemaConfigItem({param:"response_schema",title:CHAT_CONFIG.RESPONSE_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:ResponseSchema}),Vo=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),ae=(r,e,o,t,s)=>N(E({},ie(r,e,o,t,s)),{responseFormat:Vo.def,responseSchema:Yo.def}),re=(r,e,o,t,s)=>ne(r,e,o,t,s).extend({responseFormat:Vo.schema,responseSchema:Yo.schema});var Wo=(r,e,o,t,s,c,a)=>re(r,e,o,t,s).extend({reasoningEnabled:ao.schema,maxReasoningTokens:ro(c,a).schema,reasoningEffort:lo.schema}),Jo=(r,e,o,t,s,c,a)=>N(E({},ae(r,e,o,t,s)),{reasoningEnabled:ao.def,maxReasoningTokens:ro(c,a).def,reasoningEffort:lo.def});var po=r=>RangeConfigItem({param:"outputDimensionality",title:EMBEDDING_CONFIG.DIMENSIONS.title,description:EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:r,step:1,default:r});var Qo=r=>z.object({dimensions:po(r).schema}),Zo=r=>({dimensions:po(r).def});var f={base:(r,e,o,t,s)=>({def:ie(r,e,o,t,s),schema:ne(r,e,o,t,s)}),responseSchema:(r,e,o,t,s)=>({def:ae(r,e,o,t,s),schema:re(r,e,o,t,s)}),reasoning:(r,e,o,t,s,c,a)=>({def:Jo(r,e,o,t,s,c,a),schema:Wo(r,e,o,t,s,c,a)})},H={base:r=>({def:Zo(r),schema:Qo(r)})};var Mn="google",j=class{constructor(){this.version="v1";this.name=Mn;this.chatModelFactories={[le]:{model:me,modelOptions:ot,modelSchema:co},[de]:{model:pe,modelOptions:tt,modelSchema:go},[ce]:{model:ge,modelOptions:nt,modelSchema:ho},[he]:{model:fe,modelOptions:it,modelSchema:fo},[ue]:{model:ye,modelOptions:st,modelSchema:uo},[Ce]:{model:Me,modelOptions:at,modelSchema:yo},[Te]:{model:Ge,modelOptions:rt,modelSchema:Co},[be]:{model:Pe,modelOptions:lt,modelSchema:Mo},[_e]:{model:Se,modelOptions:mt,modelSchema:To},[Ee]:{model:we,modelOptions:dt,modelSchema:Go},[ve]:{model:Fe,modelOptions:gt,modelSchema:_o},[Ne]:{model:De,modelOptions:ft,modelSchema:Eo},[Le]:{model:Ie,modelOptions:ht,modelSchema:So},[Ue]:{model:$e,modelOptions:ut,modelSchema:wo},[Be]:{model:Ae,modelOptions:yt,modelSchema:Oo},[je]:{model:ze,modelOptions:Ct,modelSchema:ko},[Oe]:{model:ke,modelOptions:pt,modelSchema:bo},[Re]:{model:xe,modelOptions:ct,modelSchema:Po}};this.embeddingModelFactories={[Ro]:{model:qe,modelOptions:Mt,modelSchema:xo},[vo]:{model:He,modelOptions:Tt,modelSchema:Fo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}chatModel(e){let o=e.modelName;if(!(o in this.chatModelFactories))throw new ProviderError({info:`Google chat model: ${o} not found`,cause:new Error(`Google chat model: ${o} not found, available chat models:
6
6
  [${this.chatModelLiterals().join(", ")}]`)});let t=this.chatModelFactories[o].model,s=this.chatModelFactories[o].modelOptions.parse(e);return new t(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,o)=>(e[o]=this.embeddingModelFactories[o].modelSchema,e),{})}embeddingModel(e){let o=e.modelName;if(!(o in this.embeddingModelFactories))throw new ProviderError({info:`Google embedding model: ${o} not found`,cause:new Error(`Google embedding model: ${o} not found, available embedding models:
7
- [${this.embeddingModelLiterals().join(", ")}]`)});let t=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(e);return new t(s)}};A.baseUrl="https://generativelanguage.googleapis.com/v1beta";var C={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var b=z.enum([SystemRoleLiteral,UserRoleLiteral,AssistantRoleLiteral,ToolRoleLiteral]),yn="model",Cn="function",P={system:UserRoleLiteral,user:UserRoleLiteral,assistant:yn,tool:Cn};var _=[TextModalityLiteral,ImageModalityLiteral,PdfModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral,ReasoningModalityLiteral,SearchResultModalityLiteral,ErrorModalityLiteral],S=z.enum([TextModalityLiteral,ImageModalityLiteral,PdfModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral,ReasoningModalityLiteral,SearchResultModalityLiteral,ErrorModalityLiteral]),Es=[TextModalityLiteral],Os=z.enum([TextModalityLiteral]),ws=[TextModalityLiteral,ImageModalityLiteral],ks=z.enum([TextModalityLiteral,ImageModalityLiteral]),Rs=[TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],xs=z.enum([TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]);var Tn=z.object({renderedContent:z.string().optional()}),Mn=z.object({uri:z.string().optional(),title:z.string().optional()}),Gn=z.object({web:Mn.optional()}),bn=z.object({startIndex:z.number().optional(),endIndex:z.number().optional(),text:z.string().optional()}),Pn=z.object({segment:bn.optional(),groundingChunkIndices:z.array(z.number()).optional(),confidenceScores:z.array(z.number()).optional()}),yt=z.object({searchEntryPoint:Tn.optional(),groundingChunks:z.array(Gn).optional(),groundingSupports:z.array(Pn).optional(),webSearchQueries:z.array(z.string()).optional()}),_n=z.object({text:z.string(),thought:z.boolean().optional()}),Sn=z.object({functionCall:z.object({name:z.string(),args:z.record(z.any())}),thoughtSignature:z.string().optional()}),Ct=z.object({candidates:z.array(z.object({content:z.object({role:z.string(),parts:z.array(z.union([_n,Sn]))}).optional(),finishReason:z.string(),index:z.number().optional(),safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string(),blocked:z.boolean().optional()}))),groundingMetadata:yt.optional()})),promptFeedback:z.optional(z.object({safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string()})))})),usageMetadata:z.object({promptTokenCount:z.number(),cachedContentTokenCount:z.number().optional(),candidatesTokenCount:z.number().optional(),totalTokenCount:z.number()}).optional()}),En=z.object({text:z.string(),thought:z.boolean().optional()}),On=z.object({functionCall:z.object({name:z.string(),args:z.record(z.any())}),thoughtSignature:z.string().optional()}),ko=z.object({candidates:z.array(z.object({content:z.object({role:z.string(),parts:z.array(z.union([En,On]))}).optional(),finishReason:z.string().optional(),index:z.number().optional(),safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string(),blocked:z.boolean().optional()}))),groundingMetadata:yt.optional()})),promptFeedback:z.optional(z.object({safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string()})))})),usageMetadata:z.object({promptTokenCount:z.number().optional(),cachedContentTokenCount:z.number().optional(),candidatesTokenCount:z.number().optional(),totalTokenCount:z.number().optional()}).optional()});var _t=z.object({text:z.string().min(1)}),wn=z.object({inline_data:z.object({mime_type:z.string().min(1),data:z.string().base64()})}),kn=z.object({file_data:z.object({mime_type:z.string().min(1),file_uri:z.string().min(1)})}),Rn=z.object({function_call:z.object({name:z.string().min(1),args:z.record(z.string().min(1))}),thought_signature:z.string().optional()}),xn=z.object({function_response:z.object({name:z.string().min(1),response:z.record(z.string().min(1))})}),Tt=z.object({text:z.string(),thought:z.literal(!0),thought_signature:z.string().min(1)}),vn=z.object({role:z.enum(["user","model","function"]),parts:z.array(z.union([_t,wn,kn,Rn,xn,Tt,Tt]))}),Mt=z.object({parts:z.array(_t)}),Fn=z.object({name:z.string().min(1),description:z.string().min(1),parameters:z.any()}),In=z.object({timeRangeFilter:z.object({startTime:z.string().datetime().optional(),endTime:z.string().datetime().optional()}).optional()}),Gt=z.object({function_calling_config:z.object({mode:z.enum(["ANY","AUTO","NONE"]),allowed_function_names:z.array(z.string()).optional()})}),Ln=z.object({thinkingBudget:z.number().optional(),includeThoughts:z.boolean().optional(),thinkingLevel:z.enum(["LOW","HIGH"]).optional()}),bt=z.object({stopSequences:z.array(z.string()).optional(),maxOutputTokens:z.number().optional(),temperature:z.number().optional(),topP:z.number().optional(),topK:z.number().optional(),presencePenalty:z.number().optional(),frequencyPenalty:z.number().optional(),seed:z.number().optional(),thinkingConfig:Ln.optional()}),Pt=z.object({category:z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),St=z.object({model:z.string().min(1).optional(),contents:z.array(vn),systemInstruction:Mt.optional(),system_instruction:Mt.optional(),generationConfig:bt.optional(),generation_config:bt.optional(),safetySettings:z.array(Pt).optional(),safety_settings:z.array(Pt).optional(),tools:z.object({function_declarations:z.array(Fn),google_search:In.optional()}).optional(),toolConfig:Gt.optional(),tool_config:Gt.optional()});var G=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),completeChatUrl:z.string().url().optional(),streamChatUrl:z.string().url().optional()}),M=class{constructor(e,o){this.version="v1";var s;let t=G.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=urlWithoutTrailingSlash((s=t.baseUrl)!=null?s:A.baseUrl),this.completeChatUrl=urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformPdfMessages(e){return R(this,null,function*(){let o=n=>R(this,null,function*(){let r={};isRunningInBrowser()||(r["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let i=yield fetch(n,{headers:r});if(!i.ok)throw new InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${i.status}: ${i.statusText}`)});let c=yield i.arrayBuffer();return new Uint8Array(c)}),t=n=>R(this,null,function*(){try{let r=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return null;let h=((yield r.json()).files||[]).find(T=>T.displayName===n);return h?h.uri:null}catch(r){return null}}),s=(n,r)=>R(this,null,function*(){let i=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":n.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:r}})});if(!i.ok)throw new InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${i.status}: ${i.statusText}`)});let c=i.headers.get("x-goog-upload-url");if(!c)throw new InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};isRunningInBrowser()||(h["Content-Length"]=n.length.toString());let T=yield fetch(c,{method:"POST",headers:h,body:n});if(!T.ok)throw new InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${T.status}: ${T.statusText}`)});return (yield T.json()).file.uri}),p=n=>R(this,null,function*(){let r=yield t(n.file.id);if(r)return r;let i;if(n.value.type==="url")i=yield o(n.value.url);else {let c=n.value.base64,h="data:application/pdf;base64,";c=c.startsWith(h)?c.substring(h.length):c,i=convertBase64ToUint8Array(c);}return yield s(i,n.file.id)}),m=[];for(let n of e){let r=[];for(let i of n.content)if(i.modality===PdfModalityLiteral){let c=yield p(i);r.push(D(E({},i),{value:{type:"url",url:c}}));}else r.push(i);m.push(D(E({},n),{content:r}));}return m})}transformModelRequest(e){let o=St.safeParse(e);if(!o.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model;if(t.system_instruction&&t.systemInstruction)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(t.generation_config&&t.generationConfig)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(t.tool_config&&t.toolConfig)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let p=t.system_instruction||t.systemInstruction,m=t.generation_config||t.generationConfig,n=t.safety_settings||t.safetySettings,r=t.tool_config||t.toolConfig;if(r&&(!t.tools||t.tools.function_declarations.length===0))throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let i={};r&&(r.function_calling_config.mode==="ANY"&&r.function_calling_config.allowed_function_names&&r.function_calling_config.allowed_function_names.length===1?i.toolChoice=r.function_calling_config.allowed_function_names[0]:i.toolChoice=r.function_calling_config.mode.toLowerCase()),i.seed=m==null?void 0:m.seed,i.maxTokens=m==null?void 0:m.maxOutputTokens,i.temperature=m==null?void 0:m.temperature,i.topP=m==null?void 0:m.topP,i.presencePenalty=m==null?void 0:m.presencePenalty,i.frequencyPenalty=m==null?void 0:m.frequencyPenalty,i.stop=m==null?void 0:m.stopSequences,i.safetySettings=n;let c=Config().parse(removeUndefinedEntries(i)),h=[];p&&p.parts.forEach(d=>{h.push({role:SystemRoleLiteral,content:[{modality:TextModalityLiteral,value:d.text}]});}),t.contents.forEach(d=>{let f=d.role;switch(f){case"user":{let w=d.parts.map(O=>"text"in O?{modality:TextModalityLiteral,value:O.text}:{modality:ImageModalityLiteral,detail:"auto",value:{type:Base64ImageContentTypeLiteral,base64:O.inline_data.data,mediaType:O.inline_data.mime_type.split("/")[1]}});h.push({role:f,content:w});}break;case"model":{let w=d.parts.map((O,k)=>"text"in O?{modality:TextModalityLiteral,value:O.text}:{modality:ToolCallModalityLiteral,id:k.toString(),index:k,name:O.function_call.name,arguments:JSON.stringify(O.function_call.args)});h.push({role:AssistantRoleLiteral,content:w});}break;case"function":{let w=d.parts.map((O,k)=>({modality:ToolResponseModalityLiteral,id:k.toString(),index:k,name:O.function_response.name,data:JSON.stringify(O.function_response.response)}));h.push({role:ToolRoleLiteral,content:w});}break;default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${d.role}' is not supported for model : ${this.modelName}`)})}});let T=[];return t.tools&&t.tools.function_declarations.forEach(d=>{T.push({type:"function",definition:{schema:{name:d.name,description:d.description,parameters:d.parameters}}});}),{modelName:s,config:c,messages:h,tools:T.length>0?T:void 0}}transformConfig(e,o,t){let s=e.toolChoice;delete e.toolChoice;let p=this.modelSchema.config.schema.safeParse(e);if(!p.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:p.error});let m=p.data;Object.keys(m).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
8
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let n=Object.keys(m).reduce((c,h)=>{let T=this.modelSchema.config.def[h],d=T.param,f=m[h];return h==="reasoningEnabled"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?D(E({},c.thinkingConfig),{includeThoughts:f}):{includeThoughts:f}:h==="maxReasoningTokens"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?D(E({},c.thinkingConfig),{thinkingBudget:f}):{thinkingBudget:f}:h==="reasoningEffort"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?D(E({},c.thinkingConfig),{thinkingLevel:f}):{thinkingLevel:f}:d==="maxOutputTokens"&&T.type==="range"&&f===0?c[d]=T.max:c[d]=f,c},{});if(n.thinkingConfig&&typeof n.thinkingConfig=="object"&&"thinkingBudget"in n.thinkingConfig&&"thinkingLevel"in n.thinkingConfig&&n.thinkingConfig.thinkingBudget!==void 0&&n.thinkingConfig.thinkingBudget!==0&&n.thinkingConfig.thinkingLevel!==void 0)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("Only one of 'thinkingBudget' or 'thinkingLevel' can be set, not both.")});let r=n.safetySettings;delete n.safetySettings,delete n.googleSearch;let i;if(s!==void 0){let c=s;if(!t||t&&t.length===0)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(c))c==="any"?i={function_calling_config:{mode:"ANY",allowed_function_names:t.map(T=>T.definition.schema.name)}}:i={function_calling_config:{mode:c.toUpperCase()}};else if(t.map(T=>T.definition.schema.name).includes(c))i={function_calling_config:{mode:"ANY",allowed_function_names:[c]}};else throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${c}' is not part of provided 'tools' names or
9
- one of [${h.choices.join(", ")}]`)})}}if("response_format"in n&&n.response_format!==void 0){let c=n.response_format;if(c==="json_schema"){let h=n.response_schema;if(!("response_schema"in n)||!n.response_schema||!(h!=null&&h.schema))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});n.responseSchema=h.schema,n.responseMimeType="application/json","additionalProperties"in h.schema&&delete n.responseSchema.additionalProperties,delete n.response_format,delete n.response_schema;}else c==="json_object"?(n.responseSchema={type:"object"},delete n.response_format):c==="text"&&delete n.response_format;}return E(E({generation_config:n},i?{tool_config:i}:{}),r?{safety_settings:r}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=n=>{let r=n.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return r?n.substring(r[0].length):n},t=e.map(n=>{let r=Message().safeParse(n);if(!r.success)throw new InvalidMessagesError({info:"Invalid messages",cause:r.error});return r.data});t.forEach(n=>{n.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}',
7
+ [${this.embeddingModelLiterals().join(", ")}]`)});let t=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(e);return new t(s)}};j.baseUrl="https://generativelanguage.googleapis.com/v1beta";var C={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var G=z.enum([SystemRoleLiteral,UserRoleLiteral,AssistantRoleLiteral,ToolRoleLiteral]),Sn="model",En="function",b={system:UserRoleLiteral,user:UserRoleLiteral,assistant:Sn,tool:En};var P=[TextModalityLiteral,ImageModalityLiteral,PdfModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral,ReasoningModalityLiteral,SearchResultModalityLiteral,ErrorModalityLiteral],_=z.enum([TextModalityLiteral,ImageModalityLiteral,PdfModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral,ReasoningModalityLiteral,SearchResultModalityLiteral,ErrorModalityLiteral]),Us=[TextModalityLiteral],$s=z.enum([TextModalityLiteral]),Bs=[TextModalityLiteral,ImageModalityLiteral],As=z.enum([TextModalityLiteral,ImageModalityLiteral]),js=[TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],zs=z.enum([TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]);var wn=z.object({renderedContent:z.string().optional()}),On=z.object({uri:z.string().optional(),title:z.string().optional()}),kn=z.object({web:On.optional()}),Rn=z.object({startIndex:z.number().optional(),endIndex:z.number().optional(),text:z.string().optional()}),xn=z.object({segment:Rn.optional(),groundingChunkIndices:z.array(z.number()).optional(),confidenceScores:z.array(z.number()).optional()}),St=z.object({searchEntryPoint:wn.optional(),groundingChunks:z.array(kn).optional(),groundingSupports:z.array(xn).optional(),webSearchQueries:z.array(z.string()).optional()}),vn=z.object({text:z.string(),thought:z.boolean().optional()}),Fn=z.object({functionCall:z.object({name:z.string(),args:z.record(z.any())}),thoughtSignature:z.string().optional()}),Et=z.object({candidates:z.array(z.object({content:z.object({role:z.string(),parts:z.array(z.union([vn,Fn]))}).optional(),finishReason:z.string(),index:z.number().optional(),safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string(),blocked:z.boolean().optional()}))),groundingMetadata:St.optional()})),promptFeedback:z.optional(z.object({safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string()})))})),usageMetadata:z.object({promptTokenCount:z.number(),cachedContentTokenCount:z.number().optional(),candidatesTokenCount:z.number().optional(),totalTokenCount:z.number()}).optional()}),Ln=z.object({text:z.string(),thought:z.boolean().optional()}),In=z.object({functionCall:z.object({name:z.string(),args:z.record(z.any())}),thoughtSignature:z.string().optional()}),Io=z.object({candidates:z.array(z.object({content:z.object({role:z.string(),parts:z.array(z.union([Ln,In]))}).optional(),finishReason:z.string().optional(),index:z.number().optional(),safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string(),blocked:z.boolean().optional()}))),groundingMetadata:St.optional()})),promptFeedback:z.optional(z.object({safetyRatings:z.optional(z.array(z.object({category:z.string(),probability:z.string()})))})),usageMetadata:z.object({promptTokenCount:z.number().optional(),cachedContentTokenCount:z.number().optional(),candidatesTokenCount:z.number().optional(),totalTokenCount:z.number().optional()}).optional()});var vt=z.object({text:z.string().min(1)}),Nn=z.object({inline_data:z.object({mime_type:z.string().min(1),data:z.string().base64()})}),Dn=z.object({file_data:z.object({mime_type:z.string().min(1),file_uri:z.string().min(1)})}),Un=z.object({function_call:z.object({name:z.string().min(1),args:z.record(z.string().min(1))}),thought_signature:z.string().optional()}),$n=z.object({function_response:z.object({name:z.string().min(1),response:z.record(z.string().min(1))})}),wt=z.object({text:z.string(),thought:z.literal(!0),thought_signature:z.string().min(1)}),Bn=z.object({role:z.enum(["user","model","function"]),parts:z.array(z.union([vt,Nn,Dn,Un,$n,wt,wt]))}),Ot=z.object({parts:z.array(vt)}),An=z.object({name:z.string().min(1),description:z.string().min(1),parameters:z.any()}),jn=z.object({timeRangeFilter:z.object({startTime:z.string().datetime().optional(),endTime:z.string().datetime().optional()}).optional()}),kt=z.object({function_calling_config:z.object({mode:z.enum(["ANY","AUTO","NONE"]),allowed_function_names:z.array(z.string()).optional()})}),zn=z.object({thinkingBudget:z.number().optional(),includeThoughts:z.boolean().optional(),thinkingLevel:z.enum(["LOW","HIGH"]).optional()}),Rt=z.object({stopSequences:z.array(z.string()).optional(),maxOutputTokens:z.number().optional(),temperature:z.number().optional(),topP:z.number().optional(),topK:z.number().optional(),presencePenalty:z.number().optional(),frequencyPenalty:z.number().optional(),seed:z.number().optional(),thinkingConfig:zn.optional()}),xt=z.object({category:z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),Ft=z.object({model:z.string().min(1).optional(),contents:z.array(Bn),systemInstruction:Ot.optional(),system_instruction:Ot.optional(),generationConfig:Rt.optional(),generation_config:Rt.optional(),safetySettings:z.array(xt).optional(),safety_settings:z.array(xt).optional(),tools:z.object({function_declarations:z.array(An),google_search:jn.optional()}).optional(),toolConfig:kt.optional(),tool_config:kt.optional()});var T=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),completeChatUrl:z.string().url().optional(),streamChatUrl:z.string().url().optional()}),M=class{constructor(e,o){this.version="v1";var s;let t=T.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=urlWithoutTrailingSlash((s=t.baseUrl)!=null?s:j.baseUrl),this.completeChatUrl=urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e,o){var a;let s=0,c=m=>{let n=m.match(/^(\d+(?:\.\d+)?)s$/);return n?Math.ceil(parseFloat(n[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((a=m.error)!=null&&a.details&&Array.isArray(m.error.details)){let n=m.error.details.find(i=>i["@type"]==="type.googleapis.com/google.rpc.RetryInfo");n!=null&&n.retryDelay&&(s=c(n.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformPdfMessages(e){return R(this,null,function*(){let o=m=>R(this,null,function*(){let n={};isRunningInBrowser()||(n["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let i=yield fetch(m,{headers:n});if(!i.ok)throw new InvalidMessagesError({info:`Failed to download PDF from URL: ${m}`,cause:new Error(`HTTP ${i.status}: ${i.statusText}`)});let l=yield i.arrayBuffer();return new Uint8Array(l)}),t=m=>R(this,null,function*(){try{let n=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok)return null;let h=((yield n.json()).files||[]).find(S=>S.displayName===m);return h?h.uri:null}catch(n){return null}}),s=(m,n)=>R(this,null,function*(){let i=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":m.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:n}})});if(!i.ok)throw new InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${i.status}: ${i.statusText}`)});let l=i.headers.get("x-goog-upload-url");if(!l)throw new InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};isRunningInBrowser()||(h["Content-Length"]=m.length.toString());let S=yield fetch(l,{method:"POST",headers:h,body:m});if(!S.ok)throw new InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${S.status}: ${S.statusText}`)});return (yield S.json()).file.uri}),c=m=>R(this,null,function*(){let n=yield t(m.file.id);if(n)return n;let i;if(m.value.type==="url")i=yield o(m.value.url);else {let l=m.value.base64,h="data:application/pdf;base64,";l=l.startsWith(h)?l.substring(h.length):l,i=convertBase64ToUint8Array(l);}return yield s(i,m.file.id)}),a=[];for(let m of e){let n=[];for(let i of m.content)if(i.modality===PdfModalityLiteral){let l=yield c(i);n.push(N(E({},i),{value:{type:"url",url:l}}));}else n.push(i);a.push(N(E({},m),{content:n}));}return a})}transformModelRequest(e){let o=Ft.safeParse(e);if(!o.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model;if(t.system_instruction&&t.systemInstruction)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(t.generation_config&&t.generationConfig)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(t.tool_config&&t.toolConfig)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let c=t.system_instruction||t.systemInstruction,a=t.generation_config||t.generationConfig,m=t.safety_settings||t.safetySettings,n=t.tool_config||t.toolConfig;if(n&&(!t.tools||t.tools.function_declarations.length===0))throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let i={};n&&(n.function_calling_config.mode==="ANY"&&n.function_calling_config.allowed_function_names&&n.function_calling_config.allowed_function_names.length===1?i.toolChoice=n.function_calling_config.allowed_function_names[0]:i.toolChoice=n.function_calling_config.mode.toLowerCase()),i.seed=a==null?void 0:a.seed,i.maxTokens=a==null?void 0:a.maxOutputTokens,i.temperature=a==null?void 0:a.temperature,i.topP=a==null?void 0:a.topP,i.presencePenalty=a==null?void 0:a.presencePenalty,i.frequencyPenalty=a==null?void 0:a.frequencyPenalty,i.stop=a==null?void 0:a.stopSequences,i.safetySettings=m;let l=Config().parse(removeUndefinedEntries(i)),h=[];c&&c.parts.forEach(p=>{h.push({role:SystemRoleLiteral,content:[{modality:TextModalityLiteral,value:p.text}]});}),t.contents.forEach(p=>{let u=p.role;switch(u){case"user":{let O=p.parts.map(w=>"text"in w?{modality:TextModalityLiteral,value:w.text}:{modality:ImageModalityLiteral,detail:"auto",value:{type:Base64ImageContentTypeLiteral,base64:w.inline_data.data,mediaType:w.inline_data.mime_type.split("/")[1]}});h.push({role:u,content:O});}break;case"model":{let O=p.parts.map((w,k)=>"text"in w?{modality:TextModalityLiteral,value:w.text}:{modality:ToolCallModalityLiteral,id:k.toString(),index:k,name:w.function_call.name,arguments:JSON.stringify(w.function_call.args)});h.push({role:AssistantRoleLiteral,content:O});}break;case"function":{let O=p.parts.map((w,k)=>({modality:ToolResponseModalityLiteral,id:k.toString(),index:k,name:w.function_response.name,data:JSON.stringify(w.function_response.response)}));h.push({role:ToolRoleLiteral,content:O});}break;default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${p.role}' is not supported for model : ${this.modelName}`)})}});let S=[];return t.tools&&t.tools.function_declarations.forEach(p=>{S.push({type:"function",definition:{schema:{name:p.name,description:p.description,parameters:p.parameters}}});}),{modelName:s,config:l,messages:h,tools:S.length>0?S:void 0}}transformConfig(e,o,t){let s=e.toolChoice;delete e.toolChoice;let c=this.modelSchema.config.schema.safeParse(e);if(!c.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:c.error});let a=c.data;Object.keys(a).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
8
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(a).reduce((l,h)=>{let S=this.modelSchema.config.def[h],p=S.param,u=a[h];return h==="reasoningEnabled"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(E({},l.thinkingConfig),{includeThoughts:u}):{includeThoughts:u}:h==="maxReasoningTokens"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(E({},l.thinkingConfig),{thinkingBudget:u}):{thinkingBudget:u}:h==="reasoningEffort"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(E({},l.thinkingConfig),{thinkingLevel:u}):{thinkingLevel:u}:p==="maxOutputTokens"&&S.type==="range"&&u===0?l[p]=S.max:l[p]=u,l},{});if(m.thinkingConfig&&typeof m.thinkingConfig=="object"&&"thinkingBudget"in m.thinkingConfig&&"thinkingLevel"in m.thinkingConfig&&m.thinkingConfig.thinkingBudget!==void 0&&m.thinkingConfig.thinkingBudget!==0&&m.thinkingConfig.thinkingLevel!==void 0)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("Only one of 'thinkingBudget' or 'thinkingLevel' can be set, not both.")});let n=m.safetySettings;delete m.safetySettings,delete m.googleSearch;let i;if(s!==void 0){let l=s;if(!t||t&&t.length===0)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(l))l==="any"?i={function_calling_config:{mode:"ANY",allowed_function_names:t.map(S=>S.definition.schema.name)}}:i={function_calling_config:{mode:l.toUpperCase()}};else if(t.map(S=>S.definition.schema.name).includes(l))i={function_calling_config:{mode:"ANY",allowed_function_names:[l]}};else throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${l}' is not part of provided 'tools' names or
9
+ one of [${h.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let l=m.response_format;if(l==="json_schema"){let h=m.response_schema;if(!("response_schema"in m)||!m.response_schema||!(h!=null&&h.schema))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});m.responseSchema=this.stripAdditionalProperties(h.schema),m.responseMimeType="application/json",delete m.response_format,delete m.response_schema;}else l==="json_object"?(m.responseSchema={type:"object"},delete m.response_format):l==="text"&&delete m.response_format;}return E(E({generation_config:m},i?{tool_config:i}:{}),n?{safety_settings:n}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=n=>{let i=n.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return i?n.substring(i[0].length):n},t=e.map(n=>{let i=Message().safeParse(n);if(!i.success)throw new InvalidMessagesError({info:"Invalid messages",cause:i.error});return i.data});t.forEach(n=>{n.content.forEach(i=>{if(!this.modelSchema.modalities.includes(i.modality))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${i.modality}',
10
10
  available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
11
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),t.forEach(n=>{n.content=n.content.filter(r=>r.modality!=="error"&&r.modality!=="search-result");});let s={parts:[]},p=[];if(t.forEach(n=>{switch(n.role){case SystemRoleLiteral:n.content.forEach(r=>{if(r.modality===TextModalityLiteral)s.parts.push({text:r.value});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})});break;case AssistantRoleLiteral:{let r=[];n.content.forEach(i=>{if(i.modality===TextModalityLiteral)r.push({text:i.value});else if(i.modality===ToolCallModalityLiteral)r.push(E({function_call:{name:i.name,args:JSON.parse(i.arguments)}},i.thoughtSignature?{thought_signature:i.thoughtSignature}:{}));else if(i.modality===ReasoningModalityLiteral)i.value.type==="thinking"&&i.value.thinking&&r.push({text:i.value.thinking,thought:!0,thought_signature:i.value.signature});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})}),p.push({role:this.modelSchema.roles[n.role],parts:r});}break;case UserRoleLiteral:{let r=[];n.content.forEach(i=>{if(i.modality===TextModalityLiteral)r.push({text:i.value});else if(i.modality===ImageModalityLiteral){if(i.value.type==="base64"){let c=i.value.base64;c=o(c),r.push({inline_data:{mime_type:`image/${i.value.mediaType}`,data:c}});}else if(i.value.type==="url")throw new InvalidMessagesError({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${i.value.type}'`)})}else if(i.modality===PdfModalityLiteral)if(i.value.type==="base64"){let c=i.value.base64;c=o(c),r.push({inline_data:{mime_type:"application/pdf",data:c}});}else i.value.type==="url"&&r.push({file_data:{mime_type:"application/pdf",file_uri:i.value.url}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})}),p.push({role:this.modelSchema.roles[n.role],parts:r});}break;case ToolRoleLiteral:{let r=[];n.content.forEach(i=>{if(i.modality===ToolResponseModalityLiteral)r.push({function_response:{name:i.name,response:JSON.parse(i.data)}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})}),p.push({role:this.modelSchema.roles[n.role],parts:r});}break;default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
12
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),p[0].role!==this.modelSchema.roles[UserRoleLiteral])throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let m=n=>n===this.modelSchema.roles[UserRoleLiteral]||n===this.modelSchema.roles[ToolRoleLiteral]?[this.modelSchema.roles[AssistantRoleLiteral]]:[this.modelSchema.roles[UserRoleLiteral],this.modelSchema.roles[ToolRoleLiteral]];for(let n=1;n<p.length;n++)if(!m(p[n-1].role).includes(p[n].role))throw new InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${p[n].role}' after message with role : '${p[n-1].role}'`)});if(p[p.length-1].role!==this.modelSchema.roles[UserRoleLiteral]&&p[p.length-1].role!==this.modelSchema.roles[ToolRoleLiteral])throw new InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return E({contents:p},s.parts.length>0?{system_instruction:s}:{})}stripAdditionalProperties(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>this.stripAdditionalProperties(t));let o={};for(let[t,s]of Object.entries(e))t!=="additionalProperties"&&(o[t]=this.stripAdditionalProperties(s));return o}transformTools(e,o){if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${ToolCallModalityLiteral}'`)});if((!e||e.length===0)&&!(o!=null&&o.googleSearchTool))return {tools:[]};let s=(e!=null?e:[]).map(p=>{let m=Tool().safeParse(p);if(!m.success)throw new InvalidToolsError({info:"Invalid tools",cause:m.error});return m.data}).map(p=>({name:p.definition.schema.name,description:p.definition.schema.description,parameters:this.stripAdditionalProperties(p.definition.schema.parameters)}));return {tools:[E(E({},s.length>0?{function_declarations:s}:{}),o!=null&&o.googleSearchTool?{google_search:{}}:{})]}}getCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),p=yield this.transformPdfMessages(o),m=this.transformMessages(p);if(m.messages&&m.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=this.transformTools(t||[],e);return E(E(E(E({},this.getDefaultParams()),s),m),n)})}transformCompleteChatResponse(e){var t,s,p,m,n,r;let o=Ct.safeParse(e);if(o.success){if(o.data.candidates.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let i={messages:[],usage:void 0,logProbs:void 0},c=o.data;c.usageMetadata&&(i.usage={promptTokens:c.usageMetadata.promptTokenCount,totalTokens:c.usageMetadata.totalTokenCount,completionTokens:c.usageMetadata.candidatesTokenCount||0});let h=c.candidates[0];if(h.content){let d=h.content.parts.map((f,y)=>{if("text"in f&&f.text!==void 0)return f.thought===!0?createReasoningContent(f.text,""):createTextContent(f.text);if("functionCall"in f&&f.functionCall!==void 0)return createToolCallContent(y,`${f.functionCall.name}_${y}`,f.functionCall.name,JSON.stringify(f.functionCall.args),void 0,f.thoughtSignature)});i.messages.push({role:AssistantRoleLiteral,content:d});}h.groundingMetadata&&(i.messages.length===0?i.messages.push({role:AssistantRoleLiteral,content:[createSearchResultGoogleContent(((t=h.groundingMetadata.webSearchQueries)==null?void 0:t[0])||"",((s=h.groundingMetadata.groundingChunks)==null?void 0:s.map(d=>{var f,y;return {source:d.web?"web":"",url:((f=d.web)==null?void 0:f.uri)||"",title:((y=d.web)==null?void 0:y.title)||""}}))||[],((p=h.groundingMetadata.groundingSupports)==null?void 0:p.map(d=>{var f,y,w;return {text:((f=d.segment)==null?void 0:f.text)||"",responseIndices:d.groundingChunkIndices||[],startIndex:((y=d.segment)==null?void 0:y.startIndex)||void 0,endIndex:((w=d.segment)==null?void 0:w.endIndex)||void 0,confidenceScores:d.confidenceScores||void 0}}))||[])]}):i.messages[0].content.push(createSearchResultGoogleContent(((m=h.groundingMetadata.webSearchQueries)==null?void 0:m[0])||"",((n=h.groundingMetadata.groundingChunks)==null?void 0:n.map(d=>{var f,y;return {source:d.web?"web":"",url:((f=d.web)==null?void 0:f.uri)||"",title:((y=d.web)==null?void 0:y.title)||""}}))||[],((r=h.groundingMetadata.groundingSupports)==null?void 0:r.map(d=>{var f,y,w;return {text:((f=d.segment)==null?void 0:f.text)||"",responseIndices:d.groundingChunkIndices||[],startIndex:((y=d.segment)==null?void 0:y.startIndex)||void 0,endIndex:((w=d.segment)==null?void 0:w.endIndex)||void 0,confidenceScores:d.confidenceScores||void 0}}))||[])));let T=h.safetyRatings;if(T&&T.length>0&&T.forEach(d=>{d.blocked&&(i.messages.length===0?i.messages.push({role:AssistantRoleLiteral,content:[createSafetyErrorContent(d.category,d.probability,d.blocked,`Blocked content for category: ${d.category} with probability: ${d.probability}`)]}):i.messages[0].content.push(createSafetyErrorContent(d.category,d.probability,d.blocked,`Blocked content for category: ${d.category} with probability: ${d.probability}`)));}),i.messages.length>0)return i;if(i.messages.length===0&&h.finishReason==="SAFETY")throw new ModelResponseError({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new ModelResponseError({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),p=yield this.transformPdfMessages(o),m=this.transformMessages(p);if(m.messages&&m.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=this.transformTools(t||[],e);return E(E(E(E({},this.getDefaultParams()),s),m),n)})}transformStreamChatResponseChunk(e,o){return We(this,null,function*(){var s,p,m;let t=(o+e).split(",\r").filter(n=>n.trim()!=="");for(let n of t){let r=n;if(r=r.replace(/\n/g,""),r.startsWith("[")||r.startsWith(",{"))r=r.slice(1);else if(r.endsWith("]")){if(r==="]")return;r=r.slice(0,-1);}let i;try{i=JSON.parse(r);}catch(h){if(h instanceof SyntaxError){o=r;continue}else throw h}o="";let c=ko.safeParse(i);if(c.success){let h={partialMessages:[]},T=c.data;if(T.candidates.length>0){let d=T.candidates[0].content;d&&"parts"in d&&d.parts.length>0&&d.parts.forEach((f,y)=>{if("text"in f&&f.text!==void 0&&(f.thought===!0?h.partialMessages.push(createPartialReasoningMessage(AssistantRoleLiteral,f.text,"")):h.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,f.text))),"functionCall"in f&&f.functionCall!==void 0){let w=f.functionCall;h.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,y,`${w.name}_${y}`,w.name,JSON.stringify(w.args),void 0,f.thoughtSignature));}});}if(T.usageMetadata&&(h.usage={promptTokens:T.usageMetadata.promptTokenCount,completionTokens:T.usageMetadata.candidatesTokenCount,totalTokens:T.usageMetadata.totalTokenCount}),T.candidates.length>0){let d=T.candidates[0];d.groundingMetadata&&h.partialMessages.push(createPartialSearchResultGoogleMessage(AssistantRoleLiteral,((s=d.groundingMetadata.webSearchQueries)==null?void 0:s[0])||"",((p=d.groundingMetadata.groundingChunks)==null?void 0:p.map(y=>{var w,O;return {source:y.web?"web":"",url:((w=y.web)==null?void 0:w.uri)||"",title:((O=y.web)==null?void 0:O.title)||""}}))||[],((m=d.groundingMetadata.groundingSupports)==null?void 0:m.map(y=>{var w,O,k;return {text:((w=y.segment)==null?void 0:w.text)||"",responseIndices:y.groundingChunkIndices||[],startIndex:((O=y.segment)==null?void 0:O.startIndex)||void 0,endIndex:((k=y.segment)==null?void 0:k.endIndex)||void 0,confidenceScores:y.confidenceScores||void 0}}))||[]));let f=d.safetyRatings;f&&f.length>0&&f.forEach(y=>{y.blocked&&h.partialMessages.push(createPartialSafetyErrorMessage(AssistantRoleLiteral,y.category,y.probability,y.blocked,`Blocked content for category: ${y.category} with probability: ${y.probability}`));});}yield {partialResponse:h,buffer:o};}else throw new ModelResponseError({info:"Invalid response from model",cause:c.error})}yield {partialResponse:{partialMessages:[]},buffer:o};})}transformProxyStreamChatResponseChunk(e,o,t,s,p){return We(this,null,function*(){var c,h,T;if((p==null?void 0:p.alt)!=="sse"){yield*Do(this.transformStreamChatResponseChunk(e,o));return}let m=o+e,n=[],r="",i=0;for(;i<m.length;){let d=m.indexOf(`
13
- `,i);if(d===-1){r=m.substring(i);break}else {let f=m.substring(i,d).trim();f&&n.push(f),i=d+1;}}for(let d of n){if(d==="data: [DONE]")return;if(d.startsWith("data: ")){let f=d.substring(6);try{let y=JSON.parse(f),w=ko.safeParse(y);if(w.success){let O={partialMessages:[]},k=w.data;if(k.candidates.length>0){let N=k.candidates[0].content;N&&"parts"in N&&N.parts.length>0&&N.parts.forEach((L,x)=>{if("text"in L&&L.text!==void 0&&(L.thought===!0?O.partialMessages.push(createPartialReasoningMessage(AssistantRoleLiteral,L.text,"")):O.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,L.text))),"functionCall"in L&&L.functionCall!==void 0){let $=L.functionCall;O.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,x,`${$.name}_${x}`,$.name,JSON.stringify($.args),void 0,L.thoughtSignature));}});}if(k.usageMetadata&&k.usageMetadata.totalTokenCount&&k.usageMetadata.promptTokenCount&&k.usageMetadata.candidatesTokenCount&&(O.usage={promptTokens:k.usageMetadata.promptTokenCount,completionTokens:k.usageMetadata.candidatesTokenCount,totalTokens:k.usageMetadata.totalTokenCount}),k.candidates.length>0){let N=k.candidates[0];N.groundingMetadata&&O.partialMessages.push(createPartialSearchResultGoogleMessage(AssistantRoleLiteral,((c=N.groundingMetadata.webSearchQueries)==null?void 0:c[0])||"",((h=N.groundingMetadata.groundingChunks)==null?void 0:h.map(x=>{var $,W;return {source:x.web?"web":"",url:(($=x.web)==null?void 0:$.uri)||"",title:((W=x.web)==null?void 0:W.title)||""}}))||[],((T=N.groundingMetadata.groundingSupports)==null?void 0:T.map(x=>{var $,W,Fo;return {text:(($=x.segment)==null?void 0:$.text)||"",responseIndices:x.groundingChunkIndices||[],startIndex:((W=x.segment)==null?void 0:W.startIndex)||void 0,endIndex:((Fo=x.segment)==null?void 0:Fo.endIndex)||void 0,confidenceScores:x.confidenceScores||void 0}}))||[]));let L=N.safetyRatings;L&&L.length>0&&L.forEach(x=>{x.blocked&&O.partialMessages.push(createPartialSafetyErrorMessage(AssistantRoleLiteral,x.category,x.probability,x.blocked,`Blocked content for category: ${x.category} with probability: ${x.probability}`));});}yield {partialResponse:O,buffer:o};}else throw new ModelResponseError({info:"Invalid response from model",cause:w.error})}catch(y){throw new ModelResponseError({info:`Malformed JSON received in stream: ${f}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}getProxyCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getProxyStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{if(!t||Object.keys(t).length===0){s(this.streamChatUrl);return}let p=new URL(this.streamChatUrl);Object.entries(t).forEach(([m,n])=>{n!=null&&p.searchParams.set(m,n);}),s(p.toString());})})}getProxyCompleteChatHeaders(e,o,t){return R(this,null,function*(){if(!o)return {};let s=E({},o);return delete s.host,delete s["content-length"],s})}getProxyStreamChatHeaders(e,o,t){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,t)})}getModelPricing(){if(!(this.modelName in C))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return C[this.modelName]}};var le="gemini-1.5-flash-001",Yn="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",ro=ChatModelSchema(b,S).parse({name:le,description:Yn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[le]}),Wo=G,me=class extends M{constructor(e){super(ro,e);}};var de="gemini-1.5-flash-002",Wn="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",lo=ChatModelSchema(b,S).parse({name:de,description:Wn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[de]}),Jo=G,pe=class extends M{constructor(e){super(lo,e);}};var ce="gemini-1.5-flash-latest",Xn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",mo=ChatModelSchema(b,S).parse({name:ce,description:Xn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[ce]}),Xo=G,ge=class extends M{constructor(e){super(mo,e);}};var he="gemini-1.5-flash",Zn="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",po=ChatModelSchema(b,S).parse({name:he,description:Zn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[he]}),Qo=G,fe=class extends M{constructor(e){super(po,e);}};var ue="gemini-1.5-pro-001",oi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",co=ChatModelSchema(b,S).parse({name:ue,description:oi,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[ue]}),Zo=G,ye=class extends M{constructor(e){super(co,e);}};var Ce="gemini-1.5-pro-002",ni="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",go=ChatModelSchema(b,S).parse({name:Ce,description:ni,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[Ce]}),et=G,Te=class extends M{constructor(e){super(go,e);}};var Me="gemini-1.5-pro-latest",si="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ho=ChatModelSchema(b,S).parse({name:Me,description:si,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[Me]}),ot=G,Ge=class extends M{constructor(e){super(ho,e);}};var be="gemini-1.5-pro",ri="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",fo=ChatModelSchema(b,S).parse({name:be,description:ri,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[be]}),tt=G,Pe=class extends M{constructor(e){super(fo,e);}};var $t="gemini-2.0-flash-exp",mi="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",di=ChatModelSchema(b,S).parse({name:$t,description:mi,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[$t]}),yr=G,Bt=class extends M{constructor(e){super(di,e);}};var _e="gemini-2.0-flash",ci="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",uo=ChatModelSchema(b,S).parse({name:_e,description:ci,maxInputTokens:1048576,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[_e]}),nt=G,Se=class extends M{constructor(e){super(uo,e);}};var Ee="gemini-2.5-flash-lite",hi="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",yo=ChatModelSchema(b,S).parse({name:Ee,description:hi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.responseSchema(2,1,65536,4,.95).def,schema:u.responseSchema(2,1,65536,4,.95).schema},price:C[Ee]}),it=G,Oe=class extends M{constructor(e){super(yo,e);}};var we="gemini-2.5-flash-preview-04-17",ui="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",Co=ChatModelSchema(b,S).parse({name:we,description:ui,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,24576).def,schema:u.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[we]}),st=G,ke=class extends M{constructor(e){super(Co,e);}};var Re="gemini-2.5-flash",Ci="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",To=ChatModelSchema(b,S).parse({name:Re,description:Ci,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,24576).def,schema:u.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[Re]}),at=G,xe=class extends M{constructor(e){super(To,e);}};var ve="gemini-2.5-pro-preview-03-25",Mi="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Mo=ChatModelSchema(b,S).parse({name:ve,description:Mi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[ve]}),rt=G,Fe=class extends M{constructor(e){super(Mo,e);}};var Ie="gemini-2.5-pro",bi="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Go=ChatModelSchema(b,S).parse({name:Ie,description:bi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ie]}),lt=G,Le=class extends M{constructor(e){super(Go,e);}};var Ne="gemini-3-flash-preview",_i="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",bo=ChatModelSchema(b,S).parse({name:Ne,description:_i,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ne]}),mt=G,De=class extends M{constructor(e){super(bo,e);}};var Ue="gemini-3-pro-preview",Ei="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",Po=ChatModelSchema(b,S).parse({name:Ue,description:Ei,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ue]}),dt=G,$e=class extends M{constructor(e){super(Po,e);}};var Ye=[EmbeddingTextModalityLiteral],Ve=z.enum([EmbeddingTextModalityLiteral]);var At=z.object({embeddings:z.array(z.object({values:z.array(z.number())}))});var wi=z.object({model:z.string().min(1),content:z.object({parts:z.array(z.object({text:z.string().min(1)})).min(1)})}),zt=z.object({model:z.string().min(1).optional(),requests:z.array(wi).min(1),outputDimensionality:z.number().int().min(1).optional()});var oe=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),getEmbeddingsUrl:z.string().url().optional()}),V=class{constructor(e,o){this.version="v1";let t=oe.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=urlWithoutTrailingSlash(t.baseUrl||A.baseUrl),this.getEmbeddingsUrl=urlWithoutTrailingSlash(t.getEmbeddingsUrl||`${this.baseUrl}/models/${this.modelName}:batchEmbedContents?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=zt.safeParse(e);if(!o.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model,p={outputDimensionality:t.outputDimensionality},m=Config().parse(removeUndefinedEntries(p)),n={modality:EmbeddingTextModalityLiteral,requests:t.requests.reduce((r,i)=>(r.push(...i.content.parts.map(c=>c.text)),r),[])};return {modelName:s,config:m,embeddingRequests:n}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:t.error});let s=t.data;return Object.keys(s).forEach(m=>{if(!this.modelSchema.config.def[m])throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${m}',
14
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((m,n)=>{let i=this.modelSchema.config.def[n].param,c=s[n];return m[i]=c,m},{})}transformEmbeddingRequests(e){let o=EmbeddingRequests().safeParse(e);if(!o.success)throw new InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.error});if(e.modality!==EmbeddingTextModalityLiteral)throw new InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${EmbeddingTextModalityLiteral}' modality is supported for model : '${this.modelName}'`)});return {requests:o.data.requests.map(s=>({model:`models/${this.modelName}`,content:{parts:[{text:s}]}}))}}getGetEmbeddingsUrl(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return R(this,null,function*(){return new Promise(t=>{let s=this.transformConfig(e),p=this.transformEmbeddingRequests(o);if(o.requests.length===0)throw new InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});s.outputDimensionality&&(p.requests.forEach(m=>{m.outputDimensionality=s.outputDimensionality;}),delete s.outputDimensionality),t(E(E(E({},this.getDefaultParams()),s),p));})})}transformGetEmbeddingsResponse(e){let o=At.safeParse(e);if(o.success){let s=o.data.embeddings.map((p,m)=>({index:m,embedding:p.values}));return {encodingFormat:FloatEmbeddingLiteral,embeddings:s}}throw new ModelResponseError({info:"Invalid response from model",cause:o.error})}};var _o="text-embedding-001",Ni="text-embedding-001",So=EmbeddingModelSchema(Ve).parse({name:_o,description:Ni,modalities:Ye,maxInputTokens:2048,maxOutputTokens:768,config:{def:q.base(768).def,schema:q.base(768).schema}}),pt=oe,Be=class extends V{constructor(e){super(So,e);}};var Eo="text-embedding-004",Ui="text-embedding-004",Oo=EmbeddingModelSchema(Ve).parse({name:Eo,description:Ui,modalities:Ye,maxInputTokens:2048,maxOutputTokens:768,config:{def:q.base(768).def,schema:q.base(768).schema}}),ct=oe,je=class extends V{constructor(e){super(Oo,e);}};
11
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),t.forEach(n=>{n.content=n.content.filter(i=>i.modality!=="error"&&i.modality!=="search-result");});let s=[];for(let n of t){let i=s[s.length-1];if(n.role===ToolRoleLiteral&&(i==null?void 0:i.role)===ToolRoleLiteral){s[s.length-1]=N(E({},i),{content:[...i.content,...n.content]});continue}s.push(n);}let c={parts:[]},a=[];if(s.forEach(n=>{switch(n.role){case SystemRoleLiteral:n.content.forEach(i=>{if(i.modality===TextModalityLiteral)c.parts.push({text:i.value});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})});break;case AssistantRoleLiteral:{let i=[];n.content.forEach(l=>{if(l.modality===TextModalityLiteral)i.push({text:l.value});else if(l.modality===ToolCallModalityLiteral)i.push(E({function_call:{name:l.name,args:JSON.parse(l.arguments)}},l.thoughtSignature?{thought_signature:l.thoughtSignature}:{}));else if(l.modality===ReasoningModalityLiteral)l.value.type==="thinking"&&l.value.thinking&&i.push({text:l.value.thinking,thought:!0,thought_signature:l.value.signature});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[n.role],parts:i});}break;case UserRoleLiteral:{let i=[];n.content.forEach(l=>{if(l.modality===TextModalityLiteral)i.push({text:l.value});else if(l.modality===ImageModalityLiteral){if(l.value.type==="base64"){let h=l.value.base64;h=o(h),i.push({inline_data:{mime_type:`image/${l.value.mediaType}`,data:h}});}else if(l.value.type==="url")throw new InvalidMessagesError({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${l.value.type}'`)})}else if(l.modality===PdfModalityLiteral)if(l.value.type==="base64"){let h=l.value.base64;h=o(h),i.push({inline_data:{mime_type:"application/pdf",data:h}});}else l.value.type==="url"&&i.push({file_data:{mime_type:"application/pdf",file_uri:l.value.url}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[n.role],parts:i});}break;case ToolRoleLiteral:{let i=[];n.content.forEach(l=>{if(l.modality===ToolResponseModalityLiteral)i.push({function_response:{name:l.name,response:JSON.parse(l.data)}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[n.role],parts:i});}break;default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
12
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[0].role!==this.modelSchema.roles[UserRoleLiteral])throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let m=n=>n===this.modelSchema.roles[UserRoleLiteral]||n===this.modelSchema.roles[ToolRoleLiteral]?[this.modelSchema.roles[AssistantRoleLiteral]]:[this.modelSchema.roles[UserRoleLiteral],this.modelSchema.roles[ToolRoleLiteral]];for(let n=1;n<a.length;n++)if(!m(a[n-1].role).includes(a[n].role))throw new InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[n].role}' after message with role : '${a[n-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[UserRoleLiteral]&&a[a.length-1].role!==this.modelSchema.roles[ToolRoleLiteral])throw new InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return E({contents:a},c.parts.length>0?{system_instruction:c}:{})}stripAdditionalProperties(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>this.stripAdditionalProperties(t));let o={};for(let[t,s]of Object.entries(e))t!=="additionalProperties"&&(o[t]=this.stripAdditionalProperties(s));return o}transformTools(e,o){if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${ToolCallModalityLiteral}'`)});if((!e||e.length===0)&&!(o!=null&&o.googleSearchTool))return {tools:[]};let s=(e!=null?e:[]).map(c=>{let a=Tool().safeParse(c);if(!a.success)throw new InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(c=>({name:c.definition.schema.name,description:c.definition.schema.description,parameters:this.stripAdditionalProperties(c.definition.schema.parameters)}));return {tools:[E(E({},s.length>0?{function_declarations:s}:{}),o!=null&&o.googleSearchTool?{google_search:{}}:{})]}}getCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),c=yield this.transformPdfMessages(o),a=this.transformMessages(c);if(a.messages&&a.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=this.transformTools(t||[],e);return E(E(E(E({},this.getDefaultParams()),s),a),m)})}transformCompleteChatResponse(e){var t,s,c,a,m,n;let o=Et.safeParse(e);if(o.success){if(o.data.candidates.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let i={messages:[],usage:void 0,logProbs:void 0},l=o.data;l.usageMetadata&&(i.usage={promptTokens:l.usageMetadata.promptTokenCount,totalTokens:l.usageMetadata.totalTokenCount,completionTokens:l.usageMetadata.candidatesTokenCount||0});let h=l.candidates[0];if(h.content){let p=h.content.parts.map((u,y)=>{if("text"in u&&u.text!==void 0)return u.thought===!0?createReasoningContent(u.text,""):createTextContent(u.text);if("functionCall"in u&&u.functionCall!==void 0)return createToolCallContent(y,`${u.functionCall.name}_${y}`,u.functionCall.name,JSON.stringify(u.functionCall.args),void 0,u.thoughtSignature)});i.messages.push({role:AssistantRoleLiteral,content:p});}h.groundingMetadata&&(i.messages.length===0?i.messages.push({role:AssistantRoleLiteral,content:[createSearchResultGoogleContent(((t=h.groundingMetadata.webSearchQueries)==null?void 0:t[0])||"",((s=h.groundingMetadata.groundingChunks)==null?void 0:s.map(p=>{var u,y;return {source:p.web?"web":"",url:((u=p.web)==null?void 0:u.uri)||"",title:((y=p.web)==null?void 0:y.title)||""}}))||[],((c=h.groundingMetadata.groundingSupports)==null?void 0:c.map(p=>{var u,y,O;return {text:((u=p.segment)==null?void 0:u.text)||"",responseIndices:p.groundingChunkIndices||[],startIndex:((y=p.segment)==null?void 0:y.startIndex)||void 0,endIndex:((O=p.segment)==null?void 0:O.endIndex)||void 0,confidenceScores:p.confidenceScores||void 0}}))||[])]}):i.messages[0].content.push(createSearchResultGoogleContent(((a=h.groundingMetadata.webSearchQueries)==null?void 0:a[0])||"",((m=h.groundingMetadata.groundingChunks)==null?void 0:m.map(p=>{var u,y;return {source:p.web?"web":"",url:((u=p.web)==null?void 0:u.uri)||"",title:((y=p.web)==null?void 0:y.title)||""}}))||[],((n=h.groundingMetadata.groundingSupports)==null?void 0:n.map(p=>{var u,y,O;return {text:((u=p.segment)==null?void 0:u.text)||"",responseIndices:p.groundingChunkIndices||[],startIndex:((y=p.segment)==null?void 0:y.startIndex)||void 0,endIndex:((O=p.segment)==null?void 0:O.endIndex)||void 0,confidenceScores:p.confidenceScores||void 0}}))||[])));let S=h.safetyRatings;if(S&&S.length>0&&S.forEach(p=>{p.blocked&&(i.messages.length===0?i.messages.push({role:AssistantRoleLiteral,content:[createSafetyErrorContent(p.category,p.probability,p.blocked,`Blocked content for category: ${p.category} with probability: ${p.probability}`)]}):i.messages[0].content.push(createSafetyErrorContent(p.category,p.probability,p.blocked,`Blocked content for category: ${p.category} with probability: ${p.probability}`)));}),i.messages.length>0)return i;if(i.messages.length===0&&h.finishReason==="SAFETY")throw new ModelResponseError({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new ModelResponseError({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),c=yield this.transformPdfMessages(o),a=this.transformMessages(c);if(a.messages&&a.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=this.transformTools(t||[],e);return E(E(E(E({},this.getDefaultParams()),s),a),m)})}transformStreamChatResponseChunk(e,o){return Ze(this,null,function*(){var s,c,a;let t=(o+e).split(",\r").filter(m=>m.trim()!=="");for(let m of t){let n=m;if(n=n.replace(/\n/g,""),n.startsWith("[")||n.startsWith(",{"))n=n.slice(1);else if(n.endsWith("]")){if(n==="]")return;n=n.slice(0,-1);}let i;try{i=JSON.parse(n);}catch(h){if(h instanceof SyntaxError){o=n;continue}else throw h}o="";let l=Io.safeParse(i);if(l.success){let h={partialMessages:[]},S=l.data;if(S.candidates.length>0){let p=S.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((u,y)=>{if("text"in u&&u.text!==void 0&&(u.thought===!0?h.partialMessages.push(createPartialReasoningMessage(AssistantRoleLiteral,u.text,"")):h.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,u.text))),"functionCall"in u&&u.functionCall!==void 0){let O=u.functionCall;h.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,y,`${O.name}_${y}`,O.name,JSON.stringify(O.args),void 0,u.thoughtSignature));}});}if(S.usageMetadata&&(h.usage={promptTokens:S.usageMetadata.promptTokenCount,completionTokens:S.usageMetadata.candidatesTokenCount,totalTokens:S.usageMetadata.totalTokenCount}),S.candidates.length>0){let p=S.candidates[0];p.groundingMetadata&&h.partialMessages.push(createPartialSearchResultGoogleMessage(AssistantRoleLiteral,((s=p.groundingMetadata.webSearchQueries)==null?void 0:s[0])||"",((c=p.groundingMetadata.groundingChunks)==null?void 0:c.map(y=>{var O,w;return {source:y.web?"web":"",url:((O=y.web)==null?void 0:O.uri)||"",title:((w=y.web)==null?void 0:w.title)||""}}))||[],((a=p.groundingMetadata.groundingSupports)==null?void 0:a.map(y=>{var O,w,k;return {text:((O=y.segment)==null?void 0:O.text)||"",responseIndices:y.groundingChunkIndices||[],startIndex:((w=y.segment)==null?void 0:w.startIndex)||void 0,endIndex:((k=y.segment)==null?void 0:k.endIndex)||void 0,confidenceScores:y.confidenceScores||void 0}}))||[]));let u=p.safetyRatings;u&&u.length>0&&u.forEach(y=>{y.blocked&&h.partialMessages.push(createPartialSafetyErrorMessage(AssistantRoleLiteral,y.category,y.probability,y.blocked,`Blocked content for category: ${y.category} with probability: ${y.probability}`));});}yield {partialResponse:h,buffer:o};}else throw new ModelResponseError({info:"Invalid response from model",cause:l.error})}yield {partialResponse:{partialMessages:[]},buffer:o};})}transformProxyStreamChatResponseChunk(e,o,t,s,c){return Ze(this,null,function*(){var l,h,S;if((c==null?void 0:c.alt)!=="sse"){yield*zo(this.transformStreamChatResponseChunk(e,o));return}let a=o+e,m=[],n="",i=0;for(;i<a.length;){let p=a.indexOf(`
13
+ `,i);if(p===-1){n=a.substring(i);break}else {let u=a.substring(i,p).trim();u&&m.push(u),i=p+1;}}for(let p of m){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let u=p.substring(6);try{let y=JSON.parse(u),O=Io.safeParse(y);if(O.success){let w={partialMessages:[]},k=O.data;if(k.candidates.length>0){let D=k.candidates[0].content;D&&"parts"in D&&D.parts.length>0&&D.parts.forEach((I,x)=>{if("text"in I&&I.text!==void 0&&(I.thought===!0?w.partialMessages.push(createPartialReasoningMessage(AssistantRoleLiteral,I.text,"")):w.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,I.text))),"functionCall"in I&&I.functionCall!==void 0){let $=I.functionCall;w.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,x,`${$.name}_${x}`,$.name,JSON.stringify($.args),void 0,I.thoughtSignature));}});}if(k.usageMetadata&&k.usageMetadata.totalTokenCount&&k.usageMetadata.promptTokenCount&&k.usageMetadata.candidatesTokenCount&&(w.usage={promptTokens:k.usageMetadata.promptTokenCount,completionTokens:k.usageMetadata.candidatesTokenCount,totalTokens:k.usageMetadata.totalTokenCount}),k.candidates.length>0){let D=k.candidates[0];D.groundingMetadata&&w.partialMessages.push(createPartialSearchResultGoogleMessage(AssistantRoleLiteral,((l=D.groundingMetadata.webSearchQueries)==null?void 0:l[0])||"",((h=D.groundingMetadata.groundingChunks)==null?void 0:h.map(x=>{var $,J;return {source:x.web?"web":"",url:(($=x.web)==null?void 0:$.uri)||"",title:((J=x.web)==null?void 0:J.title)||""}}))||[],((S=D.groundingMetadata.groundingSupports)==null?void 0:S.map(x=>{var $,J,$o;return {text:(($=x.segment)==null?void 0:$.text)||"",responseIndices:x.groundingChunkIndices||[],startIndex:((J=x.segment)==null?void 0:J.startIndex)||void 0,endIndex:(($o=x.segment)==null?void 0:$o.endIndex)||void 0,confidenceScores:x.confidenceScores||void 0}}))||[]));let I=D.safetyRatings;I&&I.length>0&&I.forEach(x=>{x.blocked&&w.partialMessages.push(createPartialSafetyErrorMessage(AssistantRoleLiteral,x.category,x.probability,x.blocked,`Blocked content for category: ${x.category} with probability: ${x.probability}`));});}yield {partialResponse:w,buffer:o};}else throw new ModelResponseError({info:"Invalid response from model",cause:O.error})}catch(y){throw new ModelResponseError({info:`Malformed JSON received in stream: ${u}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:n};})}getProxyCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getProxyStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{if(!t||Object.keys(t).length===0){s(this.streamChatUrl);return}let c=new URL(this.streamChatUrl);Object.entries(t).forEach(([a,m])=>{m!=null&&c.searchParams.set(a,m);}),s(c.toString());})})}getProxyCompleteChatHeaders(e,o,t){return R(this,null,function*(){if(!o)return {};let s=E({},o);return delete s.host,delete s["content-length"],s})}getProxyStreamChatHeaders(e,o,t){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,t)})}getModelPricing(){if(!(this.modelName in C))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return C[this.modelName]}};var le="gemini-1.5-flash-001",oi="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",co=ChatModelSchema(G,_).parse({name:le,description:oi,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[le]}),ot=T,me=class extends M{constructor(e){super(co,e);}};var de="gemini-1.5-flash-002",ni="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",go=ChatModelSchema(G,_).parse({name:de,description:ni,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[de]}),tt=T,pe=class extends M{constructor(e){super(go,e);}};var ce="gemini-1.5-flash-latest",si="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",ho=ChatModelSchema(G,_).parse({name:ce,description:si,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[ce]}),nt=T,ge=class extends M{constructor(e){super(ho,e);}};var he="gemini-1.5-flash",ri="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",fo=ChatModelSchema(G,_).parse({name:he,description:ri,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[he]}),it=T,fe=class extends M{constructor(e){super(fo,e);}};var ue="gemini-1.5-pro-001",mi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",uo=ChatModelSchema(G,_).parse({name:ue,description:mi,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[ue]}),st=T,ye=class extends M{constructor(e){super(uo,e);}};var Ce="gemini-1.5-pro-002",pi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",yo=ChatModelSchema(G,_).parse({name:Ce,description:pi,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[Ce]}),at=T,Me=class extends M{constructor(e){super(yo,e);}};var Te="gemini-1.5-pro-latest",gi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Co=ChatModelSchema(G,_).parse({name:Te,description:gi,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[Te]}),rt=T,Ge=class extends M{constructor(e){super(Co,e);}};var be="gemini-1.5-pro",fi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Mo=ChatModelSchema(G,_).parse({name:be,description:fi,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[be]}),lt=T,Pe=class extends M{constructor(e){super(Mo,e);}};var Yt="gemini-2.0-flash-exp",yi="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Ci=ChatModelSchema(G,_).parse({name:Yt,description:yi,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[Yt]}),kr=T,Vt=class extends M{constructor(e){super(Ci,e);}};var _e="gemini-2.0-flash",Ti="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",To=ChatModelSchema(G,_).parse({name:_e,description:Ti,maxInputTokens:1048576,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[_e]}),mt=T,Se=class extends M{constructor(e){super(To,e);}};var Ee="gemini-2.0-flash-lite",bi="Google's lightweight Gemini 2.0 Flash Lite model for high-throughput, low-cost text generation and classification workloads.",Go=ChatModelSchema(G,_).parse({name:Ee,description:bi,maxInputTokens:1048576,maxOutputTokens:8192,roles:b,modalities:P,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:C[Ee]}),dt=T,we=class extends M{constructor(e){super(Go,e);}};var Oe="gemini-2.5-flash-lite",_i="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",bo=ChatModelSchema(G,_).parse({name:Oe,description:_i,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:C[Oe]}),pt=T,ke=class extends M{constructor(e){super(bo,e);}};var Re="gemini-2.5-flash-lite-preview-09-2025",Ei="Google's preview Flash Lite variant in the Gemini 2.5 family, optimized for low-latency, high-volume tasks.",Po=ChatModelSchema(G,_).parse({name:Re,description:Ei,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:C[Re]}),ct=T,xe=class extends M{constructor(e){super(Po,e);}};var ve="gemini-2.5-flash-preview-04-17",Oi="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",_o=ChatModelSchema(G,_).parse({name:ve,description:Oi,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[ve]}),gt=T,Fe=class extends M{constructor(e){super(_o,e);}};var Le="gemini-2.5-flash",Ri="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",So=ChatModelSchema(G,_).parse({name:Le,description:Ri,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[Le]}),ht=T,Ie=class extends M{constructor(e){super(So,e);}};var Ne="gemini-2.5-pro-preview-03-25",vi="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Eo=ChatModelSchema(G,_).parse({name:Ne,description:vi,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ne]}),ft=T,De=class extends M{constructor(e){super(Eo,e);}};var Ue="gemini-2.5-pro",Li="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",wo=ChatModelSchema(G,_).parse({name:Ue,description:Li,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ue]}),ut=T,$e=class extends M{constructor(e){super(wo,e);}};var Be="gemini-3-flash-preview",Ni="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",Oo=ChatModelSchema(G,_).parse({name:Be,description:Ni,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Be]}),yt=T,Ae=class extends M{constructor(e){super(Oo,e);}};var je="gemini-3-pro-preview",Ui="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",ko=ChatModelSchema(G,_).parse({name:je,description:Ui,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:P,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[je]}),Ct=T,ze=class extends M{constructor(e){super(ko,e);}};var Xe=[EmbeddingTextModalityLiteral],Qe=z.enum([EmbeddingTextModalityLiteral]);var Jt=z.object({embeddings:z.array(z.object({values:z.array(z.number())}))});var Bi=z.object({model:z.string().min(1),content:z.object({parts:z.array(z.object({text:z.string().min(1)})).min(1)})}),Xt=z.object({model:z.string().min(1).optional(),requests:z.array(Bi).min(1),outputDimensionality:z.number().int().min(1).optional()});var oe=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),getEmbeddingsUrl:z.string().url().optional()}),W=class{constructor(e,o){this.version="v1";let t=oe.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=urlWithoutTrailingSlash(t.baseUrl||j.baseUrl),this.getEmbeddingsUrl=urlWithoutTrailingSlash(t.getEmbeddingsUrl||`${this.baseUrl}/models/${this.modelName}:batchEmbedContents?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e,o){var a;let s=0,c=m=>{let n=m.match(/^(\d+(?:\.\d+)?)s$/);return n?Math.ceil(parseFloat(n[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((a=m.error)!=null&&a.details&&Array.isArray(m.error.details)){let n=m.error.details.find(i=>i["@type"]==="type.googleapis.com/google.rpc.RetryInfo");n!=null&&n.retryDelay&&(s=c(n.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=Xt.safeParse(e);if(!o.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model,c={outputDimensionality:t.outputDimensionality},a=Config().parse(removeUndefinedEntries(c)),m={modality:EmbeddingTextModalityLiteral,requests:t.requests.reduce((n,i)=>(n.push(...i.content.parts.map(l=>l.text)),n),[])};return {modelName:s,config:a,embeddingRequests:m}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:t.error});let s=t.data;return Object.keys(s).forEach(a=>{if(!this.modelSchema.config.def[a])throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${a}',
14
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((a,m)=>{let i=this.modelSchema.config.def[m].param,l=s[m];return a[i]=l,a},{})}transformEmbeddingRequests(e){let o=EmbeddingRequests().safeParse(e);if(!o.success)throw new InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.error});if(e.modality!==EmbeddingTextModalityLiteral)throw new InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${EmbeddingTextModalityLiteral}' modality is supported for model : '${this.modelName}'`)});return {requests:o.data.requests.map(s=>({model:`models/${this.modelName}`,content:{parts:[{text:s}]}}))}}getGetEmbeddingsUrl(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return R(this,null,function*(){return new Promise(t=>{let s=this.transformConfig(e),c=this.transformEmbeddingRequests(o);if(o.requests.length===0)throw new InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});s.outputDimensionality&&(c.requests.forEach(a=>{a.outputDimensionality=s.outputDimensionality;}),delete s.outputDimensionality),t(E(E(E({},this.getDefaultParams()),s),c));})})}transformGetEmbeddingsResponse(e){let o=Jt.safeParse(e);if(o.success){let s=o.data.embeddings.map((c,a)=>({index:a,embedding:c.values}));return {encodingFormat:FloatEmbeddingLiteral,embeddings:s}}throw new ModelResponseError({info:"Invalid response from model",cause:o.error})}};var Ro="text-embedding-001",Vi="text-embedding-001",xo=EmbeddingModelSchema(Qe).parse({name:Ro,description:Vi,modalities:Xe,maxInputTokens:2048,maxOutputTokens:768,config:{def:H.base(768).def,schema:H.base(768).schema}}),Mt=oe,qe=class extends W{constructor(e){super(xo,e);}};var vo="text-embedding-004",Ji="text-embedding-004",Fo=EmbeddingModelSchema(Qe).parse({name:vo,description:Ji,modalities:Xe,maxInputTokens:2048,maxOutputTokens:768,config:{def:H.base(768).def,schema:H.base(768).schema}}),Tt=oe,He=class extends W{constructor(e){super(Fo,e);}};
15
15
 
16
- export { M as BaseChatModel, G as BaseChatModelOptions, V as BaseEmbeddingModel, oe as BaseEmbeddingModelOptions, ie as ChatModelBaseConfigDef, ne as ChatModelBaseConfigSchema, qo as ChatModelReasoningConfigDef, zo as ChatModelReasoningConfigSchema, Yo as EmbeddingModelBaseConfigDef, Ko as EmbeddingModelBaseConfigSchema, en as GOOGLE_SAFETY_CATEGORIES, tn as GOOGLE_SAFETY_CATEGORY_OPTIONS, on as GOOGLE_SAFETY_THRESHOLDS, nn as GOOGLE_SAFETY_THRESHOLD_OPTIONS, fe as Gemini1_5Flash, me as Gemini1_5Flash001, le as Gemini1_5Flash001Literal, Wo as Gemini1_5Flash001Options, ro as Gemini1_5Flash001Schema, pe as Gemini1_5Flash002, de as Gemini1_5Flash002Literal, Jo as Gemini1_5Flash002Options, lo as Gemini1_5Flash002Schema, ge as Gemini1_5FlashLatest, ce as Gemini1_5FlashLatestLiteral, Xo as Gemini1_5FlashLatestOptions, mo as Gemini1_5FlashLatestSchema, he as Gemini1_5FlashLiteral, Qo as Gemini1_5FlashOptions, po as Gemini1_5FlashSchema, Pe as Gemini1_5Pro, ye as Gemini1_5Pro001, ue as Gemini1_5Pro001Literal, Zo as Gemini1_5Pro001Options, co as Gemini1_5Pro001Schema, Te as Gemini1_5Pro002, Ce as Gemini1_5Pro002Literal, et as Gemini1_5Pro002Options, go as Gemini1_5Pro002Schema, Ge as Gemini1_5ProLatest, Me as Gemini1_5ProLatestLiteral, ot as Gemini1_5ProLatestOptions, ho as Gemini1_5ProLatestSchema, be as Gemini1_5ProLiteral, tt as Gemini1_5ProOptions, fo as Gemini1_5ProSchema, Se as Gemini2_0Flash, Bt as Gemini2_0FlashExp, $t as Gemini2_0FlashExpLiteral, yr as Gemini2_0FlashExpOptions, di as Gemini2_0FlashExpSchema, _e as Gemini2_0FlashLiteral, nt as Gemini2_0FlashOptions, uo as Gemini2_0FlashSchema, xe as Gemini2_5Flash, Oe as Gemini2_5FlashLite, Ee as Gemini2_5FlashLiteLiteral, it as Gemini2_5FlashLiteOptions, yo as Gemini2_5FlashLiteSchema, Re as Gemini2_5FlashLiteral, at as Gemini2_5FlashOptions, ke as Gemini2_5FlashPreview0417, we as Gemini2_5FlashPreview0417Literal, st as Gemini2_5FlashPreview0417Options, Co as Gemini2_5FlashPreview0417Schema, To as Gemini2_5FlashSchema, Le as Gemini2_5Pro, Ie as Gemini2_5ProLiteral, lt as Gemini2_5ProOptions, Fe as Gemini2_5ProPreview0325, ve as Gemini2_5ProPreview0325Literal, rt as Gemini2_5ProPreview0325Options, Mo as Gemini2_5ProPreview0325Schema, Go as Gemini2_5ProSchema, De as Gemini3FlashPreview, Ne as Gemini3FlashPreviewLiteral, mt as Gemini3FlashPreviewOptions, bo as Gemini3FlashPreviewSchema, $e as Gemini3ProPreview, Ue as Gemini3ProPreviewLiteral, dt as Gemini3ProPreviewOptions, Po as Gemini3ProPreviewSchema, A as Google, yn as GoogleChatAssistantRoleLiteral, vn as GoogleChatContent, kn as GoogleChatContentPartFileData, Rn as GoogleChatContentPartFunctionCall, xn as GoogleChatContentPartFunctionResponse, wn as GoogleChatContentPartInlineData, _t as GoogleChatContentPartText, Tt as GoogleChatContentPartThinking, bt as GoogleChatGenerationConfig, In as GoogleChatGoogleSearchTool, u as GoogleChatModelConfigs, _ as GoogleChatModelModalities, S as GoogleChatModelModalitiesEnum, ae as GoogleChatModelResponseSchemaConfigDef, re as GoogleChatModelResponseSchemaConfigSchema, b as GoogleChatModelRoles, P as GoogleChatModelRolesMap, Es as GoogleChatModelTextModalities, Os as GoogleChatModelTextModalitiesEnum, Rs as GoogleChatModelTextToolModalities, xs as GoogleChatModelTextToolModalitiesEnum, ws as GoogleChatModelTextVisionModalities, ks as GoogleChatModelTextVisionModalitiesEnum, St as GoogleChatRequest, Pt as GoogleChatSafetySettings, Mt as GoogleChatSystemInstruction, Ln as GoogleChatThinkingConfig, Fn as GoogleChatTool, Gt as GoogleChatToolConfig, Cn as GoogleChatToolRoleLiteral, Ct as GoogleCompleteChatResponse, _n as GoogleCompleteChatTextResponse, Sn as GoogleCompleteChatToolResponse, q as GoogleEmbeddingModelConfigs, Ye as GoogleEmbeddingModelModalities, Ve as GoogleEmbeddingModelModalitiesEnum, zt as GoogleEmbeddingRequest, wi as GoogleEmbeddingRequestInput, At as GoogleGetEmbeddingsResponse, Gn as GoogleGroundingChunk, yt as GoogleGroundingMetadata, Pn as GoogleGroundingSupport, Tn as GoogleSearchEntryPoint, ko as GoogleStreamChatResponse, En as GoogleStreamChatTextResponse, On as GoogleStreamChatToolResponse, pn as ProviderLiteral, Be as Text_Embedding_001, _o as Text_Embedding_001Literal, pt as Text_Embedding_001Options, So as Text_Embedding_001Schema, je as Text_Embedding_004, Eo as Text_Embedding_004Literal, ct as Text_Embedding_004Options, Oo as Text_Embedding_004Schema, ao as dimensions, Ai as frequencyPenalty, so as googleSearchTool, no as maxReasoningTokens, Xe as maxTokens, zi as presencePenalty, io as reasoningEffort, to as reasoningEnabled, oo as safetySettings, qi as seed, Qe as stop, Je as temperature, eo as toolChoice, ji as topK, Ze as topP };
16
+ export { M as BaseChatModel, T as BaseChatModelOptions, W as BaseEmbeddingModel, oe as BaseEmbeddingModelOptions, ie as ChatModelBaseConfigDef, ne as ChatModelBaseConfigSchema, Jo as ChatModelReasoningConfigDef, Wo as ChatModelReasoningConfigSchema, Zo as EmbeddingModelBaseConfigDef, Qo as EmbeddingModelBaseConfigSchema, mn as GOOGLE_SAFETY_CATEGORIES, pn as GOOGLE_SAFETY_CATEGORY_OPTIONS, dn as GOOGLE_SAFETY_THRESHOLDS, cn as GOOGLE_SAFETY_THRESHOLD_OPTIONS, fe as Gemini1_5Flash, me as Gemini1_5Flash001, le as Gemini1_5Flash001Literal, ot as Gemini1_5Flash001Options, co as Gemini1_5Flash001Schema, pe as Gemini1_5Flash002, de as Gemini1_5Flash002Literal, tt as Gemini1_5Flash002Options, go as Gemini1_5Flash002Schema, ge as Gemini1_5FlashLatest, ce as Gemini1_5FlashLatestLiteral, nt as Gemini1_5FlashLatestOptions, ho as Gemini1_5FlashLatestSchema, he as Gemini1_5FlashLiteral, it as Gemini1_5FlashOptions, fo as Gemini1_5FlashSchema, Pe as Gemini1_5Pro, ye as Gemini1_5Pro001, ue as Gemini1_5Pro001Literal, st as Gemini1_5Pro001Options, uo as Gemini1_5Pro001Schema, Me as Gemini1_5Pro002, Ce as Gemini1_5Pro002Literal, at as Gemini1_5Pro002Options, yo as Gemini1_5Pro002Schema, Ge as Gemini1_5ProLatest, Te as Gemini1_5ProLatestLiteral, rt as Gemini1_5ProLatestOptions, Co as Gemini1_5ProLatestSchema, be as Gemini1_5ProLiteral, lt as Gemini1_5ProOptions, Mo as Gemini1_5ProSchema, Se as Gemini2_0Flash, Vt as Gemini2_0FlashExp, Yt as Gemini2_0FlashExpLiteral, kr as Gemini2_0FlashExpOptions, Ci as Gemini2_0FlashExpSchema, we as Gemini2_0FlashLite, Ee as Gemini2_0FlashLiteLiteral, dt as Gemini2_0FlashLiteOptions, Go as Gemini2_0FlashLiteSchema, _e as Gemini2_0FlashLiteral, mt as Gemini2_0FlashOptions, To as Gemini2_0FlashSchema, Ie as Gemini2_5Flash, ke as Gemini2_5FlashLite, Oe as Gemini2_5FlashLiteLiteral, pt as Gemini2_5FlashLiteOptions, xe as Gemini2_5FlashLitePreview092025, Re as Gemini2_5FlashLitePreview092025Literal, ct as Gemini2_5FlashLitePreview092025Options, Po as Gemini2_5FlashLitePreview092025Schema, bo as Gemini2_5FlashLiteSchema, Le as Gemini2_5FlashLiteral, ht as Gemini2_5FlashOptions, Fe as Gemini2_5FlashPreview0417, ve as Gemini2_5FlashPreview0417Literal, gt as Gemini2_5FlashPreview0417Options, _o as Gemini2_5FlashPreview0417Schema, So as Gemini2_5FlashSchema, $e as Gemini2_5Pro, Ue as Gemini2_5ProLiteral, ut as Gemini2_5ProOptions, De as Gemini2_5ProPreview0325, Ne as Gemini2_5ProPreview0325Literal, ft as Gemini2_5ProPreview0325Options, Eo as Gemini2_5ProPreview0325Schema, wo as Gemini2_5ProSchema, Ae as Gemini3FlashPreview, Be as Gemini3FlashPreviewLiteral, yt as Gemini3FlashPreviewOptions, Oo as Gemini3FlashPreviewSchema, ze as Gemini3ProPreview, je as Gemini3ProPreviewLiteral, Ct as Gemini3ProPreviewOptions, ko as Gemini3ProPreviewSchema, j as Google, Sn as GoogleChatAssistantRoleLiteral, Bn as GoogleChatContent, Dn as GoogleChatContentPartFileData, Un as GoogleChatContentPartFunctionCall, $n as GoogleChatContentPartFunctionResponse, Nn as GoogleChatContentPartInlineData, vt as GoogleChatContentPartText, wt as GoogleChatContentPartThinking, Rt as GoogleChatGenerationConfig, jn as GoogleChatGoogleSearchTool, f as GoogleChatModelConfigs, P as GoogleChatModelModalities, _ as GoogleChatModelModalitiesEnum, ae as GoogleChatModelResponseSchemaConfigDef, re as GoogleChatModelResponseSchemaConfigSchema, G as GoogleChatModelRoles, b as GoogleChatModelRolesMap, Us as GoogleChatModelTextModalities, $s as GoogleChatModelTextModalitiesEnum, js as GoogleChatModelTextToolModalities, zs as GoogleChatModelTextToolModalitiesEnum, Bs as GoogleChatModelTextVisionModalities, As as GoogleChatModelTextVisionModalitiesEnum, Ft as GoogleChatRequest, xt as GoogleChatSafetySettings, Ot as GoogleChatSystemInstruction, zn as GoogleChatThinkingConfig, An as GoogleChatTool, kt as GoogleChatToolConfig, En as GoogleChatToolRoleLiteral, Et as GoogleCompleteChatResponse, vn as GoogleCompleteChatTextResponse, Fn as GoogleCompleteChatToolResponse, H as GoogleEmbeddingModelConfigs, Xe as GoogleEmbeddingModelModalities, Qe as GoogleEmbeddingModelModalitiesEnum, Xt as GoogleEmbeddingRequest, Bi as GoogleEmbeddingRequestInput, Jt as GoogleGetEmbeddingsResponse, kn as GoogleGroundingChunk, St as GoogleGroundingMetadata, xn as GoogleGroundingSupport, wn as GoogleSearchEntryPoint, Io as GoogleStreamChatResponse, Ln as GoogleStreamChatTextResponse, In as GoogleStreamChatToolResponse, Mn as ProviderLiteral, qe as Text_Embedding_001, Ro as Text_Embedding_001Literal, Mt as Text_Embedding_001Options, xo as Text_Embedding_001Schema, He as Text_Embedding_004, vo as Text_Embedding_004Literal, Tt as Text_Embedding_004Options, Fo as Text_Embedding_004Schema, po as dimensions, es as frequencyPenalty, mo as googleSearchTool, ro as maxReasoningTokens, oo as maxTokens, os as presencePenalty, lo as reasoningEffort, ao as reasoningEnabled, so as safetySettings, ts as seed, to as stop, eo as temperature, io as toolChoice, Zi as topK, no as topP };
17
17
  //# sourceMappingURL=index.mjs.map
18
18
  //# sourceMappingURL=index.mjs.map