@adaline/google 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,130 +4,138 @@ var zod = require('zod');
4
4
  var provider = require('@adaline/provider');
5
5
  var types = require('@adaline/types');
6
6
 
7
- var ot=Object.defineProperty,tt=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var co=Object.getOwnPropertySymbols;var it=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var X=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),at=s=>{throw TypeError(s)};var go=(s,e,t)=>e in s?ot(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,T=(s,e)=>{for(var t in e||(e={}))it.call(e,t)&&go(s,t,e[t]);if(co)for(var t of co(e))st.call(e,t)&&go(s,t,e[t]);return s},U=(s,e)=>tt(s,nt(e));var R=(s,e,t)=>new Promise((o,n)=>{var a=m=>{try{i(t.next(m));}catch(r){n(r);}},l=m=>{try{i(t.throw(m));}catch(r){n(r);}},i=m=>m.done?o(m.value):Promise.resolve(m.value).then(a,l);i((t=t.apply(s,e)).next());}),ho=function(s,e){this[0]=s,this[1]=e;},De=(s,e,t)=>{var o=(l,i,m,r)=>{try{var p=t[l](i),g=(i=p.value)instanceof ho,P=p.done;Promise.resolve(g?i[0]:i).then(f=>g?o(l==="return"?l:"next",i[1]?{done:f.done,value:f.value}:f,m,r):m({value:f,done:P})).catch(f=>o("throw",f,m,r));}catch(f){r(f);}},n=l=>a[l]=i=>new Promise((m,r)=>o(l,i,m,r)),a={};return t=t.apply(s,e),a[X("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a},fo=s=>{var e=s[X("asyncIterator")],t=!1,o,n={};return e==null?(e=s[X("iterator")](),o=a=>n[a]=l=>e[a](l)):(e=e.call(s),o=a=>n[a]=l=>{if(t){if(t=!1,a==="throw")throw l;return l}return t=!0,{done:!1,value:new ho(new Promise(i=>{var m=e[a](l);m instanceof Object||at("Object expected"),i(m);}),1)}}),n[X("iterator")]=()=>n,o("next"),"throw"in e?o("throw"):n.throw=a=>{throw a},"return"in e&&o("return"),n};var Le=(s,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:s,step:.01,default:e}),$e=s=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:s,step:1,default:0}),Ue=s=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(s).title,description:provider.CHAT_CONFIG.STOP(s).description,max:s}),je=s=>provider.RangeConfigItem({param:"topP",title:provider.CHAT_CONFIG.TOP_P.title,description:provider.CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:s}),En=s=>provider.RangeConfigItem({param:"topK",title:provider.CHAT_CONFIG.TOP_K.title,description:provider.CHAT_CONFIG.TOP_K.description,min:1,max:40,step:1,default:s}),Sn=provider.RangeConfigItem({param:"frequencyPenalty",title:provider.CHAT_CONFIG.FREQUENCY_PENALTY.title,description:provider.CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),Rn=provider.RangeConfigItem({param:"presencePenalty",title:provider.CHAT_CONFIG.PRESENCE_PENALTY.title,description:provider.CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),On=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),qe=provider.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"]}),Be=provider.ObjectSchemaConfigItem({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.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"]),category:zod.z.enum(["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"])}))}),Ae=provider.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});var Q=(s,e,t,o,n)=>zod.z.object({temperature:Le(s,e).schema,maxTokens:$e(t).schema,stop:Ue(o).schema,topP:je(n).schema,toolChoice:qe.schema,safetySettings:Be.schema}),ee=(s,e,t,o,n)=>({temperature:Le(s,e).def,maxTokens:$e(t).def,stop:Ue(o).def,topP:je(n).def,toolChoice:qe.def,safetySettings:Be.def});var uo=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),yo=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),te=(s,e,t,o,n)=>U(T({},ee(s,e,t,o,n)),{responseFormat:yo.def,responseSchema:uo.def}),ne=(s,e,t,o,n)=>Q(s,e,t,o,n).extend({responseFormat:yo.schema,responseSchema:uo.schema});var Co=(s,e,t,o,n)=>ne(s,e,t,o,n).extend({reasoningEnabled:Ae.schema}),To=(s,e,t,o,n)=>U(T({},te(s,e,t,o,n)),{reasoningEnabled:Ae.def});var ze=s=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:s,step:1,default:s});var bo=s=>zod.z.object({dimensions:ze(s).schema}),Go=s=>({dimensions:ze(s).def});var h={base:(s,e,t,o,n)=>({def:ee(s,e,t,o,n),schema:Q(s,e,t,o,n)}),responseSchema:(s,e,t,o,n)=>({def:te(s,e,t,o,n),schema:ne(s,e,t,o,n)}),reasoning:(s,e,t,o,n)=>({def:To(s,e,t,o,n),schema:Co(s,e,t,o,n)})},j={base:s=>({def:Go(s),schema:bo(s)})};var yt="google",$=class{constructor(){this.version="v1";this.name=yt;this.chatModelFactories={[ie]:{model:se,modelOptions:Po,modelSchema:He},[ae]:{model:re,modelOptions:Eo,modelSchema:Ke},[le]:{model:me,modelOptions:So,modelSchema:Ye},[de]:{model:pe,modelOptions:Ro,modelSchema:Ve},[ce]:{model:ge,modelOptions:Oo,modelSchema:Je},[he]:{model:fe,modelOptions:xo,modelSchema:We},[ue]:{model:ye,modelOptions:wo,modelSchema:Xe},[Ce]:{model:Te,modelOptions:ko,modelSchema:Ze},[Me]:{model:be,modelOptions:vo,modelSchema:Qe},[Ge]:{model:_e,modelOptions:No,modelSchema:eo},[Pe]:{model:Ee,modelOptions:Io,modelSchema:oo}};this.embeddingModelFactories={[to]:{model:Se,modelOptions:Fo,modelSchema:no},[io]:{model:Re,modelOptions:Do,modelSchema:so}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new provider.ProviderError({info:`Google chat model: ${t} not found`,cause:new Error(`Google chat model: ${t} not found, available chat models:
7
+ var mt=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var Co=Object.getOwnPropertySymbols;var ct=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var X=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),gt=s=>{throw TypeError(s)};var To=(s,e,t)=>e in s?mt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_=(s,e)=>{for(var t in e||(e={}))ct.call(e,t)&&To(s,t,e[t]);if(Co)for(var t of Co(e))ht.call(e,t)&&To(s,t,e[t]);return s},$=(s,e)=>dt(s,pt(e));var R=(s,e,t)=>new Promise((o,n)=>{var a=m=>{try{i(t.next(m));}catch(r){n(r);}},l=m=>{try{i(t.throw(m));}catch(r){n(r);}},i=m=>m.done?o(m.value):Promise.resolve(m.value).then(a,l);i((t=t.apply(s,e)).next());}),Mo=function(s,e){this[0]=s,this[1]=e;},je=(s,e,t)=>{var o=(l,i,m,r)=>{try{var p=t[l](i),g=(i=p.value)instanceof Mo,P=p.done;Promise.resolve(g?i[0]:i).then(f=>g?o(l==="return"?l:"next",i[1]?{done:f.done,value:f.value}:f,m,r):m({value:f,done:P})).catch(f=>o("throw",f,m,r));}catch(f){r(f);}},n=l=>a[l]=i=>new Promise((m,r)=>o(l,i,m,r)),a={};return t=t.apply(s,e),a[X("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a},bo=s=>{var e=s[X("asyncIterator")],t=!1,o,n={};return e==null?(e=s[X("iterator")](),o=a=>n[a]=l=>e[a](l)):(e=e.call(s),o=a=>n[a]=l=>{if(t){if(t=!1,a==="throw")throw l;return l}return t=!0,{done:!1,value:new Mo(new Promise(i=>{var m=e[a](l);m instanceof Object||gt("Object expected"),i(m);}),1)}}),n[X("iterator")]=()=>n,o("next"),"throw"in e?o("throw"):n.throw=a=>{throw a},"return"in e&&o("return"),n};var qe=(s,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:s,step:.01,default:e}),Be=s=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:s,step:1,default:0}),ze=s=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(s).title,description:provider.CHAT_CONFIG.STOP(s).description,max:s}),Ae=s=>provider.RangeConfigItem({param:"topP",title:provider.CHAT_CONFIG.TOP_P.title,description:provider.CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:s}),Ln=s=>provider.RangeConfigItem({param:"topK",title:provider.CHAT_CONFIG.TOP_K.title,description:provider.CHAT_CONFIG.TOP_K.description,min:1,max:40,step:1,default:s}),Un=provider.RangeConfigItem({param:"frequencyPenalty",title:provider.CHAT_CONFIG.FREQUENCY_PENALTY.title,description:provider.CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),$n=provider.RangeConfigItem({param:"presencePenalty",title:provider.CHAT_CONFIG.PRESENCE_PENALTY.title,description:provider.CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),jn=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),He=provider.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"]}),Ke=provider.ObjectSchemaConfigItem({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.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"]),category:zod.z.enum(["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"])}))}),Ye=provider.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});var Q=(s,e,t,o,n)=>zod.z.object({temperature:qe(s,e).schema,maxTokens:Be(t).schema,stop:ze(o).schema,topP:Ae(n).schema,toolChoice:He.schema,safetySettings:Ke.schema}),ee=(s,e,t,o,n)=>({temperature:qe(s,e).def,maxTokens:Be(t).def,stop:ze(o).def,topP:Ae(n).def,toolChoice:He.def,safetySettings:Ke.def});var Go=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),_o=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),te=(s,e,t,o,n)=>$(_({},ee(s,e,t,o,n)),{responseFormat:_o.def,responseSchema:Go.def}),ne=(s,e,t,o,n)=>Q(s,e,t,o,n).extend({responseFormat:_o.schema,responseSchema:Go.schema});var Po=(s,e,t,o,n)=>ne(s,e,t,o,n).extend({reasoningEnabled:Ye.schema}),So=(s,e,t,o,n)=>$(_({},te(s,e,t,o,n)),{reasoningEnabled:Ye.def});var Ve=s=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:s,step:1,default:s});var Ro=s=>zod.z.object({dimensions:Ve(s).schema}),Oo=s=>({dimensions:Ve(s).def});var h={base:(s,e,t,o,n)=>({def:ee(s,e,t,o,n),schema:Q(s,e,t,o,n)}),responseSchema:(s,e,t,o,n)=>({def:te(s,e,t,o,n),schema:ne(s,e,t,o,n)}),reasoning:(s,e,t,o,n)=>({def:So(s,e,t,o,n),schema:Po(s,e,t,o,n)})},j={base:s=>({def:Oo(s),schema:Ro(s)})};var St="google",U=class{constructor(){this.version="v1";this.name=St;this.chatModelFactories={[ie]:{model:se,modelOptions:wo,modelSchema:Je},[ae]:{model:re,modelOptions:ko,modelSchema:We},[le]:{model:me,modelOptions:vo,modelSchema:Xe},[de]:{model:pe,modelOptions:No,modelSchema:Ze},[ce]:{model:he,modelOptions:Fo,modelSchema:Qe},[ge]:{model:fe,modelOptions:Io,modelSchema:eo},[ue]:{model:ye,modelOptions:Do,modelSchema:oo},[Ce]:{model:Te,modelOptions:Lo,modelSchema:to},[Me]:{model:be,modelOptions:Uo,modelSchema:no},[Ge]:{model:_e,modelOptions:$o,modelSchema:io},[Pe]:{model:Se,modelOptions:jo,modelSchema:so},[Ee]:{model:Re,modelOptions:qo,modelSchema:ao},[Oe]:{model:xe,modelOptions:Bo,modelSchema:ro}};this.embeddingModelFactories={[lo]:{model:we,modelOptions:zo,modelSchema:mo},[po]:{model:ke,modelOptions:Ao,modelSchema:co}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new provider.ProviderError({info:`Google chat model: ${t} not found`,cause:new Error(`Google chat model: ${t} not found, available chat models:
8
8
  [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,n=this.chatModelFactories[t].modelOptions.parse(e);return new o(n)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){let t=e.modelName;if(!(t in this.embeddingModelFactories))throw new provider.ProviderError({info:`Google embedding model: ${t} not found`,cause:new Error(`Google embedding model: ${t} not found, available embedding models:
9
- [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};$.baseUrl="https://generativelanguage.googleapis.com/v1beta";var u={"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}}}]}};var M=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),_t="model",Pt="function",b={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:_t,tool:Pt};var G=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],_=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),di=[types.TextModalityLiteral],pi=zod.z.enum([types.TextModalityLiteral]),ci=[types.TextModalityLiteral,types.ImageModalityLiteral],gi=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),hi=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],fi=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Et=zod.z.object({text:zod.z.string()}),St=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Lo=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Et,St]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Rt=zod.z.object({text:zod.z.string()}),Ot=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),ro=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Rt,Ot]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()});var Bo=zod.z.object({text:zod.z.string().min(1)}),xt=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),wt=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),kt=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),vt=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([Bo,xt,wt,kt]))}),$o=zod.z.object({parts:zod.z.array(Bo)}),Nt=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),Uo=zod.z.object({function_calling_config:zod.z.object({mode:zod.z.enum(["ANY","AUTO","NONE"]),allowed_function_names:zod.z.array(zod.z.string()).optional()})}),jo=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional()}),qo=zod.z.object({category:zod.z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),Ao=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(vt),systemInstruction:$o.optional(),system_instruction:$o.optional(),generationConfig:jo.optional(),generation_config:jo.optional(),safetySettings:zod.z.array(qo).optional(),safety_settings:zod.z.array(qo).optional(),tools:zod.z.object({function_declarations:zod.z.array(Nt)}).optional(),toolConfig:Uo.optional(),tool_config:Uo.optional()});var C=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),y=class{constructor(e,t){this.version="v1";var n;let o=C.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((n=o.baseUrl)!=null?n:$.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.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((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let t=Ao.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model;if(o.system_instruction&&o.systemInstruction)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(o.generation_config&&o.generationConfig)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(o.tool_config&&o.toolConfig)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let a=o.system_instruction||o.systemInstruction,l=o.generation_config||o.generationConfig,i=o.safety_settings||o.safetySettings,m=o.tool_config||o.toolConfig;if(m&&(!o.tools||o.tools.function_declarations.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};m&&(m.function_calling_config.mode==="ANY"&&m.function_calling_config.allowed_function_names&&m.function_calling_config.allowed_function_names.length===1?r.toolChoice=m.function_calling_config.allowed_function_names[0]:r.toolChoice=m.function_calling_config.mode.toLowerCase()),r.seed=l==null?void 0:l.seed,r.maxTokens=l==null?void 0:l.maxOutputTokens,r.temperature=l==null?void 0:l.temperature,r.topP=l==null?void 0:l.topP,r.presencePenalty=l==null?void 0:l.presencePenalty,r.frequencyPenalty=l==null?void 0:l.frequencyPenalty,r.stop=l==null?void 0:l.stopSequences,r.safetySettings=i;let p=types.Config().parse(provider.removeUndefinedEntries(r)),g=[];a&&a.parts.forEach(f=>{g.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:f.text}]});}),o.contents.forEach(f=>{let x=f.role;switch(x){case"user":{let k=f.parts.map(E=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:E.inline_data.data,mediaType:E.inline_data.mime_type.split("/")[1]}});g.push({role:x,content:k});}break;case"model":{let k=f.parts.map((E,N)=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ToolCallModalityLiteral,id:N.toString(),index:N,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});g.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=f.parts.map((E,N)=>({modality:types.ToolResponseModalityLiteral,id:N.toString(),index:N,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));g.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${f.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return o.tools&&o.tools.function_declarations.forEach(f=>{P.push({type:"function",definition:{schema:{name:f.name,description:f.description,parameters:f.parameters}}});}),{modelName:n,config:p,messages:g,tools:P.length>0?P:void 0}}transformConfig(e,t,o){let n=e.toolChoice;delete e.toolChoice;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let l=a.data;Object.keys(l).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
10
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(l).reduce((p,g)=>{let P=this.modelSchema.config.def[g],f=P.param,x=l[g];return g==="reasoningEnabled"?p.thinkingConfig={includeThoughts:x}:g==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?U(T({},p.thinkingConfig),{thinkingBudget:x}):{thinkingBudget:x}:f==="maxOutputTokens"&&P.type==="range"&&x===0?p[f]=P.max:p[f]=x,p},{}),m=i.safetySettings;delete i.safetySettings;let r;if(n!==void 0){let p=n;if(!o||o&&o.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let g=this.modelSchema.config.def.toolChoice;if(g.choices.includes(p))p==="any"?r={function_calling_config:{mode:"ANY",allowed_function_names:o.map(P=>P.definition.schema.name)}}:r={function_calling_config:{mode:p.toUpperCase()}};else if(o.map(P=>P.definition.schema.name).includes(p))r={function_calling_config:{mode:"ANY",allowed_function_names:[p]}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${p}' is not part of provided 'tools' names or
11
- one of [${g.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let p=i.response_format;if(p==="json_schema"){let g=i.response_schema;if(!("response_schema"in i)||!i.response_schema||!(g!=null&&g.schema))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});i.responseSchema=g.schema,i.responseMimeType="application/json","additionalProperties"in g.schema&&delete i.responseSchema.additionalProperties,delete i.response_format,delete i.response_schema;}else p==="json_object"?(i.responseSchema={type:"object"},delete i.response_format):p==="text"&&delete i.response_format;}return T(T({generation_config:i},r?{tool_config:r}:{}),m?{safety_settings:m}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=i=>{let m=i.match(/^data:image\/[a-zA-Z]+;base64,/);return m?i.substring(m[0].length):i},o=e.map(i=>{let m=types.Message().safeParse(i);if(!m.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:m.error});return m.data});o.forEach(i=>{i.content.forEach(m=>{if(!this.modelSchema.modalities.includes(m.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${m.modality}',
9
+ [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};U.baseUrl="https://generativelanguage.googleapis.com/v1beta";var u={"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-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),kt="model",vt="function",M={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:kt,tool:vt};var b=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],G=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),Gi=[types.TextModalityLiteral],_i=zod.z.enum([types.TextModalityLiteral]),Pi=[types.TextModalityLiteral,types.ImageModalityLiteral],Si=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),Ei=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],Ri=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Nt=zod.z.object({text:zod.z.string()}),Ft=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ho=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Nt,Ft]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),It=zod.z.object({text:zod.z.string()}),Dt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),go=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([It,Dt]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()});var Wo=zod.z.object({text:zod.z.string().min(1)}),Lt=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Ut=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),$t=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),jt=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([Wo,Lt,Ut,$t]))}),Ko=zod.z.object({parts:zod.z.array(Wo)}),qt=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),Yo=zod.z.object({function_calling_config:zod.z.object({mode:zod.z.enum(["ANY","AUTO","NONE"]),allowed_function_names:zod.z.array(zod.z.string()).optional()})}),Vo=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional()}),Jo=zod.z.object({category:zod.z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),Xo=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(jt),systemInstruction:Ko.optional(),system_instruction:Ko.optional(),generationConfig:Vo.optional(),generation_config:Vo.optional(),safetySettings:zod.z.array(Jo).optional(),safety_settings:zod.z.array(Jo).optional(),tools:zod.z.object({function_declarations:zod.z.array(qt)}).optional(),toolConfig:Yo.optional(),tool_config:Yo.optional()});var C=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),y=class{constructor(e,t){this.version="v1";var n;let o=C.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((n=o.baseUrl)!=null?n:U.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.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((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let t=Xo.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model;if(o.system_instruction&&o.systemInstruction)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(o.generation_config&&o.generationConfig)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(o.tool_config&&o.toolConfig)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let a=o.system_instruction||o.systemInstruction,l=o.generation_config||o.generationConfig,i=o.safety_settings||o.safetySettings,m=o.tool_config||o.toolConfig;if(m&&(!o.tools||o.tools.function_declarations.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};m&&(m.function_calling_config.mode==="ANY"&&m.function_calling_config.allowed_function_names&&m.function_calling_config.allowed_function_names.length===1?r.toolChoice=m.function_calling_config.allowed_function_names[0]:r.toolChoice=m.function_calling_config.mode.toLowerCase()),r.seed=l==null?void 0:l.seed,r.maxTokens=l==null?void 0:l.maxOutputTokens,r.temperature=l==null?void 0:l.temperature,r.topP=l==null?void 0:l.topP,r.presencePenalty=l==null?void 0:l.presencePenalty,r.frequencyPenalty=l==null?void 0:l.frequencyPenalty,r.stop=l==null?void 0:l.stopSequences,r.safetySettings=i;let p=types.Config().parse(provider.removeUndefinedEntries(r)),g=[];a&&a.parts.forEach(f=>{g.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:f.text}]});}),o.contents.forEach(f=>{let x=f.role;switch(x){case"user":{let k=f.parts.map(S=>"text"in S?{modality:types.TextModalityLiteral,value:S.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:S.inline_data.data,mediaType:S.inline_data.mime_type.split("/")[1]}});g.push({role:x,content:k});}break;case"model":{let k=f.parts.map((S,N)=>"text"in S?{modality:types.TextModalityLiteral,value:S.text}:{modality:types.ToolCallModalityLiteral,id:N.toString(),index:N,name:S.function_call.name,arguments:JSON.stringify(S.function_call.args)});g.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=f.parts.map((S,N)=>({modality:types.ToolResponseModalityLiteral,id:N.toString(),index:N,name:S.function_response.name,data:JSON.stringify(S.function_response.response)}));g.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${f.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return o.tools&&o.tools.function_declarations.forEach(f=>{P.push({type:"function",definition:{schema:{name:f.name,description:f.description,parameters:f.parameters}}});}),{modelName:n,config:p,messages:g,tools:P.length>0?P:void 0}}transformConfig(e,t,o){let n=e.toolChoice;delete e.toolChoice;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let l=a.data;Object.keys(l).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
10
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(l).reduce((p,g)=>{let P=this.modelSchema.config.def[g],f=P.param,x=l[g];return g==="reasoningEnabled"?p.thinkingConfig={includeThoughts:x}:g==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?$(_({},p.thinkingConfig),{thinkingBudget:x}):{thinkingBudget:x}:f==="maxOutputTokens"&&P.type==="range"&&x===0?p[f]=P.max:p[f]=x,p},{}),m=i.safetySettings;delete i.safetySettings;let r;if(n!==void 0){let p=n;if(!o||o&&o.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let g=this.modelSchema.config.def.toolChoice;if(g.choices.includes(p))p==="any"?r={function_calling_config:{mode:"ANY",allowed_function_names:o.map(P=>P.definition.schema.name)}}:r={function_calling_config:{mode:p.toUpperCase()}};else if(o.map(P=>P.definition.schema.name).includes(p))r={function_calling_config:{mode:"ANY",allowed_function_names:[p]}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${p}' is not part of provided 'tools' names or
11
+ one of [${g.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let p=i.response_format;if(p==="json_schema"){let g=i.response_schema;if(!("response_schema"in i)||!i.response_schema||!(g!=null&&g.schema))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});i.responseSchema=g.schema,i.responseMimeType="application/json","additionalProperties"in g.schema&&delete i.responseSchema.additionalProperties,delete i.response_format,delete i.response_schema;}else p==="json_object"?(i.responseSchema={type:"object"},delete i.response_format):p==="text"&&delete i.response_format;}return _(_({generation_config:i},r?{tool_config:r}:{}),m?{safety_settings:m}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=i=>{let m=i.match(/^data:image\/[a-zA-Z]+;base64,/);return m?i.substring(m[0].length):i},o=e.map(i=>{let m=types.Message().safeParse(i);if(!m.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:m.error});return m.data});o.forEach(i=>{i.content.forEach(m=>{if(!this.modelSchema.modalities.includes(m.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${m.modality}',
12
12
  available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(i=>{if(!Object.keys(this.modelSchema.roles).includes(i.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${i.role}',
13
13
  available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let n={parts:[]},a=[];if(o.forEach(i=>{switch(i.role){case types.SystemRoleLiteral:i.content.forEach(m=>{if(m.modality===types.TextModalityLiteral)n.parts.push({text:m.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${m.modality}'`)})});break;case types.AssistantRoleLiteral:{let m=[];i.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)m.push({text:r.value});else if(r.modality===types.ToolCallModalityLiteral)m.push({function_call:{name:r.name,args:JSON.parse(r.arguments)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${r.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:m});}break;case types.UserRoleLiteral:{let m=[];i.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)m.push({text:r.value});else if(r.modality===types.ImageModalityLiteral){if(r.value.type==="base64"){let p=r.value.base64;p=t(p),m.push({inline_data:{mime_type:`image/${r.value.mediaType}`,data:p}});}else if(r.value.type==="url")throw new provider.InvalidMessagesError({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${r.value.type}'`)})}else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${r.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:m});}break;case types.ToolRoleLiteral:{let m=[];i.content.forEach(r=>{if(r.modality===types.ToolResponseModalityLiteral)m.push({function_response:{name:r.name,response:JSON.parse(r.data)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${r.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:m});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' is not supported,
14
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[0].role!==this.modelSchema.roles[types.UserRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let l=i=>i===this.modelSchema.roles[types.UserRoleLiteral]||i===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let i=1;i<a.length;i++)if(!l(a[i-1].role).includes(a[i].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[i].role}' after message with role : '${a[i-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&a[a.length-1].role!==this.modelSchema.roles[types.ToolRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return T({contents:a},n.parts.length>0?{system_instruction:n}:{})}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:[{function_declarations:e.map(n=>{let a=types.Tool().safeParse(n);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(n=>({name:n.definition.schema.name,description:n.definition.schema.description,parameters:n.definition.schema.parameters}))}]}}getCompleteChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return R(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(i=>{i(T(T(T(T({},this.getDefaultParams()),n),a),l));})})}transformCompleteChatResponse(e){let t=Lo.safeParse(e);if(t.success){if(t.data.candidates.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,n=[],a,l=o.candidates[0].content;if(l){let r=l.parts.map((p,g)=>{if("text"in p&&p.text!==void 0)return types.createTextContent(p.text);if("functionCall"in p&&p.functionCall!==void 0)return types.createToolCallContent(g,`${p.functionCall.name}_${g}`,p.functionCall.name,JSON.stringify(p.functionCall.args))});return n.push({role:types.AssistantRoleLiteral,content:r}),o.usageMetadata&&(a={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:n,usage:a,logProbs:void 0}}let i=o.candidates[0].safetyRatings;if(i&&i.length>0&&i.forEach(r=>{if(r.blocked)throw new provider.ModelResponseError({info:`Blocked content for category: ${r.category} with probability: ${r.probability}`,cause:new Error(`Blocked content for category: ${r.category} with probability: ${r.probability}`)})}),o.candidates[0].finishReason==="SAFETY")throw new provider.ModelResponseError({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return R(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(i=>{i(T(T(T(T({},this.getDefaultParams()),n),a),l));})})}transformStreamChatResponseChunk(e,t){return De(this,null,function*(){let o=(t+e).split(",\r").filter(n=>n.trim()!=="");for(let n of o){let a=n;if(a=a.replace(/\n/g,""),a.startsWith("[")||a.startsWith(",{"))a=a.slice(1);else if(a.endsWith("]")){if(a==="]")return;a=a.slice(0,-1);}let l;try{l=JSON.parse(a);}catch(m){if(m instanceof SyntaxError){t=a;continue}else throw m}t="";let i=ro.safeParse(l);if(i.success){let m={partialMessages:[]},r=i.data;if(r.candidates.length>0){let p=r.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((g,P)=>{if("text"in g&&g.text!==void 0&&m.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,g.text)),"functionCall"in g&&g.functionCall!==void 0){let f=g.functionCall;m.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,P,`${f.name}_${P}`,f.name,JSON.stringify(f.args)));}});}r.usageMetadata&&(m.usage={promptTokens:r.usageMetadata.promptTokenCount,completionTokens:r.usageMetadata.candidatesTokenCount,totalTokens:r.usageMetadata.totalTokenCount}),yield {partialResponse:m,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:i.error})}yield {partialResponse:{partialMessages:[]},buffer:t};})}transformProxyStreamChatResponseChunk(e,t,o,n,a){return De(this,null,function*(){if((a==null?void 0:a.alt)!=="sse"){yield*fo(this.transformStreamChatResponseChunk(e,t));return}let l=t+e,i=[],m="",r=0;for(;r<l.length;){let p=l.indexOf(`
15
- `,r);if(p===-1){m=l.substring(r);break}else {let g=l.substring(r,p).trim();g&&i.push(g),r=p+1;}}for(let p of i){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let g=p.substring(6);try{let P=JSON.parse(g),f=ro.safeParse(P);if(f.success){let x={partialMessages:[]},w=f.data;if(w.candidates.length>0){let k=w.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((E,N)=>{if("text"in E&&E.text!==void 0&&x.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.text)),"functionCall"in E&&E.functionCall!==void 0){let Fe=E.functionCall;x.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,N,`${Fe.name}_${N}`,Fe.name,JSON.stringify(Fe.args)));}});}w.usageMetadata&&w.usageMetadata.totalTokenCount&&w.usageMetadata.promptTokenCount&&w.usageMetadata.candidatesTokenCount&&(x.usage={promptTokens:w.usageMetadata.promptTokenCount,completionTokens:w.usageMetadata.candidatesTokenCount,totalTokens:w.usageMetadata.totalTokenCount}),yield {partialResponse:x,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:f.error})}catch(P){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${g}`,cause:P})}}}yield {partialResponse:{partialMessages:[]},buffer:m};})}getProxyCompleteChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{if(!o||Object.keys(o).length===0){n(this.streamChatUrl);return}let a=new URL(this.streamChatUrl);Object.entries(o).forEach(([l,i])=>{i!=null&&a.searchParams.set(l,i);}),n(a.toString());})})}getProxyCompleteChatHeaders(e,t,o){return R(this,null,function*(){if(!t)return {};let n=T({},t);return delete n.host,delete n["content-length"],n})}getProxyStreamChatHeaders(e,t,o){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in u))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return u[this.modelName]}};var ie="gemini-1.5-flash-001",Bt="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",He=provider.ChatModelSchema(M,_).parse({name:ie,description:Bt,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ie]}),Po=C,se=class extends y{constructor(e){super(He,e);}};var ae="gemini-1.5-flash-002",zt="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",Ke=provider.ChatModelSchema(M,_).parse({name:ae,description:zt,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ae]}),Eo=C,re=class extends y{constructor(e){super(Ke,e);}};var le="gemini-1.5-flash-latest",Kt="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Ye=provider.ChatModelSchema(M,_).parse({name:le,description:Kt,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[le]}),So=C,me=class extends y{constructor(e){super(Ye,e);}};var de="gemini-1.5-flash",Vt="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",Ve=provider.ChatModelSchema(M,_).parse({name:de,description:Vt,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[de]}),Ro=C,pe=class extends y{constructor(e){super(Ve,e);}};var ce="gemini-1.5-pro-001",Wt="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Je=provider.ChatModelSchema(M,_).parse({name:ce,description:Wt,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ce]}),Oo=C,ge=class extends y{constructor(e){super(Je,e);}};var he="gemini-1.5-pro-002",Zt="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",We=provider.ChatModelSchema(M,_).parse({name:he,description:Zt,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[he]}),xo=C,fe=class extends y{constructor(e){super(We,e);}};var ue="gemini-1.5-pro-latest",en="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Xe=provider.ChatModelSchema(M,_).parse({name:ue,description:en,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ue]}),wo=C,ye=class extends y{constructor(e){super(Xe,e);}};var Ce="gemini-1.5-pro",tn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Ze=provider.ChatModelSchema(M,_).parse({name:Ce,description:tn,maxInputTokens:2e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[Ce]}),ko=C,Te=class extends y{constructor(e){super(Ze,e);}};var Me="gemini-2.0-flash-exp",sn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Qe=provider.ChatModelSchema(M,_).parse({name:Me,description:sn,maxInputTokens:1e6,maxOutputTokens:8192,roles:b,modalities:G,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[Me]}),vo=C,be=class extends y{constructor(e){super(Qe,e);}};var Ge="gemini-2.5-flash-preview-04-17",rn="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",eo=provider.ChatModelSchema(M,_).parse({name:Ge,description:rn,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:G,config:{def:h.responseSchema(2,1,65536,4,.95).def,schema:h.responseSchema(2,1,65536,4,.95).schema},price:u[Ge]}),No=C,_e=class extends y{constructor(e){super(eo,e);}};var Pe="gemini-2.5-pro-preview-03-25",mn="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",oo=provider.ChatModelSchema(M,_).parse({name:Pe,description:mn,maxInputTokens:1048576,maxOutputTokens:65536,roles:b,modalities:G,config:{def:h.reasoning(2,1,65536,4,.95).def,schema:h.reasoning(2,1,65536,4,.95).schema},price:u[Pe]}),Io=C,Ee=class extends y{constructor(e){super(oo,e);}};var Ne=[types.EmbeddingTextModalityLiteral],Ie=zod.z.enum([types.EmbeddingTextModalityLiteral]);var Xo=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var pn=zod.z.object({model:zod.z.string().min(1),content:zod.z.object({parts:zod.z.array(zod.z.object({text:zod.z.string().min(1)})).min(1)})}),Zo=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(pn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var W=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),A=class{constructor(e,t){this.version="v1";let o=W.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||$.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(o.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((t,o)=>t+o.length,0)}transformModelRequest(e){let t=Zo.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model,a={outputDimensionality:o.outputDimensionality},l=types.Config().parse(provider.removeUndefinedEntries(a)),i={modality:types.EmbeddingTextModalityLiteral,requests:o.requests.reduce((m,r)=>(m.push(...r.content.parts.map(p=>p.text)),m),[])};return {modelName:n,config:l,embeddingRequests:i}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let n=o.data;return Object.keys(n).forEach(l=>{if(!this.modelSchema.config.def[l])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
16
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((l,i)=>{let r=this.modelSchema.config.def[i].param,p=n[i];return l[r]=p,l},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});if(e.modality!==types.EmbeddingTextModalityLiteral)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${types.EmbeddingTextModalityLiteral}' modality is supported for model : '${this.modelName}'`)});return {requests:t.data.requests.map(n=>({model:`models/${this.modelName}`,content:{parts:[{text:n}]}}))}}getGetEmbeddingsUrl(e,t){return R(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return R(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return R(this,null,function*(){return new Promise(o=>{let n=this.transformConfig(e),a=this.transformEmbeddingRequests(t);if(t.requests.length===0)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n.outputDimensionality&&(a.requests.forEach(l=>{l.outputDimensionality=n.outputDimensionality;}),delete n.outputDimensionality),o(T(T(T({},this.getDefaultParams()),n),a));})})}transformGetEmbeddingsResponse(e){let t=Xo.safeParse(e);if(t.success){let n=t.data.embeddings.map((a,l)=>({index:l,embedding:a.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:n}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var to="text-embedding-001",Tn="text-embedding-001",no=provider.EmbeddingModelSchema(Ie).parse({name:to,description:Tn,modalities:Ne,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),Fo=W,Se=class extends A{constructor(e){super(no,e);}};var io="text-embedding-004",bn="text-embedding-004",so=provider.EmbeddingModelSchema(Ie).parse({name:io,description:bn,modalities:Ne,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),Do=W,Re=class extends A{constructor(e){super(so,e);}};
14
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[0].role!==this.modelSchema.roles[types.UserRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let l=i=>i===this.modelSchema.roles[types.UserRoleLiteral]||i===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let i=1;i<a.length;i++)if(!l(a[i-1].role).includes(a[i].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[i].role}' after message with role : '${a[i-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&a[a.length-1].role!==this.modelSchema.roles[types.ToolRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return _({contents:a},n.parts.length>0?{system_instruction:n}:{})}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:[{function_declarations:e.map(n=>{let a=types.Tool().safeParse(n);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(n=>({name:n.definition.schema.name,description:n.definition.schema.description,parameters:n.definition.schema.parameters}))}]}}getCompleteChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return R(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(i=>{i(_(_(_(_({},this.getDefaultParams()),n),a),l));})})}transformCompleteChatResponse(e){let t=Ho.safeParse(e);if(t.success){if(t.data.candidates.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,n=[],a,l=o.candidates[0].content;if(l){let r=l.parts.map((p,g)=>{if("text"in p&&p.text!==void 0)return types.createTextContent(p.text);if("functionCall"in p&&p.functionCall!==void 0)return types.createToolCallContent(g,`${p.functionCall.name}_${g}`,p.functionCall.name,JSON.stringify(p.functionCall.args))});return n.push({role:types.AssistantRoleLiteral,content:r}),o.usageMetadata&&(a={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:n,usage:a,logProbs:void 0}}let i=o.candidates[0].safetyRatings;if(i&&i.length>0&&i.forEach(r=>{if(r.blocked)throw new provider.ModelResponseError({info:`Blocked content for category: ${r.category} with probability: ${r.probability}`,cause:new Error(`Blocked content for category: ${r.category} with probability: ${r.probability}`)})}),o.candidates[0].finishReason==="SAFETY")throw new provider.ModelResponseError({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return R(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(i=>{i(_(_(_(_({},this.getDefaultParams()),n),a),l));})})}transformStreamChatResponseChunk(e,t){return je(this,null,function*(){let o=(t+e).split(",\r").filter(n=>n.trim()!=="");for(let n of o){let a=n;if(a=a.replace(/\n/g,""),a.startsWith("[")||a.startsWith(",{"))a=a.slice(1);else if(a.endsWith("]")){if(a==="]")return;a=a.slice(0,-1);}let l;try{l=JSON.parse(a);}catch(m){if(m instanceof SyntaxError){t=a;continue}else throw m}t="";let i=go.safeParse(l);if(i.success){let m={partialMessages:[]},r=i.data;if(r.candidates.length>0){let p=r.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((g,P)=>{if("text"in g&&g.text!==void 0&&m.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,g.text)),"functionCall"in g&&g.functionCall!==void 0){let f=g.functionCall;m.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,P,`${f.name}_${P}`,f.name,JSON.stringify(f.args)));}});}r.usageMetadata&&(m.usage={promptTokens:r.usageMetadata.promptTokenCount,completionTokens:r.usageMetadata.candidatesTokenCount,totalTokens:r.usageMetadata.totalTokenCount}),yield {partialResponse:m,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:i.error})}yield {partialResponse:{partialMessages:[]},buffer:t};})}transformProxyStreamChatResponseChunk(e,t,o,n,a){return je(this,null,function*(){if((a==null?void 0:a.alt)!=="sse"){yield*bo(this.transformStreamChatResponseChunk(e,t));return}let l=t+e,i=[],m="",r=0;for(;r<l.length;){let p=l.indexOf(`
15
+ `,r);if(p===-1){m=l.substring(r);break}else {let g=l.substring(r,p).trim();g&&i.push(g),r=p+1;}}for(let p of i){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let g=p.substring(6);try{let P=JSON.parse(g),f=go.safeParse(P);if(f.success){let x={partialMessages:[]},w=f.data;if(w.candidates.length>0){let k=w.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((S,N)=>{if("text"in S&&S.text!==void 0&&x.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,S.text)),"functionCall"in S&&S.functionCall!==void 0){let $e=S.functionCall;x.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,N,`${$e.name}_${N}`,$e.name,JSON.stringify($e.args)));}});}w.usageMetadata&&w.usageMetadata.totalTokenCount&&w.usageMetadata.promptTokenCount&&w.usageMetadata.candidatesTokenCount&&(x.usage={promptTokens:w.usageMetadata.promptTokenCount,completionTokens:w.usageMetadata.candidatesTokenCount,totalTokens:w.usageMetadata.totalTokenCount}),yield {partialResponse:x,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:f.error})}catch(P){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${g}`,cause:P})}}}yield {partialResponse:{partialMessages:[]},buffer:m};})}getProxyCompleteChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return R(this,null,function*(){return new Promise(n=>{if(!o||Object.keys(o).length===0){n(this.streamChatUrl);return}let a=new URL(this.streamChatUrl);Object.entries(o).forEach(([l,i])=>{i!=null&&a.searchParams.set(l,i);}),n(a.toString());})})}getProxyCompleteChatHeaders(e,t,o){return R(this,null,function*(){if(!t)return {};let n=_({},t);return delete n.host,delete n["content-length"],n})}getProxyStreamChatHeaders(e,t,o){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in u))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return u[this.modelName]}};var ie="gemini-1.5-flash-001",Wt="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",Je=provider.ChatModelSchema(T,G).parse({name:ie,description:Wt,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ie]}),wo=C,se=class extends y{constructor(e){super(Je,e);}};var ae="gemini-1.5-flash-002",Zt="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",We=provider.ChatModelSchema(T,G).parse({name:ae,description:Zt,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ae]}),ko=C,re=class extends y{constructor(e){super(We,e);}};var le="gemini-1.5-flash-latest",en="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Xe=provider.ChatModelSchema(T,G).parse({name:le,description:en,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[le]}),vo=C,me=class extends y{constructor(e){super(Xe,e);}};var de="gemini-1.5-flash",tn="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",Ze=provider.ChatModelSchema(T,G).parse({name:de,description:tn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[de]}),No=C,pe=class extends y{constructor(e){super(Ze,e);}};var ce="gemini-1.5-pro-001",sn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Qe=provider.ChatModelSchema(T,G).parse({name:ce,description:sn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ce]}),Fo=C,he=class extends y{constructor(e){super(Qe,e);}};var ge="gemini-1.5-pro-002",rn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",eo=provider.ChatModelSchema(T,G).parse({name:ge,description:rn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ge]}),Io=C,fe=class extends y{constructor(e){super(eo,e);}};var ue="gemini-1.5-pro-latest",mn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",oo=provider.ChatModelSchema(T,G).parse({name:ue,description:mn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[ue]}),Do=C,ye=class extends y{constructor(e){super(oo,e);}};var Ce="gemini-1.5-pro",pn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",to=provider.ChatModelSchema(T,G).parse({name:Ce,description:pn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[Ce]}),Lo=C,Te=class extends y{constructor(e){super(to,e);}};var Me="gemini-2.0-flash-exp",hn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",no=provider.ChatModelSchema(T,G).parse({name:Me,description:hn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:b,config:{def:h.responseSchema(2,1,8192,4,.95).def,schema:h.responseSchema(2,1,8192,4,.95).schema},price:u[Me]}),Uo=C,be=class extends y{constructor(e){super(no,e);}};var Ge="gemini-2.5-flash-preview-04-17",fn="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",io=provider.ChatModelSchema(T,G).parse({name:Ge,description:fn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:b,config:{def:h.responseSchema(2,1,65536,4,.95).def,schema:h.responseSchema(2,1,65536,4,.95).schema},price:u[Ge]}),$o=C,_e=class extends y{constructor(e){super(io,e);}};var Pe="gemini-2.5-pro-preview-03-25",yn="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",so=provider.ChatModelSchema(T,G).parse({name:Pe,description:yn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:b,config:{def:h.reasoning(2,1,65536,4,.95).def,schema:h.reasoning(2,1,65536,4,.95).schema},price:u[Pe]}),jo=C,Se=class extends y{constructor(e){super(so,e);}};var Ee="gemini-2.5-flash",Tn="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",ao=provider.ChatModelSchema(T,G).parse({name:Ee,description:Tn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:b,config:{def:h.responseSchema(2,1,65536,4,.95).def,schema:h.responseSchema(2,1,65536,4,.95).schema},price:u[Ee]}),qo=C,Re=class extends y{constructor(e){super(ao,e);}};var Oe="gemini-2.5-pro",bn="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",ro=provider.ChatModelSchema(T,G).parse({name:Oe,description:bn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:b,config:{def:h.reasoning(2,1,65536,4,.95).def,schema:h.reasoning(2,1,65536,4,.95).schema},price:u[Oe]}),Bo=C,xe=class extends y{constructor(e){super(ro,e);}};var Le=[types.EmbeddingTextModalityLiteral],Ue=zod.z.enum([types.EmbeddingTextModalityLiteral]);var st=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var _n=zod.z.object({model:zod.z.string().min(1),content:zod.z.object({parts:zod.z.array(zod.z.object({text:zod.z.string().min(1)})).min(1)})}),at=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(_n).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var W=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),z=class{constructor(e,t){this.version="v1";let o=W.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||U.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(o.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((t,o)=>t+o.length,0)}transformModelRequest(e){let t=at.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model,a={outputDimensionality:o.outputDimensionality},l=types.Config().parse(provider.removeUndefinedEntries(a)),i={modality:types.EmbeddingTextModalityLiteral,requests:o.requests.reduce((m,r)=>(m.push(...r.content.parts.map(p=>p.text)),m),[])};return {modelName:n,config:l,embeddingRequests:i}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let n=o.data;return Object.keys(n).forEach(l=>{if(!this.modelSchema.config.def[l])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
16
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((l,i)=>{let r=this.modelSchema.config.def[i].param,p=n[i];return l[r]=p,l},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});if(e.modality!==types.EmbeddingTextModalityLiteral)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${types.EmbeddingTextModalityLiteral}' modality is supported for model : '${this.modelName}'`)});return {requests:t.data.requests.map(n=>({model:`models/${this.modelName}`,content:{parts:[{text:n}]}}))}}getGetEmbeddingsUrl(e,t){return R(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return R(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return R(this,null,function*(){return new Promise(o=>{let n=this.transformConfig(e),a=this.transformEmbeddingRequests(t);if(t.requests.length===0)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n.outputDimensionality&&(a.requests.forEach(l=>{l.outputDimensionality=n.outputDimensionality;}),delete n.outputDimensionality),o(_(_(_({},this.getDefaultParams()),n),a));})})}transformGetEmbeddingsResponse(e){let t=st.safeParse(e);if(t.success){let n=t.data.embeddings.map((a,l)=>({index:l,embedding:a.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:n}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var lo="text-embedding-001",kn="text-embedding-001",mo=provider.EmbeddingModelSchema(Ue).parse({name:lo,description:kn,modalities:Le,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),zo=W,we=class extends z{constructor(e){super(mo,e);}};var po="text-embedding-004",Nn="text-embedding-004",co=provider.EmbeddingModelSchema(Ue).parse({name:po,description:Nn,modalities:Le,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),Ao=W,ke=class extends z{constructor(e){super(co,e);}};
17
17
 
18
18
  exports.BaseChatModel = y;
19
19
  exports.BaseChatModelOptions = C;
20
- exports.BaseEmbeddingModel = A;
20
+ exports.BaseEmbeddingModel = z;
21
21
  exports.BaseEmbeddingModelOptions = W;
22
22
  exports.ChatModelBaseConfigDef = ee;
23
23
  exports.ChatModelBaseConfigSchema = Q;
24
- exports.ChatModelReasoningConfigDef = To;
25
- exports.ChatModelReasoningConfigSchema = Co;
26
- exports.EmbeddingModelBaseConfigDef = Go;
27
- exports.EmbeddingModelBaseConfigSchema = bo;
24
+ exports.ChatModelReasoningConfigDef = So;
25
+ exports.ChatModelReasoningConfigSchema = Po;
26
+ exports.EmbeddingModelBaseConfigDef = Oo;
27
+ exports.EmbeddingModelBaseConfigSchema = Ro;
28
28
  exports.Gemini1_5Flash = pe;
29
29
  exports.Gemini1_5Flash001 = se;
30
30
  exports.Gemini1_5Flash001Literal = ie;
31
- exports.Gemini1_5Flash001Options = Po;
32
- exports.Gemini1_5Flash001Schema = He;
31
+ exports.Gemini1_5Flash001Options = wo;
32
+ exports.Gemini1_5Flash001Schema = Je;
33
33
  exports.Gemini1_5Flash002 = re;
34
34
  exports.Gemini1_5Flash002Literal = ae;
35
- exports.Gemini1_5Flash002Options = Eo;
36
- exports.Gemini1_5Flash002Schema = Ke;
35
+ exports.Gemini1_5Flash002Options = ko;
36
+ exports.Gemini1_5Flash002Schema = We;
37
37
  exports.Gemini1_5FlashLatest = me;
38
38
  exports.Gemini1_5FlashLatestLiteral = le;
39
- exports.Gemini1_5FlashLatestOptions = So;
40
- exports.Gemini1_5FlashLatestSchema = Ye;
39
+ exports.Gemini1_5FlashLatestOptions = vo;
40
+ exports.Gemini1_5FlashLatestSchema = Xe;
41
41
  exports.Gemini1_5FlashLiteral = de;
42
- exports.Gemini1_5FlashOptions = Ro;
43
- exports.Gemini1_5FlashSchema = Ve;
42
+ exports.Gemini1_5FlashOptions = No;
43
+ exports.Gemini1_5FlashSchema = Ze;
44
44
  exports.Gemini1_5Pro = Te;
45
- exports.Gemini1_5Pro001 = ge;
45
+ exports.Gemini1_5Pro001 = he;
46
46
  exports.Gemini1_5Pro001Literal = ce;
47
- exports.Gemini1_5Pro001Options = Oo;
48
- exports.Gemini1_5Pro001Schema = Je;
47
+ exports.Gemini1_5Pro001Options = Fo;
48
+ exports.Gemini1_5Pro001Schema = Qe;
49
49
  exports.Gemini1_5Pro002 = fe;
50
- exports.Gemini1_5Pro002Literal = he;
51
- exports.Gemini1_5Pro002Options = xo;
52
- exports.Gemini1_5Pro002Schema = We;
50
+ exports.Gemini1_5Pro002Literal = ge;
51
+ exports.Gemini1_5Pro002Options = Io;
52
+ exports.Gemini1_5Pro002Schema = eo;
53
53
  exports.Gemini1_5ProLatest = ye;
54
54
  exports.Gemini1_5ProLatestLiteral = ue;
55
- exports.Gemini1_5ProLatestOptions = wo;
56
- exports.Gemini1_5ProLatestSchema = Xe;
55
+ exports.Gemini1_5ProLatestOptions = Do;
56
+ exports.Gemini1_5ProLatestSchema = oo;
57
57
  exports.Gemini1_5ProLiteral = Ce;
58
- exports.Gemini1_5ProOptions = ko;
59
- exports.Gemini1_5ProSchema = Ze;
58
+ exports.Gemini1_5ProOptions = Lo;
59
+ exports.Gemini1_5ProSchema = to;
60
60
  exports.Gemini2_0FlashExp = be;
61
61
  exports.Gemini2_0FlashExpLiteral = Me;
62
- exports.Gemini2_0FlashExpOptions = vo;
63
- exports.Gemini2_0FlashExpSchema = Qe;
62
+ exports.Gemini2_0FlashExpOptions = Uo;
63
+ exports.Gemini2_0FlashExpSchema = no;
64
+ exports.Gemini2_5Flash = Re;
65
+ exports.Gemini2_5FlashLiteral = Ee;
66
+ exports.Gemini2_5FlashOptions = qo;
64
67
  exports.Gemini2_5FlashPreview0417 = _e;
65
68
  exports.Gemini2_5FlashPreview0417Literal = Ge;
66
- exports.Gemini2_5FlashPreview0417Options = No;
67
- exports.Gemini2_5FlashPreview0417Schema = eo;
68
- exports.Gemini2_5ProPreview0325 = Ee;
69
+ exports.Gemini2_5FlashPreview0417Options = $o;
70
+ exports.Gemini2_5FlashPreview0417Schema = io;
71
+ exports.Gemini2_5FlashSchema = ao;
72
+ exports.Gemini2_5Pro = xe;
73
+ exports.Gemini2_5ProLiteral = Oe;
74
+ exports.Gemini2_5ProOptions = Bo;
75
+ exports.Gemini2_5ProPreview0325 = Se;
69
76
  exports.Gemini2_5ProPreview0325Literal = Pe;
70
- exports.Gemini2_5ProPreview0325Options = Io;
71
- exports.Gemini2_5ProPreview0325Schema = oo;
72
- exports.Google = $;
73
- exports.GoogleChatAssistantRoleLiteral = _t;
74
- exports.GoogleChatContent = vt;
75
- exports.GoogleChatContentPartFunctionCall = wt;
76
- exports.GoogleChatContentPartFunctionResponse = kt;
77
- exports.GoogleChatContentPartInlineData = xt;
78
- exports.GoogleChatContentPartText = Bo;
79
- exports.GoogleChatGenerationConfig = jo;
77
+ exports.Gemini2_5ProPreview0325Options = jo;
78
+ exports.Gemini2_5ProPreview0325Schema = so;
79
+ exports.Gemini2_5ProSchema = ro;
80
+ exports.Google = U;
81
+ exports.GoogleChatAssistantRoleLiteral = kt;
82
+ exports.GoogleChatContent = jt;
83
+ exports.GoogleChatContentPartFunctionCall = Ut;
84
+ exports.GoogleChatContentPartFunctionResponse = $t;
85
+ exports.GoogleChatContentPartInlineData = Lt;
86
+ exports.GoogleChatContentPartText = Wo;
87
+ exports.GoogleChatGenerationConfig = Vo;
80
88
  exports.GoogleChatModelConfigs = h;
81
- exports.GoogleChatModelModalities = G;
82
- exports.GoogleChatModelModalitiesEnum = _;
89
+ exports.GoogleChatModelModalities = b;
90
+ exports.GoogleChatModelModalitiesEnum = G;
83
91
  exports.GoogleChatModelResponseSchemaConfigDef = te;
84
92
  exports.GoogleChatModelResponseSchemaConfigSchema = ne;
85
- exports.GoogleChatModelRoles = M;
86
- exports.GoogleChatModelRolesMap = b;
87
- exports.GoogleChatModelTextModalities = di;
88
- exports.GoogleChatModelTextModalitiesEnum = pi;
89
- exports.GoogleChatModelTextToolModalities = hi;
90
- exports.GoogleChatModelTextToolModalitiesEnum = fi;
91
- exports.GoogleChatModelTextVisionModalities = ci;
92
- exports.GoogleChatModelTextVisionModalitiesEnum = gi;
93
- exports.GoogleChatRequest = Ao;
94
- exports.GoogleChatSafetySettings = qo;
95
- exports.GoogleChatSystemInstruction = $o;
96
- exports.GoogleChatTool = Nt;
97
- exports.GoogleChatToolConfig = Uo;
98
- exports.GoogleChatToolRoleLiteral = Pt;
99
- exports.GoogleCompleteChatResponse = Lo;
100
- exports.GoogleCompleteChatTextResponse = Et;
101
- exports.GoogleCompleteChatToolResponse = St;
93
+ exports.GoogleChatModelRoles = T;
94
+ exports.GoogleChatModelRolesMap = M;
95
+ exports.GoogleChatModelTextModalities = Gi;
96
+ exports.GoogleChatModelTextModalitiesEnum = _i;
97
+ exports.GoogleChatModelTextToolModalities = Ei;
98
+ exports.GoogleChatModelTextToolModalitiesEnum = Ri;
99
+ exports.GoogleChatModelTextVisionModalities = Pi;
100
+ exports.GoogleChatModelTextVisionModalitiesEnum = Si;
101
+ exports.GoogleChatRequest = Xo;
102
+ exports.GoogleChatSafetySettings = Jo;
103
+ exports.GoogleChatSystemInstruction = Ko;
104
+ exports.GoogleChatTool = qt;
105
+ exports.GoogleChatToolConfig = Yo;
106
+ exports.GoogleChatToolRoleLiteral = vt;
107
+ exports.GoogleCompleteChatResponse = Ho;
108
+ exports.GoogleCompleteChatTextResponse = Nt;
109
+ exports.GoogleCompleteChatToolResponse = Ft;
102
110
  exports.GoogleEmbeddingModelConfigs = j;
103
- exports.GoogleEmbeddingModelModalities = Ne;
104
- exports.GoogleEmbeddingModelModalitiesEnum = Ie;
105
- exports.GoogleEmbeddingRequest = Zo;
106
- exports.GoogleEmbeddingRequestInput = pn;
107
- exports.GoogleGetEmbeddingsResponse = Xo;
108
- exports.GoogleStreamChatResponse = ro;
109
- exports.GoogleStreamChatTextResponse = Rt;
110
- exports.GoogleStreamChatToolResponse = Ot;
111
- exports.ProviderLiteral = yt;
112
- exports.Text_Embedding_001 = Se;
113
- exports.Text_Embedding_001Literal = to;
114
- exports.Text_Embedding_001Options = Fo;
115
- exports.Text_Embedding_001Schema = no;
116
- exports.Text_Embedding_004 = Re;
117
- exports.Text_Embedding_004Literal = io;
118
- exports.Text_Embedding_004Options = Do;
119
- exports.Text_Embedding_004Schema = so;
120
- exports.dimensions = ze;
121
- exports.frequencyPenalty = Sn;
122
- exports.maxTokens = $e;
123
- exports.presencePenalty = Rn;
124
- exports.reasoningEnabled = Ae;
125
- exports.safetySettings = Be;
126
- exports.seed = On;
127
- exports.stop = Ue;
128
- exports.temperature = Le;
129
- exports.toolChoice = qe;
130
- exports.topK = En;
131
- exports.topP = je;
111
+ exports.GoogleEmbeddingModelModalities = Le;
112
+ exports.GoogleEmbeddingModelModalitiesEnum = Ue;
113
+ exports.GoogleEmbeddingRequest = at;
114
+ exports.GoogleEmbeddingRequestInput = _n;
115
+ exports.GoogleGetEmbeddingsResponse = st;
116
+ exports.GoogleStreamChatResponse = go;
117
+ exports.GoogleStreamChatTextResponse = It;
118
+ exports.GoogleStreamChatToolResponse = Dt;
119
+ exports.ProviderLiteral = St;
120
+ exports.Text_Embedding_001 = we;
121
+ exports.Text_Embedding_001Literal = lo;
122
+ exports.Text_Embedding_001Options = zo;
123
+ exports.Text_Embedding_001Schema = mo;
124
+ exports.Text_Embedding_004 = ke;
125
+ exports.Text_Embedding_004Literal = po;
126
+ exports.Text_Embedding_004Options = Ao;
127
+ exports.Text_Embedding_004Schema = co;
128
+ exports.dimensions = Ve;
129
+ exports.frequencyPenalty = Un;
130
+ exports.maxTokens = Be;
131
+ exports.presencePenalty = $n;
132
+ exports.reasoningEnabled = Ye;
133
+ exports.safetySettings = Ke;
134
+ exports.seed = jn;
135
+ exports.stop = ze;
136
+ exports.temperature = qe;
137
+ exports.toolChoice = He;
138
+ exports.topK = Ln;
139
+ exports.topP = Ae;
132
140
  //# sourceMappingURL=index.js.map
133
141
  //# sourceMappingURL=index.js.map