@adaline/google 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2374,6 +2374,11 @@ declare class BaseChatModel implements ChatModelV1<ChatModelSchemaType> {
2374
2374
  };
2375
2375
  transformConfig(config: ConfigType, messages?: MessageType[], tools?: ToolType[]): ParamsType;
2376
2376
  transformMessages(messages: MessageType[]): ParamsType;
2377
+ /**
2378
+ * Recursively removes 'additionalProperties' from a JSON schema object.
2379
+ * Google's Gemini API does not support this field in function parameters.
2380
+ */
2381
+ private stripAdditionalProperties;
2377
2382
  transformTools(tools: ToolType[]): ParamsType;
2378
2383
  getCompleteChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<UrlType>;
2379
2384
  getCompleteChatHeaders(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<HeadersType>;
package/dist/index.d.ts CHANGED
@@ -2374,6 +2374,11 @@ declare class BaseChatModel implements ChatModelV1<ChatModelSchemaType> {
2374
2374
  };
2375
2375
  transformConfig(config: ConfigType, messages?: MessageType[], tools?: ToolType[]): ParamsType;
2376
2376
  transformMessages(messages: MessageType[]): ParamsType;
2377
+ /**
2378
+ * Recursively removes 'additionalProperties' from a JSON schema object.
2379
+ * Google's Gemini API does not support this field in function parameters.
2380
+ */
2381
+ private stripAdditionalProperties;
2377
2382
  transformTools(tools: ToolType[]): ParamsType;
2378
2383
  getCompleteChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<UrlType>;
2379
2384
  getCompleteChatHeaders(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<HeadersType>;
package/dist/index.js CHANGED
@@ -4,16 +4,16 @@ var zod = require('zod');
4
4
  var provider = require('@adaline/provider');
5
5
  var types = require('@adaline/types');
6
6
 
7
- var bt=Object.defineProperty,Pt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var Po=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var W=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Ot=a=>{throw TypeError(a)};var _o=(a,e,o)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[e]=o,_=(a,e)=>{for(var o in e||(e={}))St.call(e,o)&&_o(a,o,e[o]);if(Po)for(var o of Po(e))Et.call(e,o)&&_o(a,o,e[o]);return a},N=(a,e)=>Pt(a,_t(e));var S=(a,e,o)=>new Promise((t,i)=>{var l=r=>{try{n(o.next(r));}catch(s){i(s);}},m=r=>{try{n(o.throw(r));}catch(s){i(s);}},n=r=>r.done?t(r.value):Promise.resolve(r.value).then(l,m);n((o=o.apply(a,e)).next());}),So=function(a,e){this[0]=a,this[1]=e;},qe=(a,e,o)=>{var t=(m,n,r,s)=>{try{var p=o[m](n),h=(n=p.value)instanceof So,P=p.done;Promise.resolve(h?n[0]:n).then(y=>h?t(m==="return"?m:"next",n[1]?{done:y.done,value:y.value}:y,r,s):r({value:y,done:P})).catch(y=>t("throw",y,r,s));}catch(y){s(y);}},i=m=>l[m]=n=>new Promise((r,s)=>t(m,n,r,s)),l={};return o=o.apply(a,e),l[W("asyncIterator")]=()=>l,i("next"),i("throw"),i("return"),l},Eo=a=>{var e=a[W("asyncIterator")],o=!1,t,i={};return e==null?(e=a[W("iterator")](),t=l=>i[l]=m=>e[l](m)):(e=e.call(a),t=l=>i[l]=m=>{if(o){if(o=!1,l==="throw")throw m;return m}return o=!0,{done:!1,value:new So(new Promise(n=>{var r=e[l](m);r instanceof Object||Ot("Object expected"),n(r);}),1)}}),i[W("iterator")]=()=>i,t("next"),"throw"in e?t("throw"):i.throw=l=>{throw l},"return"in e&&t("return"),i};var vt=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],Ft=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Oo=(a,e)=>a.replace(e,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),Nt=vt.map(a=>({value:a,label:Oo(a,"HARM_CATEGORY_")})),Lt=Ft.map(a=>({value:a,label:Oo(a,"HARM_BLOCK_THRESHOLD_")})),ze=(a,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:a,step:.01,default:e}),He=a=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),Ke=a=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(a).title,description:provider.CHAT_CONFIG.STOP(a).description,max:a}),Ye=a=>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:a}),li=a=>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:a}),mi=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}),pi=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}),di=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),Ve=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"]}),Je=provider.PairedSelectConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",fields:[{key:"category",label:"Category",choices:Nt},{key:"threshold",label:"Threshold",choices:Lt}],uniqueByField:"category"}),Xe=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 Z=(a,e,o,t,i)=>zod.z.object({temperature:ze(a,e).schema,maxTokens:He(o).schema,stop:Ke(t).schema,topP:Ye(i).schema,toolChoice:Ve.schema,safetySettings:Je.schema}),Q=(a,e,o,t,i)=>({temperature:ze(a,e).def,maxTokens:He(o).def,stop:Ke(t).def,topP:Ye(i).def,toolChoice:Ve.def,safetySettings:Je.def});var Ro=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),wo=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"]}),oe=(a,e,o,t,i)=>N(_({},Q(a,e,o,t,i)),{responseFormat:wo.def,responseSchema:Ro.def}),te=(a,e,o,t,i)=>Z(a,e,o,t,i).extend({responseFormat:wo.schema,responseSchema:Ro.schema});var xo=(a,e,o,t,i)=>te(a,e,o,t,i).extend({reasoningEnabled:Xe.schema}),ko=(a,e,o,t,i)=>N(_({},oe(a,e,o,t,i)),{reasoningEnabled:Xe.def});var We=a=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:a,step:1,default:a});var Fo=a=>zod.z.object({dimensions:We(a).schema}),No=a=>({dimensions:We(a).def});var g={base:(a,e,o,t,i)=>({def:Q(a,e,o,t,i),schema:Z(a,e,o,t,i)}),responseSchema:(a,e,o,t,i)=>({def:oe(a,e,o,t,i),schema:te(a,e,o,t,i)}),reasoning:(a,e,o,t,i)=>({def:ko(a,e,o,t,i),schema:xo(a,e,o,t,i)})},B={base:a=>({def:No(a),schema:Fo(a)})};var At="google",$=class{constructor(){this.version="v1";this.name=At;this.chatModelFactories={[ne]:{model:ie,modelOptions:Io,modelSchema:Ze},[se]:{model:ae,modelOptions:Do,modelSchema:Qe},[re]:{model:le,modelOptions:Uo,modelSchema:eo},[me]:{model:pe,modelOptions:$o,modelSchema:oo},[de]:{model:ce,modelOptions:Bo,modelSchema:to},[ge]:{model:he,modelOptions:jo,modelSchema:no},[fe]:{model:ue,modelOptions:Ao,modelSchema:io},[ye]:{model:Ce,modelOptions:qo,modelSchema:so},[Te]:{model:Me,modelOptions:zo,modelSchema:ao},[Pe]:{model:_e,modelOptions:Ko,modelSchema:lo},[Oe]:{model:Re,modelOptions:Vo,modelSchema:po},[Se]:{model:Ee,modelOptions:Yo,modelSchema:mo},[we]:{model:xe,modelOptions:Jo,modelSchema:co},[ke]:{model:ve,modelOptions:Xo,modelSchema:go},[Ge]:{model:be,modelOptions:Ho,modelSchema:ro}};this.embeddingModelFactories={[ho]:{model:Fe,modelOptions:Wo,modelSchema:fo},[uo]:{model:Ne,modelOptions:Zo,modelSchema:yo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}chatModel(e){let o=e.modelName;if(!(o in this.chatModelFactories))throw new provider.ProviderError({info:`Google chat model: ${o} not found`,cause:new Error(`Google chat model: ${o} not found, available chat models:
8
- [${this.chatModelLiterals().join(", ")}]`)});let t=this.chatModelFactories[o].model,i=this.chatModelFactories[o].modelOptions.parse(e);return new t(i)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,o)=>(e[o]=this.embeddingModelFactories[o].modelSchema,e),{})}embeddingModel(e){let o=e.modelName;if(!(o in this.embeddingModelFactories))throw new provider.ProviderError({info:`Google embedding model: ${o} not found`,cause:new Error(`Google embedding model: ${o} not found, available embedding models:
9
- [${this.embeddingModelLiterals().join(", ")}]`)});let t=this.embeddingModelFactories[o].model,i=this.embeddingModelFactories[o].modelOptions.parse(e);return new t(i)}};$.baseUrl="https://generativelanguage.googleapis.com/v1beta";var f={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),Vt="model",Jt="function",M={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:Vt,tool:Jt};var G=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],b=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),Yi=[types.TextModalityLiteral],Vi=zod.z.enum([types.TextModalityLiteral]),Ji=[types.TextModalityLiteral,types.ImageModalityLiteral],Xi=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),Wi=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],Zi=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Xt=zod.z.object({text:zod.z.string()}),Wt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),et=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([Xt,Wt]))}).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()}),Zt=zod.z.object({text:zod.z.string()}),Qt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),To=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([Zt,Qt]))}).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 st=zod.z.object({text:zod.z.string().min(1)}),en=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),on=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),tn=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),nn=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),sn=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([st,en,on,tn,nn]))}),ot=zod.z.object({parts:zod.z.array(st)}),an=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),tt=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()})}),nt=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()}),it=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"])}),at=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(sn),systemInstruction:ot.optional(),system_instruction:ot.optional(),generationConfig:nt.optional(),generation_config:nt.optional(),safetySettings:zod.z.array(it).optional(),safety_settings:zod.z.array(it).optional(),tools:zod.z.object({function_declarations:zod.z.array(an)}).optional(),toolConfig:tt.optional(),tool_config:tt.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()}),u=class{constructor(e,o){this.version="v1";var i;let t=C.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((i=t.baseUrl)!=null?i:$.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformPdfMessages(e){return S(this,null,function*(){let o=n=>S(this,null,function*(){let r={};provider.isRunningInBrowser()||(r["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let s=yield fetch(n,{headers:r});if(!s.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=yield s.arrayBuffer();return new Uint8Array(p)}),t=n=>S(this,null,function*(){try{let r=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return null;let h=((yield r.json()).files||[]).find(P=>P.displayName===n);return h?h.uri:null}catch(r){return null}}),i=(n,r)=>S(this,null,function*(){let s=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":n.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:r}})});if(!s.ok)throw new provider.InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=s.headers.get("x-goog-upload-url");if(!p)throw new provider.InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};provider.isRunningInBrowser()||(h["Content-Length"]=n.length.toString());let P=yield fetch(p,{method:"POST",headers:h,body:n});if(!P.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${P.status}: ${P.statusText}`)});return (yield P.json()).file.uri}),l=n=>S(this,null,function*(){let r=yield t(n.file.id);if(r)return r;let s;if(n.value.type==="url")s=yield o(n.value.url);else {let p=n.value.base64,h="data:application/pdf;base64,";p=p.startsWith(h)?p.substring(h.length):p,s=provider.convertBase64ToUint8Array(p);}return yield i(s,n.file.id)}),m=[];for(let n of e){let r=[];for(let s of n.content)if(s.modality===types.PdfModalityLiteral){let p=yield l(s);r.push(N(_({},s),{value:{type:"url",url:p}}));}else r.push(s);m.push(N(_({},n),{content:r}));}return m})}transformModelRequest(e){let o=at.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,i=t.model;if(t.system_instruction&&t.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(t.generation_config&&t.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(t.tool_config&&t.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 l=t.system_instruction||t.systemInstruction,m=t.generation_config||t.generationConfig,n=t.safety_settings||t.safetySettings,r=t.tool_config||t.toolConfig;if(r&&(!t.tools||t.tools.function_declarations.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};r&&(r.function_calling_config.mode==="ANY"&&r.function_calling_config.allowed_function_names&&r.function_calling_config.allowed_function_names.length===1?s.toolChoice=r.function_calling_config.allowed_function_names[0]:s.toolChoice=r.function_calling_config.mode.toLowerCase()),s.seed=m==null?void 0:m.seed,s.maxTokens=m==null?void 0:m.maxOutputTokens,s.temperature=m==null?void 0:m.temperature,s.topP=m==null?void 0:m.topP,s.presencePenalty=m==null?void 0:m.presencePenalty,s.frequencyPenalty=m==null?void 0:m.frequencyPenalty,s.stop=m==null?void 0:m.stopSequences,s.safetySettings=n;let p=types.Config().parse(provider.removeUndefinedEntries(s)),h=[];l&&l.parts.forEach(y=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:y.text}]});}),t.contents.forEach(y=>{let w=y.role;switch(w){case"user":{let k=y.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]}});h.push({role:w,content:k});}break;case"model":{let k=y.parts.map((E,F)=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ToolCallModalityLiteral,id:F.toString(),index:F,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=y.parts.map((E,F)=>({modality:types.ToolResponseModalityLiteral,id:F.toString(),index:F,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${y.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return t.tools&&t.tools.function_declarations.forEach(y=>{P.push({type:"function",definition:{schema:{name:y.name,description:y.description,parameters:y.parameters}}});}),{modelName:i,config:p,messages:h,tools:P.length>0?P:void 0}}transformConfig(e,o,t){let i=e.toolChoice;delete e.toolChoice;let l=this.modelSchema.config.schema.safeParse(e);if(!l.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:l.error});let m=l.data;Object.keys(m).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 n=Object.keys(m).reduce((p,h)=>{let P=this.modelSchema.config.def[h],y=P.param,w=m[h];return h==="reasoningEnabled"?p.thinkingConfig={includeThoughts:w}:h==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?N(_({},p.thinkingConfig),{thinkingBudget:w}):{thinkingBudget:w}:y==="maxOutputTokens"&&P.type==="range"&&w===0?p[y]=P.max:p[y]=w,p},{}),r=n.safetySettings;delete n.safetySettings;let s;if(i!==void 0){let p=i;if(!t||t&&t.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(p))p==="any"?s={function_calling_config:{mode:"ANY",allowed_function_names:t.map(P=>P.definition.schema.name)}}:s={function_calling_config:{mode:p.toUpperCase()}};else if(t.map(P=>P.definition.schema.name).includes(p))s={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 [${h.choices.join(", ")}]`)})}}if("response_format"in n&&n.response_format!==void 0){let p=n.response_format;if(p==="json_schema"){let h=n.response_schema;if(!("response_schema"in n)||!n.response_schema||!(h!=null&&h.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'")});n.responseSchema=h.schema,n.responseMimeType="application/json","additionalProperties"in h.schema&&delete n.responseSchema.additionalProperties,delete n.response_format,delete n.response_schema;}else p==="json_object"?(n.responseSchema={type:"object"},delete n.response_format):p==="text"&&delete n.response_format;}return _(_({generation_config:n},s?{tool_config:s}:{}),r?{safety_settings:r}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=n=>{let r=n.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return r?n.substring(r[0].length):n},t=e.map(n=>{let r=types.Message().safeParse(n);if(!r.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:r.error});return r.data});t.forEach(n=>{n.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}',
12
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
13
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},l=[];if(t.forEach(n=>{switch(n.role){case types.SystemRoleLiteral:n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)i.parts.push({text:r.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})});break;case types.AssistantRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ToolCallModalityLiteral)r.push({function_call:{name:s.name,args:JSON.parse(s.arguments)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.UserRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ImageModalityLiteral){if(s.value.type==="base64"){let p=s.value.base64;p=o(p),r.push({inline_data:{mime_type:`image/${s.value.mediaType}`,data:p}});}else if(s.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: '${s.value.type}'`)})}else if(s.modality===types.PdfModalityLiteral)if(s.value.type==="base64"){let p=s.value.base64;p=o(p),r.push({inline_data:{mime_type:"application/pdf",data:p}});}else s.value.type==="url"&&r.push({file_data:{mime_type:"application/pdf",file_uri:s.value.url}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.ToolRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.ToolResponseModalityLiteral)r.push({function_response:{name:s.name,response:JSON.parse(s.data)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
14
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),l[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 m=n=>n===this.modelSchema.roles[types.UserRoleLiteral]||n===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let n=1;n<l.length;n++)if(!m(l[n-1].role).includes(l[n].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${l[n].role}' after message with role : '${l[n-1].role}'`)});if(l[l.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&l[l.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:l},i.parts.length>0?{system_instruction:i}:{})}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(i=>{let l=types.Tool().safeParse(i);if(!l.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:l.error});return l.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,parameters:i.definition.schema.parameters}))}]}}getCompleteChatUrl(e,o,t){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return S(this,null,function*(){let i=this.transformConfig(e,o,t),l=yield this.transformPdfMessages(o),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=t?this.transformTools(t):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformCompleteChatResponse(e){let o=et.safeParse(e);if(o.success){if(o.data.candidates.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let t=o.data,i=[],l,m=t.candidates[0].content;if(m){let s=m.parts.map((p,h)=>{if("text"in p&&p.text!==void 0)return types.createTextContent(p.text);if("functionCall"in p&&p.functionCall!==void 0)return types.createToolCallContent(h,`${p.functionCall.name}_${h}`,p.functionCall.name,JSON.stringify(p.functionCall.args))});return i.push({role:types.AssistantRoleLiteral,content:s}),t.usageMetadata&&(l={promptTokens:t.usageMetadata.promptTokenCount,totalTokens:t.usageMetadata.totalTokenCount,completionTokens:t.usageMetadata.candidatesTokenCount||0}),{messages:i,usage:l,logProbs:void 0}}let n=t.candidates[0].safetyRatings;if(n&&n.length>0&&n.forEach(s=>{if(s.blocked)throw new provider.ModelResponseError({info:`Blocked content for category: ${s.category} with probability: ${s.probability}`,cause:new Error(`Blocked content for category: ${s.category} with probability: ${s.probability}`)})}),t.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:o.error})}getStreamChatUrl(e,o,t){return S(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return S(this,null,function*(){let i=this.transformConfig(e,o,t),l=yield this.transformPdfMessages(o),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=t?this.transformTools(t):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformStreamChatResponseChunk(e,o){return qe(this,null,function*(){let t=(o+e).split(",\r").filter(i=>i.trim()!=="");for(let i of t){let l=i;if(l=l.replace(/\n/g,""),l.startsWith("[")||l.startsWith(",{"))l=l.slice(1);else if(l.endsWith("]")){if(l==="]")return;l=l.slice(0,-1);}let m;try{m=JSON.parse(l);}catch(r){if(r instanceof SyntaxError){o=l;continue}else throw r}o="";let n=To.safeParse(m);if(n.success){let r={partialMessages:[]},s=n.data;if(s.candidates.length>0){let p=s.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((h,P)=>{if("text"in h&&h.text!==void 0&&r.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.text)),"functionCall"in h&&h.functionCall!==void 0){let y=h.functionCall;r.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,P,`${y.name}_${P}`,y.name,JSON.stringify(y.args)));}});}s.usageMetadata&&(r.usage={promptTokens:s.usageMetadata.promptTokenCount,completionTokens:s.usageMetadata.candidatesTokenCount,totalTokens:s.usageMetadata.totalTokenCount}),yield {partialResponse:r,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:n.error})}yield {partialResponse:{partialMessages:[]},buffer:o};})}transformProxyStreamChatResponseChunk(e,o,t,i,l){return qe(this,null,function*(){if((l==null?void 0:l.alt)!=="sse"){yield*Eo(this.transformStreamChatResponseChunk(e,o));return}let m=o+e,n=[],r="",s=0;for(;s<m.length;){let p=m.indexOf(`
15
- `,s);if(p===-1){r=m.substring(s);break}else {let h=m.substring(s,p).trim();h&&n.push(h),s=p+1;}}for(let p of n){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let h=p.substring(6);try{let P=JSON.parse(h),y=To.safeParse(P);if(y.success){let w={partialMessages:[]},x=y.data;if(x.candidates.length>0){let k=x.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((E,F)=>{if("text"in E&&E.text!==void 0&&w.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.text)),"functionCall"in E&&E.functionCall!==void 0){let Ae=E.functionCall;w.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,F,`${Ae.name}_${F}`,Ae.name,JSON.stringify(Ae.args)));}});}x.usageMetadata&&x.usageMetadata.totalTokenCount&&x.usageMetadata.promptTokenCount&&x.usageMetadata.candidatesTokenCount&&(w.usage={promptTokens:x.usageMetadata.promptTokenCount,completionTokens:x.usageMetadata.candidatesTokenCount,totalTokens:x.usageMetadata.totalTokenCount}),yield {partialResponse:w,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:y.error})}catch(P){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${h}`,cause:P})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}getProxyCompleteChatUrl(e,o,t){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(e,o,t){return S(this,null,function*(){return new Promise(i=>{if(!t||Object.keys(t).length===0){i(this.streamChatUrl);return}let l=new URL(this.streamChatUrl);Object.entries(t).forEach(([m,n])=>{n!=null&&l.searchParams.set(m,n);}),i(l.toString());})})}getProxyCompleteChatHeaders(e,o,t){return S(this,null,function*(){if(!o)return {};let i=_({},o);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,o,t){return S(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,t)})}getModelPricing(){if(!(this.modelName in f))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var ne="gemini-1.5-flash-001",un="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,b).parse({name:ne,description:un,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ne]}),Io=C,ie=class extends u{constructor(e){super(Ze,e);}};var se="gemini-1.5-flash-002",Cn="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",Qe=provider.ChatModelSchema(T,b).parse({name:se,description:Cn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[se]}),Do=C,ae=class extends u{constructor(e){super(Qe,e);}};var re="gemini-1.5-flash-latest",Mn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",eo=provider.ChatModelSchema(T,b).parse({name:re,description:Mn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[re]}),Uo=C,le=class extends u{constructor(e){super(eo,e);}};var me="gemini-1.5-flash",bn="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",oo=provider.ChatModelSchema(T,b).parse({name:me,description:bn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[me]}),$o=C,pe=class extends u{constructor(e){super(oo,e);}};var de="gemini-1.5-pro-001",_n="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,b).parse({name:de,description:_n,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[de]}),Bo=C,ce=class extends u{constructor(e){super(to,e);}};var ge="gemini-1.5-pro-002",En="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",no=provider.ChatModelSchema(T,b).parse({name:ge,description:En,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ge]}),jo=C,he=class extends u{constructor(e){super(no,e);}};var fe="gemini-1.5-pro-latest",Rn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",io=provider.ChatModelSchema(T,b).parse({name:fe,description:Rn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[fe]}),Ao=C,ue=class extends u{constructor(e){super(io,e);}};var ye="gemini-1.5-pro",xn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",so=provider.ChatModelSchema(T,b).parse({name:ye,description:xn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ye]}),qo=C,Ce=class extends u{constructor(e){super(so,e);}};var ft="gemini-2.0-flash-exp",vn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Fn=provider.ChatModelSchema(T,b).parse({name:ft,description:vn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ft]}),$a=C,ut=class extends u{constructor(e){super(Fn,e);}};var Te="gemini-2.0-flash",Ln="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",ao=provider.ChatModelSchema(T,b).parse({name:Te,description:Ln,maxInputTokens:1048576,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[Te]}),zo=C,Me=class extends u{constructor(e){super(ao,e);}};var Ge="gemini-2.5-flash-lite",Dn="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",ro=provider.ChatModelSchema(T,b).parse({name:Ge,description:Dn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Ge]}),Ho=C,be=class extends u{constructor(e){super(ro,e);}};var Pe="gemini-2.5-flash-preview-04-17",$n="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",lo=provider.ChatModelSchema(T,b).parse({name:Pe,description:$n,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Pe]}),Ko=C,_e=class extends u{constructor(e){super(lo,e);}};var Se="gemini-2.5-flash",jn="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",mo=provider.ChatModelSchema(T,b).parse({name:Se,description:jn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Se]}),Yo=C,Ee=class extends u{constructor(e){super(mo,e);}};var Oe="gemini-2.5-pro-preview-03-25",qn="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",po=provider.ChatModelSchema(T,b).parse({name:Oe,description:qn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[Oe]}),Vo=C,Re=class extends u{constructor(e){super(po,e);}};var we="gemini-2.5-pro",Hn="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",co=provider.ChatModelSchema(T,b).parse({name:we,description:Hn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[we]}),Jo=C,xe=class extends u{constructor(e){super(co,e);}};var ke="gemini-3-pro-preview",Yn="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",go=provider.ChatModelSchema(T,b).parse({name:ke,description:Yn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[ke]}),Xo=C,ve=class extends u{constructor(e){super(go,e);}};var Be=[types.EmbeddingTextModalityLiteral],je=zod.z.enum([types.EmbeddingTextModalityLiteral]);var Ct=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var Jn=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)})}),Tt=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Jn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var X=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),q=class{constructor(e,o){this.version="v1";let t=X.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl||$.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(t.getEmbeddingsUrl||`${this.baseUrl}/models/${this.modelName}:batchEmbedContents?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=Tt.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,i=t.model,l={outputDimensionality:t.outputDimensionality},m=types.Config().parse(provider.removeUndefinedEntries(l)),n={modality:types.EmbeddingTextModalityLiteral,requests:t.requests.reduce((r,s)=>(r.push(...s.content.parts.map(p=>p.text)),r),[])};return {modelName:i,config:m,embeddingRequests:n}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:t.error});let i=t.data;return Object.keys(i).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${m}',
16
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((m,n)=>{let s=this.modelSchema.config.def[n].param,p=i[n];return m[s]=p,m},{})}transformEmbeddingRequests(e){let o=types.EmbeddingRequests().safeParse(e);if(!o.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.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:o.data.requests.map(i=>({model:`models/${this.modelName}`,content:{parts:[{text:i}]}}))}}getGetEmbeddingsUrl(e,o){return S(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return S(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return S(this,null,function*(){return new Promise(t=>{let i=this.transformConfig(e),l=this.transformEmbeddingRequests(o);if(o.requests.length===0)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i.outputDimensionality&&(l.requests.forEach(m=>{m.outputDimensionality=i.outputDimensionality;}),delete i.outputDimensionality),t(_(_(_({},this.getDefaultParams()),i),l));})})}transformGetEmbeddingsResponse(e){let o=Ct.safeParse(e);if(o.success){let i=o.data.embeddings.map((l,m)=>({index:m,embedding:l.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var ho="text-embedding-001",ni="text-embedding-001",fo=provider.EmbeddingModelSchema(je).parse({name:ho,description:ni,modalities:Be,maxInputTokens:2048,maxOutputTokens:768,config:{def:B.base(768).def,schema:B.base(768).schema}}),Wo=X,Fe=class extends q{constructor(e){super(fo,e);}};var uo="text-embedding-004",si="text-embedding-004",yo=provider.EmbeddingModelSchema(je).parse({name:uo,description:si,modalities:Be,maxInputTokens:2048,maxOutputTokens:768,config:{def:B.base(768).def,schema:B.base(768).schema}}),Zo=X,Ne=class extends q{constructor(e){super(yo,e);}};
7
+ var bt=Object.defineProperty,Pt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var Po=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var W=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Ot=a=>{throw TypeError(a)};var _o=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,_=(a,e)=>{for(var t in e||(e={}))St.call(e,t)&&_o(a,t,e[t]);if(Po)for(var t of Po(e))Et.call(e,t)&&_o(a,t,e[t]);return a},N=(a,e)=>Pt(a,_t(e));var S=(a,e,t)=>new Promise((o,i)=>{var l=r=>{try{n(t.next(r));}catch(s){i(s);}},m=r=>{try{n(t.throw(r));}catch(s){i(s);}},n=r=>r.done?o(r.value):Promise.resolve(r.value).then(l,m);n((t=t.apply(a,e)).next());}),So=function(a,e){this[0]=a,this[1]=e;},qe=(a,e,t)=>{var o=(m,n,r,s)=>{try{var p=t[m](n),h=(n=p.value)instanceof So,P=p.done;Promise.resolve(h?n[0]:n).then(y=>h?o(m==="return"?m:"next",n[1]?{done:y.done,value:y.value}:y,r,s):r({value:y,done:P})).catch(y=>o("throw",y,r,s));}catch(y){s(y);}},i=m=>l[m]=n=>new Promise((r,s)=>o(m,n,r,s)),l={};return t=t.apply(a,e),l[W("asyncIterator")]=()=>l,i("next"),i("throw"),i("return"),l},Eo=a=>{var e=a[W("asyncIterator")],t=!1,o,i={};return e==null?(e=a[W("iterator")](),o=l=>i[l]=m=>e[l](m)):(e=e.call(a),o=l=>i[l]=m=>{if(t){if(t=!1,l==="throw")throw m;return m}return t=!0,{done:!1,value:new So(new Promise(n=>{var r=e[l](m);r instanceof Object||Ot("Object expected"),n(r);}),1)}}),i[W("iterator")]=()=>i,o("next"),"throw"in e?o("throw"):i.throw=l=>{throw l},"return"in e&&o("return"),i};var vt=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],Ft=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Oo=(a,e)=>a.replace(e,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,t=>t.toUpperCase()),Nt=vt.map(a=>({value:a,label:Oo(a,"HARM_CATEGORY_")})),Lt=Ft.map(a=>({value:a,label:Oo(a,"HARM_BLOCK_THRESHOLD_")})),ze=(a,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:a,step:.01,default:e}),He=a=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),Ke=a=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(a).title,description:provider.CHAT_CONFIG.STOP(a).description,max:a}),Ye=a=>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:a}),li=a=>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:a}),mi=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}),pi=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}),di=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),Ve=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"]}),Je=provider.PairedSelectConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",fields:[{key:"category",label:"Category",choices:Nt},{key:"threshold",label:"Threshold",choices:Lt}],uniqueByField:"category"}),Xe=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 Z=(a,e,t,o,i)=>zod.z.object({temperature:ze(a,e).schema,maxTokens:He(t).schema,stop:Ke(o).schema,topP:Ye(i).schema,toolChoice:Ve.schema,safetySettings:Je.schema}),Q=(a,e,t,o,i)=>({temperature:ze(a,e).def,maxTokens:He(t).def,stop:Ke(o).def,topP:Ye(i).def,toolChoice:Ve.def,safetySettings:Je.def});var Ro=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),wo=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"]}),oe=(a,e,t,o,i)=>N(_({},Q(a,e,t,o,i)),{responseFormat:wo.def,responseSchema:Ro.def}),te=(a,e,t,o,i)=>Z(a,e,t,o,i).extend({responseFormat:wo.schema,responseSchema:Ro.schema});var xo=(a,e,t,o,i)=>te(a,e,t,o,i).extend({reasoningEnabled:Xe.schema}),ko=(a,e,t,o,i)=>N(_({},oe(a,e,t,o,i)),{reasoningEnabled:Xe.def});var We=a=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:a,step:1,default:a});var Fo=a=>zod.z.object({dimensions:We(a).schema}),No=a=>({dimensions:We(a).def});var g={base:(a,e,t,o,i)=>({def:Q(a,e,t,o,i),schema:Z(a,e,t,o,i)}),responseSchema:(a,e,t,o,i)=>({def:oe(a,e,t,o,i),schema:te(a,e,t,o,i)}),reasoning:(a,e,t,o,i)=>({def:ko(a,e,t,o,i),schema:xo(a,e,t,o,i)})},A={base:a=>({def:No(a),schema:Fo(a)})};var jt="google",$=class{constructor(){this.version="v1";this.name=jt;this.chatModelFactories={[ne]:{model:ie,modelOptions:Io,modelSchema:Ze},[se]:{model:ae,modelOptions:Do,modelSchema:Qe},[re]:{model:le,modelOptions:Uo,modelSchema:eo},[me]:{model:pe,modelOptions:$o,modelSchema:oo},[de]:{model:ce,modelOptions:Ao,modelSchema:to},[ge]:{model:he,modelOptions:Bo,modelSchema:no},[fe]:{model:ue,modelOptions:jo,modelSchema:io},[ye]:{model:Ce,modelOptions:qo,modelSchema:so},[Te]:{model:Me,modelOptions:zo,modelSchema:ao},[Pe]:{model:_e,modelOptions:Ko,modelSchema:lo},[Oe]:{model:Re,modelOptions:Vo,modelSchema:po},[Se]:{model:Ee,modelOptions:Yo,modelSchema:mo},[we]:{model:xe,modelOptions:Jo,modelSchema:co},[ke]:{model:ve,modelOptions:Xo,modelSchema:go},[Ge]:{model:be,modelOptions:Ho,modelSchema:ro}};this.embeddingModelFactories={[ho]:{model:Fe,modelOptions:Wo,modelSchema:fo},[uo]:{model:Ne,modelOptions:Zo,modelSchema:yo}};}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
+ [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,i=this.chatModelFactories[t].modelOptions.parse(e);return new o(i)}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,i=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(i)}};$.baseUrl="https://generativelanguage.googleapis.com/v1beta";var f={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),Vt="model",Jt="function",M={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:Vt,tool:Jt};var G=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],b=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),Yi=[types.TextModalityLiteral],Vi=zod.z.enum([types.TextModalityLiteral]),Ji=[types.TextModalityLiteral,types.ImageModalityLiteral],Xi=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),Wi=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],Zi=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Xt=zod.z.object({text:zod.z.string()}),Wt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),et=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([Xt,Wt]))}).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()}),Zt=zod.z.object({text:zod.z.string()}),Qt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),To=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([Zt,Qt]))}).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 st=zod.z.object({text:zod.z.string().min(1)}),en=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),on=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),tn=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),nn=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),sn=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([st,en,on,tn,nn]))}),ot=zod.z.object({parts:zod.z.array(st)}),an=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),tt=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()})}),nt=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()}),it=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"])}),at=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(sn),systemInstruction:ot.optional(),system_instruction:ot.optional(),generationConfig:nt.optional(),generation_config:nt.optional(),safetySettings:zod.z.array(it).optional(),safety_settings:zod.z.array(it).optional(),tools:zod.z.object({function_declarations:zod.z.array(an)}).optional(),toolConfig:tt.optional(),tool_config:tt.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()}),u=class{constructor(e,t){this.version="v1";var i;let o=C.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((i=o.baseUrl)!=null?i:$.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(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformPdfMessages(e){return S(this,null,function*(){let t=n=>S(this,null,function*(){let r={};provider.isRunningInBrowser()||(r["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let s=yield fetch(n,{headers:r});if(!s.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=yield s.arrayBuffer();return new Uint8Array(p)}),o=n=>S(this,null,function*(){try{let r=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return null;let h=((yield r.json()).files||[]).find(P=>P.displayName===n);return h?h.uri:null}catch(r){return null}}),i=(n,r)=>S(this,null,function*(){let s=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":n.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:r}})});if(!s.ok)throw new provider.InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=s.headers.get("x-goog-upload-url");if(!p)throw new provider.InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};provider.isRunningInBrowser()||(h["Content-Length"]=n.length.toString());let P=yield fetch(p,{method:"POST",headers:h,body:n});if(!P.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${P.status}: ${P.statusText}`)});return (yield P.json()).file.uri}),l=n=>S(this,null,function*(){let r=yield o(n.file.id);if(r)return r;let s;if(n.value.type==="url")s=yield t(n.value.url);else {let p=n.value.base64,h="data:application/pdf;base64,";p=p.startsWith(h)?p.substring(h.length):p,s=provider.convertBase64ToUint8Array(p);}return yield i(s,n.file.id)}),m=[];for(let n of e){let r=[];for(let s of n.content)if(s.modality===types.PdfModalityLiteral){let p=yield l(s);r.push(N(_({},s),{value:{type:"url",url:p}}));}else r.push(s);m.push(N(_({},n),{content:r}));}return m})}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,i=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 l=o.system_instruction||o.systemInstruction,m=o.generation_config||o.generationConfig,n=o.safety_settings||o.safetySettings,r=o.tool_config||o.toolConfig;if(r&&(!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 s={};r&&(r.function_calling_config.mode==="ANY"&&r.function_calling_config.allowed_function_names&&r.function_calling_config.allowed_function_names.length===1?s.toolChoice=r.function_calling_config.allowed_function_names[0]:s.toolChoice=r.function_calling_config.mode.toLowerCase()),s.seed=m==null?void 0:m.seed,s.maxTokens=m==null?void 0:m.maxOutputTokens,s.temperature=m==null?void 0:m.temperature,s.topP=m==null?void 0:m.topP,s.presencePenalty=m==null?void 0:m.presencePenalty,s.frequencyPenalty=m==null?void 0:m.frequencyPenalty,s.stop=m==null?void 0:m.stopSequences,s.safetySettings=n;let p=types.Config().parse(provider.removeUndefinedEntries(s)),h=[];l&&l.parts.forEach(y=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:y.text}]});}),o.contents.forEach(y=>{let w=y.role;switch(w){case"user":{let k=y.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]}});h.push({role:w,content:k});}break;case"model":{let k=y.parts.map((E,F)=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ToolCallModalityLiteral,id:F.toString(),index:F,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=y.parts.map((E,F)=>({modality:types.ToolResponseModalityLiteral,id:F.toString(),index:F,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${y.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return o.tools&&o.tools.function_declarations.forEach(y=>{P.push({type:"function",definition:{schema:{name:y.name,description:y.description,parameters:y.parameters}}});}),{modelName:i,config:p,messages:h,tools:P.length>0?P:void 0}}transformConfig(e,t,o){let i=e.toolChoice;delete e.toolChoice;let l=this.modelSchema.config.schema.safeParse(e);if(!l.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:l.error});let m=l.data;Object.keys(m).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 n=Object.keys(m).reduce((p,h)=>{let P=this.modelSchema.config.def[h],y=P.param,w=m[h];return h==="reasoningEnabled"?p.thinkingConfig={includeThoughts:w}:h==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?N(_({},p.thinkingConfig),{thinkingBudget:w}):{thinkingBudget:w}:y==="maxOutputTokens"&&P.type==="range"&&w===0?p[y]=P.max:p[y]=w,p},{}),r=n.safetySettings;delete n.safetySettings;let s;if(i!==void 0){let p=i;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 h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(p))p==="any"?s={function_calling_config:{mode:"ANY",allowed_function_names:o.map(P=>P.definition.schema.name)}}:s={function_calling_config:{mode:p.toUpperCase()}};else if(o.map(P=>P.definition.schema.name).includes(p))s={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 [${h.choices.join(", ")}]`)})}}if("response_format"in n&&n.response_format!==void 0){let p=n.response_format;if(p==="json_schema"){let h=n.response_schema;if(!("response_schema"in n)||!n.response_schema||!(h!=null&&h.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'")});n.responseSchema=h.schema,n.responseMimeType="application/json","additionalProperties"in h.schema&&delete n.responseSchema.additionalProperties,delete n.response_format,delete n.response_schema;}else p==="json_object"?(n.responseSchema={type:"object"},delete n.response_format):p==="text"&&delete n.response_format;}return _(_({generation_config:n},s?{tool_config:s}:{}),r?{safety_settings:r}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=n=>{let r=n.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return r?n.substring(r[0].length):n},o=e.map(n=>{let r=types.Message().safeParse(n);if(!r.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:r.error});return r.data});o.forEach(n=>{n.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}',
12
+ available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
13
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},l=[];if(o.forEach(n=>{switch(n.role){case types.SystemRoleLiteral:n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)i.parts.push({text:r.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})});break;case types.AssistantRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ToolCallModalityLiteral)r.push({function_call:{name:s.name,args:JSON.parse(s.arguments)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.UserRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ImageModalityLiteral){if(s.value.type==="base64"){let p=s.value.base64;p=t(p),r.push({inline_data:{mime_type:`image/${s.value.mediaType}`,data:p}});}else if(s.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: '${s.value.type}'`)})}else if(s.modality===types.PdfModalityLiteral)if(s.value.type==="base64"){let p=s.value.base64;p=t(p),r.push({inline_data:{mime_type:"application/pdf",data:p}});}else s.value.type==="url"&&r.push({file_data:{mime_type:"application/pdf",file_uri:s.value.url}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.ToolRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.ToolResponseModalityLiteral)r.push({function_response:{name:s.name,response:JSON.parse(s.data)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
14
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),l[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 m=n=>n===this.modelSchema.roles[types.UserRoleLiteral]||n===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let n=1;n<l.length;n++)if(!m(l[n-1].role).includes(l[n].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${l[n].role}' after message with role : '${l[n-1].role}'`)});if(l[l.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&l[l.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:l},i.parts.length>0?{system_instruction:i}:{})}stripAdditionalProperties(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>this.stripAdditionalProperties(o));let t={};for(let[o,i]of Object.entries(e))o!=="additionalProperties"&&(t[o]=this.stripAdditionalProperties(i));return t}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(i=>{let l=types.Tool().safeParse(i);if(!l.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:l.error});return l.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,parameters:this.stripAdditionalProperties(i.definition.schema.parameters)}))}]}}getCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return S(this,null,function*(){let i=this.transformConfig(e,t,o),l=yield this.transformPdfMessages(t),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=o?this.transformTools(o):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformCompleteChatResponse(e){let t=et.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,i=[],l,m=o.candidates[0].content;if(m){let s=m.parts.map((p,h)=>{if("text"in p&&p.text!==void 0)return types.createTextContent(p.text);if("functionCall"in p&&p.functionCall!==void 0)return types.createToolCallContent(h,`${p.functionCall.name}_${h}`,p.functionCall.name,JSON.stringify(p.functionCall.args))});return i.push({role:types.AssistantRoleLiteral,content:s}),o.usageMetadata&&(l={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:i,usage:l,logProbs:void 0}}let n=o.candidates[0].safetyRatings;if(n&&n.length>0&&n.forEach(s=>{if(s.blocked)throw new provider.ModelResponseError({info:`Blocked content for category: ${s.category} with probability: ${s.probability}`,cause:new Error(`Blocked content for category: ${s.category} with probability: ${s.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 S(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return S(this,null,function*(){let i=this.transformConfig(e,t,o),l=yield this.transformPdfMessages(t),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=o?this.transformTools(o):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformStreamChatResponseChunk(e,t){return qe(this,null,function*(){let o=(t+e).split(",\r").filter(i=>i.trim()!=="");for(let i of o){let l=i;if(l=l.replace(/\n/g,""),l.startsWith("[")||l.startsWith(",{"))l=l.slice(1);else if(l.endsWith("]")){if(l==="]")return;l=l.slice(0,-1);}let m;try{m=JSON.parse(l);}catch(r){if(r instanceof SyntaxError){t=l;continue}else throw r}t="";let n=To.safeParse(m);if(n.success){let r={partialMessages:[]},s=n.data;if(s.candidates.length>0){let p=s.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((h,P)=>{if("text"in h&&h.text!==void 0&&r.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.text)),"functionCall"in h&&h.functionCall!==void 0){let y=h.functionCall;r.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,P,`${y.name}_${P}`,y.name,JSON.stringify(y.args)));}});}s.usageMetadata&&(r.usage={promptTokens:s.usageMetadata.promptTokenCount,completionTokens:s.usageMetadata.candidatesTokenCount,totalTokens:s.usageMetadata.totalTokenCount}),yield {partialResponse:r,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:n.error})}yield {partialResponse:{partialMessages:[]},buffer:t};})}transformProxyStreamChatResponseChunk(e,t,o,i,l){return qe(this,null,function*(){if((l==null?void 0:l.alt)!=="sse"){yield*Eo(this.transformStreamChatResponseChunk(e,t));return}let m=t+e,n=[],r="",s=0;for(;s<m.length;){let p=m.indexOf(`
15
+ `,s);if(p===-1){r=m.substring(s);break}else {let h=m.substring(s,p).trim();h&&n.push(h),s=p+1;}}for(let p of n){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let h=p.substring(6);try{let P=JSON.parse(h),y=To.safeParse(P);if(y.success){let w={partialMessages:[]},x=y.data;if(x.candidates.length>0){let k=x.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((E,F)=>{if("text"in E&&E.text!==void 0&&w.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.text)),"functionCall"in E&&E.functionCall!==void 0){let je=E.functionCall;w.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,F,`${je.name}_${F}`,je.name,JSON.stringify(je.args)));}});}x.usageMetadata&&x.usageMetadata.totalTokenCount&&x.usageMetadata.promptTokenCount&&x.usageMetadata.candidatesTokenCount&&(w.usage={promptTokens:x.usageMetadata.promptTokenCount,completionTokens:x.usageMetadata.candidatesTokenCount,totalTokens:x.usageMetadata.totalTokenCount}),yield {partialResponse:w,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:y.error})}catch(P){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${h}`,cause:P})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}getProxyCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{if(!o||Object.keys(o).length===0){i(this.streamChatUrl);return}let l=new URL(this.streamChatUrl);Object.entries(o).forEach(([m,n])=>{n!=null&&l.searchParams.set(m,n);}),i(l.toString());})})}getProxyCompleteChatHeaders(e,t,o){return S(this,null,function*(){if(!t)return {};let i=_({},t);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,t,o){return S(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in f))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var ne="gemini-1.5-flash-001",un="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,b).parse({name:ne,description:un,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ne]}),Io=C,ie=class extends u{constructor(e){super(Ze,e);}};var se="gemini-1.5-flash-002",Cn="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",Qe=provider.ChatModelSchema(T,b).parse({name:se,description:Cn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[se]}),Do=C,ae=class extends u{constructor(e){super(Qe,e);}};var re="gemini-1.5-flash-latest",Mn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",eo=provider.ChatModelSchema(T,b).parse({name:re,description:Mn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[re]}),Uo=C,le=class extends u{constructor(e){super(eo,e);}};var me="gemini-1.5-flash",bn="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",oo=provider.ChatModelSchema(T,b).parse({name:me,description:bn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[me]}),$o=C,pe=class extends u{constructor(e){super(oo,e);}};var de="gemini-1.5-pro-001",_n="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,b).parse({name:de,description:_n,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[de]}),Ao=C,ce=class extends u{constructor(e){super(to,e);}};var ge="gemini-1.5-pro-002",En="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",no=provider.ChatModelSchema(T,b).parse({name:ge,description:En,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ge]}),Bo=C,he=class extends u{constructor(e){super(no,e);}};var fe="gemini-1.5-pro-latest",Rn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",io=provider.ChatModelSchema(T,b).parse({name:fe,description:Rn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[fe]}),jo=C,ue=class extends u{constructor(e){super(io,e);}};var ye="gemini-1.5-pro",xn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",so=provider.ChatModelSchema(T,b).parse({name:ye,description:xn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ye]}),qo=C,Ce=class extends u{constructor(e){super(so,e);}};var ft="gemini-2.0-flash-exp",vn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Fn=provider.ChatModelSchema(T,b).parse({name:ft,description:vn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ft]}),$a=C,ut=class extends u{constructor(e){super(Fn,e);}};var Te="gemini-2.0-flash",Ln="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",ao=provider.ChatModelSchema(T,b).parse({name:Te,description:Ln,maxInputTokens:1048576,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[Te]}),zo=C,Me=class extends u{constructor(e){super(ao,e);}};var Ge="gemini-2.5-flash-lite",Dn="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",ro=provider.ChatModelSchema(T,b).parse({name:Ge,description:Dn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Ge]}),Ho=C,be=class extends u{constructor(e){super(ro,e);}};var Pe="gemini-2.5-flash-preview-04-17",$n="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",lo=provider.ChatModelSchema(T,b).parse({name:Pe,description:$n,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Pe]}),Ko=C,_e=class extends u{constructor(e){super(lo,e);}};var Se="gemini-2.5-flash",Bn="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",mo=provider.ChatModelSchema(T,b).parse({name:Se,description:Bn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Se]}),Yo=C,Ee=class extends u{constructor(e){super(mo,e);}};var Oe="gemini-2.5-pro-preview-03-25",qn="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",po=provider.ChatModelSchema(T,b).parse({name:Oe,description:qn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[Oe]}),Vo=C,Re=class extends u{constructor(e){super(po,e);}};var we="gemini-2.5-pro",Hn="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",co=provider.ChatModelSchema(T,b).parse({name:we,description:Hn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[we]}),Jo=C,xe=class extends u{constructor(e){super(co,e);}};var ke="gemini-3-pro-preview",Yn="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",go=provider.ChatModelSchema(T,b).parse({name:ke,description:Yn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[ke]}),Xo=C,ve=class extends u{constructor(e){super(go,e);}};var Ae=[types.EmbeddingTextModalityLiteral],Be=zod.z.enum([types.EmbeddingTextModalityLiteral]);var Ct=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var Jn=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)})}),Tt=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Jn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var X=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),q=class{constructor(e,t){this.version="v1";let o=X.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=Tt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,i=o.model,l={outputDimensionality:o.outputDimensionality},m=types.Config().parse(provider.removeUndefinedEntries(l)),n={modality:types.EmbeddingTextModalityLiteral,requests:o.requests.reduce((r,s)=>(r.push(...s.content.parts.map(p=>p.text)),r),[])};return {modelName:i,config:m,embeddingRequests:n}}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 i=o.data;return Object.keys(i).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${m}',
16
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((m,n)=>{let s=this.modelSchema.config.def[n].param,p=i[n];return m[s]=p,m},{})}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(i=>({model:`models/${this.modelName}`,content:{parts:[{text:i}]}}))}}getGetEmbeddingsUrl(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return S(this,null,function*(){return new Promise(o=>{let i=this.transformConfig(e),l=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")});i.outputDimensionality&&(l.requests.forEach(m=>{m.outputDimensionality=i.outputDimensionality;}),delete i.outputDimensionality),o(_(_(_({},this.getDefaultParams()),i),l));})})}transformGetEmbeddingsResponse(e){let t=Ct.safeParse(e);if(t.success){let i=t.data.embeddings.map((l,m)=>({index:m,embedding:l.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var ho="text-embedding-001",ni="text-embedding-001",fo=provider.EmbeddingModelSchema(Be).parse({name:ho,description:ni,modalities:Ae,maxInputTokens:2048,maxOutputTokens:768,config:{def:A.base(768).def,schema:A.base(768).schema}}),Wo=X,Fe=class extends q{constructor(e){super(fo,e);}};var uo="text-embedding-004",si="text-embedding-004",yo=provider.EmbeddingModelSchema(Be).parse({name:uo,description:si,modalities:Ae,maxInputTokens:2048,maxOutputTokens:768,config:{def:A.base(768).def,schema:A.base(768).schema}}),Zo=X,Ne=class extends q{constructor(e){super(yo,e);}};
17
17
 
18
18
  exports.BaseChatModel = u;
19
19
  exports.BaseChatModelOptions = C;
@@ -48,15 +48,15 @@ exports.Gemini1_5FlashSchema = oo;
48
48
  exports.Gemini1_5Pro = Ce;
49
49
  exports.Gemini1_5Pro001 = ce;
50
50
  exports.Gemini1_5Pro001Literal = de;
51
- exports.Gemini1_5Pro001Options = Bo;
51
+ exports.Gemini1_5Pro001Options = Ao;
52
52
  exports.Gemini1_5Pro001Schema = to;
53
53
  exports.Gemini1_5Pro002 = he;
54
54
  exports.Gemini1_5Pro002Literal = ge;
55
- exports.Gemini1_5Pro002Options = jo;
55
+ exports.Gemini1_5Pro002Options = Bo;
56
56
  exports.Gemini1_5Pro002Schema = no;
57
57
  exports.Gemini1_5ProLatest = ue;
58
58
  exports.Gemini1_5ProLatestLiteral = fe;
59
- exports.Gemini1_5ProLatestOptions = Ao;
59
+ exports.Gemini1_5ProLatestOptions = jo;
60
60
  exports.Gemini1_5ProLatestSchema = io;
61
61
  exports.Gemini1_5ProLiteral = ye;
62
62
  exports.Gemini1_5ProOptions = qo;
@@ -124,16 +124,16 @@ exports.GoogleChatToolRoleLiteral = Jt;
124
124
  exports.GoogleCompleteChatResponse = et;
125
125
  exports.GoogleCompleteChatTextResponse = Xt;
126
126
  exports.GoogleCompleteChatToolResponse = Wt;
127
- exports.GoogleEmbeddingModelConfigs = B;
128
- exports.GoogleEmbeddingModelModalities = Be;
129
- exports.GoogleEmbeddingModelModalitiesEnum = je;
127
+ exports.GoogleEmbeddingModelConfigs = A;
128
+ exports.GoogleEmbeddingModelModalities = Ae;
129
+ exports.GoogleEmbeddingModelModalitiesEnum = Be;
130
130
  exports.GoogleEmbeddingRequest = Tt;
131
131
  exports.GoogleEmbeddingRequestInput = Jn;
132
132
  exports.GoogleGetEmbeddingsResponse = Ct;
133
133
  exports.GoogleStreamChatResponse = To;
134
134
  exports.GoogleStreamChatTextResponse = Zt;
135
135
  exports.GoogleStreamChatToolResponse = Qt;
136
- exports.ProviderLiteral = At;
136
+ exports.ProviderLiteral = jt;
137
137
  exports.Text_Embedding_001 = Fe;
138
138
  exports.Text_Embedding_001Literal = ho;
139
139
  exports.Text_Embedding_001Options = Wo;