'use strict';var chunkQXMXSHYS_cjs=require('./chunk-QXMXSHYS.cjs'),chunkW6MVJKWN_cjs=require('./chunk-W6MVJKWN.cjs');var $={"gemini-2.5-pro":{input:1.25,output:10},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.0-flash":{input:.1,output:.4},"gemini-2.0-flash-lite":{input:.025,output:.1}};function v(h){let{apiKey:u,model:T="gemini-2.0-flash",maxOutputTokens:p,baseURL:m="https://generativelanguage.googleapis.com/v1beta",fetch:b=globalThis.fetch,timeoutMs:i,hooks:g,temperature:c,topP:l,stopSequences:n}=h;chunkW6MVJKWN_cjs.d(m),chunkQXMXSHYS_cjs.c(u,"createGeminiRunner");let o={};p!=null&&(o.maxOutputTokens=p),c!=null&&(o.temperature=c),l!=null&&(o.topP=l),n!=null&&(o.stopSequences=n);let s=Object.keys(o).length>0;return chunkW6MVJKWN_cjs.e({fetch:b,hooks:g,buildRequest:(t,r,a)=>({url:`${m}/models/${t.model??T}:generateContent`,init:{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":u},body:JSON.stringify({...t.instructions?{systemInstruction:{parts:[{text:t.instructions}]}}:{},contents:a.map(e=>({role:e.role==="assistant"?"model":"user",parts:[{text:e.content}]})),...s?{generationConfig:o}:{}}),...i!=null?{signal:AbortSignal.timeout(i)}:{}}}),parseResponse:async t=>{let r=await t.json(),a=r.candidates?.[0]?.content?.parts?.[0]?.text??"",e=r.usageMetadata?.promptTokenCount??0,f=r.usageMetadata?.candidatesTokenCount??0;return {text:a,totalTokens:e+f,inputTokens:e,outputTokens:f}}})}function B(h){let{apiKey:u,model:T="gemini-2.0-flash",maxOutputTokens:p,baseURL:m="https://generativelanguage.googleapis.com/v1beta",fetch:b=globalThis.fetch,hooks:i,temperature:g,topP:c,stopSequences:l}=h;chunkW6MVJKWN_cjs.d(m),chunkQXMXSHYS_cjs.c(u,"createGeminiStreamingRunner");let n={};p!=null&&(n.maxOutputTokens=p),g!=null&&(n.temperature=g),c!=null&&(n.topP=c),l!=null&&(n.stopSequences=l);let o=Object.keys(n).length>0;return async(s,t,r)=>{let a=chunkQXMXSHYS_cjs.e(i,s,t);try{let e=await b(`${m}/models/${s.model??T}:streamGenerateContent?alt=sse`,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":u},body:JSON.stringify({...s.instructions?{systemInstruction:{parts:[{text:s.instructions}]}}:{},contents:[{role:"user",parts:[{text:t}]}],...o?{generationConfig:n}:{}}),signal:r.signal});e.ok||await chunkQXMXSHYS_cjs.a(e,"Gemini");let f=chunkQXMXSHYS_cjs.b(e),{fullText:R,inputTokens:C,outputTokens:O}=await chunkQXMXSHYS_cjs.d(f,r.onToken,y=>{let d={},A=y.candidates?.[0]?.content?.parts?.[0]?.text;if(A&&(d.text=A),y.usageMetadata){let k=y.usageMetadata;k.promptTokenCount!==void 0&&(d.inputTokens=k.promptTokenCount),k.candidatesTokenCount!==void 0&&(d.outputTokens=k.candidatesTokenCount);}return d},"Gemini"),G={inputTokens:C,outputTokens:O},w=C+O;return r.onMessage?.({role:"assistant",content:R}),chunkQXMXSHYS_cjs.f(i,s,t,R,w,G,a),chunkQXMXSHYS_cjs.h(t,R,w,G)}catch(e){throw chunkQXMXSHYS_cjs.g(i,s,t,e,a),e}}}
exports.GEMINI_PRICING=$;exports.createGeminiRunner=v;exports.createGeminiStreamingRunner=B;//# sourceMappingURL=gemini.cjs.map
//# sourceMappingURL=gemini.cjs.map