dsh-cost-meter 1.9.37 → 1.9.39

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.
@@ -1,2 +1,2 @@
1
1
  // Generated from src/ledger-writer-worker.js by scripts/build.mjs; do not edit.
2
- import{workerData as ar}from"node:worker_threads";import{statSync as cr}from"node:fs";var v=["costCny","apiCostCny","costEur","apiCostEur"],Vt=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function _(e={}){let t={USD:1,CNY:7.2,EUR:.92};for(let o of["CNY","EUR"])Vt(e.fxRates?.[o])&&(t[o]=e.fxRates[o]);return["CNY","EUR"].includes(e.currency)&&Vt(e.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ze(e,t,o){let n=_(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Ie(e){return Object.fromEntries(v.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function ae(e,t,o=1){for(let n of v)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Zt(e,t){let o=n=>{let i=Ze(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of v)(!Number.isFinite(n[r])||n[r]<0)&&(n[r]=i[r]);for(let r of Object.values(n.byProviderModel??{}))r&&typeof r=="object"&&o(r);for(let r of n.sessions??[])o(r)};for(let n of Object.values(e??{}))o(n)}var Jt=["today","summary","budget"],Xt=e=>e&&typeof e=="object"&&!Array.isArray(e);function en(e){return Xt(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Xt(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Jt.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Jt.some(o=>!t[o]))):{}}import{readFileSync as Vi,renameSync as Ao,statSync as Zi}from"node:fs";import{randomUUID as ko}from"node:crypto";var tn=5/1e3,Uo=Date.parse("2026-11-01T00:00:00+08:00"),nn=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function on(e,t){return t.source==="server-tool"?e==="deepseek-search-server"&&t.kind==="search":[`deepseek-web-${t.kind}`,`deepseek-${t.kind}-api`].includes(e)}function rn(e,t){return!e||!["search","fetch"].includes(e.kind)||e.requests!==1?!1:e.source==="server-tool"?e.kind==="search"&&Number.isFinite(t)&&e.rateCny===(t<Uo?0:tn):e.source===void 0&&e.rateCny===tn}var Je=["input","output","cacheRead","cacheWrite","reasoning","calls"],B=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Q(e){let t=[];for(let[o,n]of Object.entries(e??{})){let i=n?.sessions;if(!Array.isArray(i)||!i.length||!(n.calls>0))continue;let r=new Set,a=v.filter(l=>i.every(m=>B(m?.[l]))),s=Object.fromEntries([...Je,"cost","apiCost",...a].map(l=>[l,0])),c=new Map,u=!0;for(let l of i){if(!l?.id||r.has(l.id)){u=!1;break}r.add(l.id);for(let m of Object.keys(s)){let A=m==="apiCost"?l.apiCost??l.cost:l[m]??0;if(!B(A)){u=!1;break}s[m]+=A}if(!u||s.apiCost>s.cost+1e-8){u=!1;break}for(let[m,A]of Object.entries(l.byProviderModel??{})){if(c.has(m)&&c.get(m)===null)continue;let f=c.get(m)??Object.fromEntries(Object.keys(s).map(k=>[k,0])),b=A!==null&&typeof A=="object";for(let k of Object.keys(f)){if(v.includes(k)&&!B(A?.[k])){delete f[k];continue}let g=k==="apiCost"?A?.apiCost??A?.cost:A?.[k]??0;if(!B(g)){b=!1;break}f[k]+=g}c.set(m,b?f:null)}}if(!u||!Object.values(s).every(B)||!Je.every(l=>B(n[l]??0)&&s[l]===(n[l]??0)))continue;let d=Math.abs(s.cost-(n.cost??0))>1e-8||Math.abs(s.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=s.cost,n.apiCost=s.apiCost);for(let l of a)Math.abs(s[l]-(n[l]??0))>1e-8&&(n[l]=s[l],d=!0);for(let[l,m]of c){let A=n.byProviderModel?.[l];if(!(!m||!A||!m.calls||!Object.values(m).every(B)||!Je.every(f=>m[f]===(A[f]??0)))&&!(Math.abs(m.cost-(A.cost??0))<=1e-8&&Math.abs(m.apiCost-(A.apiCost??A.cost??0))<=1e-8&&a.every(f=>!B(m[f])||Math.abs(m[f]-(A[f]??0))<=1e-8))){for(let f of a)B(m[f])&&(A[f]=m[f]);A.cost=m.cost,A.apiCost=m.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as Do,MessageChannel as jo,receiveMessageOnPort as sn}from"node:worker_threads";import{randomUUID as Ho}from"node:crypto";import{unlinkSync as Lo,rmdirSync as Bo}from"node:fs";import{join as Fo}from"node:path";function an(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new jo,a=new Int32Array(new SharedArrayBuffer(4)),s=!1,c,u,d,l=Ho(),m=new Promise(k=>{c=k}),A=new Do(n,{workerData:{...e,signal:a,port:r,lockId:l},transferList:[r],execArgv:[]}),f=k=>{if(!s){s=!0,clearTimeout(b);try{t(k)}finally{i.close(),A.terminate(),c()}}},b=setTimeout(()=>{u={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},A.terminate().then(()=>f(u))},o);return b.unref?.(),i.on("message",f),A.on("error",k=>{d={error:{message:k.message,code:k.code}}}),A.on("exit",k=>{if(!s){try{Lo(Fo(`${e.path}.lock`,`${process.pid}-${l}`)),Bo(`${e.path}.lock`)}catch{}f(sn(i)?.message??u??d??{error:{message:`Ledger worker exited (${k})`}})}}),{promise:m,wait(k=8e3){let g=Date.now()+k;for(;!s;){let M=sn(i);if(M){f(M.message);break}if(Date.now()>=g)return!1;Atomics.wait(a,0,0,Math.min(50,g-Date.now()))}return!0}}}function Xe(e){return["input","output","cacheRead","cacheWrite"].reduce((t,o)=>{let n=e?.[o];return t+(typeof n=="number"&&Number.isFinite(n)&&n>0?n:0)},0)}import{mkdirSync as po,readdirSync as Hi,writeFileSync as ho,readFileSync as Li,renameSync as Bi,unlinkSync as Ke,rmdirSync as ze,statSync as Fi,copyFileSync as Wi,constants as zi}from"node:fs";import{dirname as Ki,join as me}from"node:path";import{randomUUID as mo}from"node:crypto";import{isDeepStrictEqual as N}from"node:util";var cn=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,Wo=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,zo=/^(sk-[A-Za-z0-9_-]|rk-[A-Za-z0-9_-]|gsk_[A-Za-z0-9]|AIza[0-9A-Za-z_-]{10,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[bap]-|eyJ[A-Za-z0-9_-]{10,})/;function et(e,t){if(typeof t!="string"||t.length===0)return!1;if(cn.test(t)){let n=t.replace(new RegExp(cn.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(Wo.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||zo.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var ln="https://api.factory.ai/api/billing/limits";var un=e=>{if(e==null||e==="")return"";if(typeof e!="string")return null;let t=e.trim();return t===""||/^[A-Za-z0-9_.:-]{1,128}$/.test(t)?t:null};var Se="https://amr-api.open-design.ai/api/v1",Pr=Se+"/public/model-prices",tt=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],Nr=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var Ko=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function dn(e){return e===void 0||e===""?"":typeof e=="string"&&Ko(e.trim())?e.trim():null}import{homedir as nt}from"node:os";import{basename as Dr,dirname as jr,join as pn,resolve as $o}from"node:path";var fn=".dsh",Hr=`~/${fn}`,qo="DSH_HOME",Yo=".agents",Lr=`~/${Yo}`;function Go(){return pn(nt(),fn)}function Qo(e){return e==="~"?nt():e.startsWith("~/")||e.startsWith("~\\")?pn(nt(),e.slice(2)):e}function Vo(e,t,o,n){let i=t[o];return $o(Qo(e??(i!==void 0&&i.trim().length>0?i:n())))}function ot(e,t=process.env){return Vo(e,t,qo,Go)}var it=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var Xo=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var ss=672*60*60,as=744*60*60;var ys=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),As=Object.freeze(["CPA_REDIRECT_REFUSED","CPA_AUTH_FAILED","CPA_OUTER_HTTP_ERROR","CPA_INNER_HTTP_ERROR","CPA_RESPONSE_INVALID","PROVIDER_PARSE_ERROR","PROVIDER_CAPABILITY_MISSING","WORKBUDDY_PLUGIN_UNAVAILABLE","SOURCE_BLOCKED_BY_POLICY"]);var ei={opendesign:{label:"OpenDesign",credentialEnvs:["OPENDESIGN_CONTROL_KEY","VELA_CONTROL_KEY"],keyHint:"OpenDesign Control Key (quota only; not the inference API key)"},factory:{label:"Factory (Droid)",credentialEnvs:["FACTORY_API_KEY"],keyHint:"Factory \u989D\u5EA6\u67E5\u8BE2\u51ED\u636E(DSH \u51ED\u636E\u5E93 / FACTORY_API_KEY)"},anthropic:{label:"Anthropic (Claude Pro/Max)",credentialEnvs:["ANTHROPIC_OAUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN"],keyHint:"Claude Code OAuth access token(~/.claude/.credentials.json)"},zai:{label:"Z.ai / \u667A\u8C31 GLM Coding Plan",credentialEnvs:["ZAI_API_KEY","BIGMODEL_API_KEY"],keyHint:"Coding Plan \u4E13\u5C5E API Key(z.ai / bigmodel.cn \u63A7\u5236\u53F0)"},minimax:{label:"MiniMax Token Plan",credentialEnvs:["MINIMAX_API_KEY"],keyHint:"MiniMax API Key(sk-* / sk-cp-*)"},kimi:{label:"Kimi / Moonshot",credentialEnvs:["KIMI_CODING_API_KEY","MOONSHOT_API_KEY","KIMI_API_KEY"],keyHint:"Kimi Code \u8BA2\u9605 Key(sk-kimi-*,\u5373 coding \u63A8\u7406\u7AEF\u70B9\u7528\u7684 Key)\u663E\u793A\u672C\u5468/5 \u5C0F\u65F6\u914D\u989D;\u4EC5\u914D\u5F00\u653E\u5E73\u53F0 Key \u65F6\u663E\u793A PAYG \u4F59\u989D"},openrouter:{label:"OpenRouter",credentialEnvs:["OPENROUTER_API_KEY"],keyHint:"OpenRouter API Key(sk-or-*;\u663E\u793A\u9884\u4ED8 credits \u5DF2\u7528%)"},siliconflow:{label:"SiliconFlow \u7845\u57FA\u6D41\u52A8",credentialEnvs:["SILICONFLOW_API_KEY"],keyHint:"SiliconFlow API Key(sk-*;\u663E\u793A\u8D26\u6237\u4F59\u989D)"},commandcode:{label:"CommandCode",credentialEnvs:["COMMANDCODE_API_KEY"],keyHint:"commandcode.ai API Key(user_*;\u663E\u793A 5 \u5C0F\u65F6/\u5468\u7A97\u53E3\u7528\u91CF% \u4E0E\u6708\u5EA6 Credits \u4F59\u989D)"},clinepass:{label:"Cline Pass",credentialEnvs:["CLINE_PASS_API_KEY"],keyHint:"Cline Pass API Key(sk_*;\u663E\u793A 5 \u5C0F\u65F6/\u5468/\u6708\u4E09\u7A97\u53E3\u7528\u91CF%)"},scnet:{label:"SCNet \u8D85\u7B97\u4E92\u8054\u7F51 Token Plan",credentialEnvs:[],keyHint:"\u65E0\u9700\u51ED\u636E:\u6309\u5B98\u65B9 Credits \u62B5\u6263\u8868(2026-08-11 \u751F\u6548)\u7531\u672C\u5730\u8D26\u672C\u4F30\u7B97\u6708\u5EA6\u7528\u91CF"},volcengine:{label:"\u706B\u5C71\u65B9\u821F Volcano Ark Coding Plan",credentialEnvs:["VOLC_ACCESSKEY","VOLCENGINE_ACCESS_KEY_ID","VOLCENGINE_ACCESS_KEY","ARK_ACCESS_KEY_ID"],credentialEnvsSecret:["VOLC_SECRETKEY","VOLCENGINE_SECRET_ACCESS_KEY","VOLCENGINE_SECRET_KEY","ARK_SECRET_ACCESS_KEY"],keyHint:"\u706B\u5C71\u5F15\u64CE\u8BBF\u95EE\u5BC6\u94A5 AccessKeyID + SecretAccessKey(\u63A7\u5236\u53F0 IAM\u2192\u7528\u6237\u2192\u5BC6\u94A5,\u9700 ArkReadOnlyAccess + BillingCenterReadOnlyAccess;\u6216\u5BFC\u51FA VOLC_ACCESSKEY / VOLC_SECRETKEY)"},qwen:{label:"\u5343\u95EE Qwen Token Plan",credentialEnvs:[],keyHint:"\u672C\u5730\u4F30\u7B97\u65E0\u9700\u51ED\u636E\uFF1B\u5B98\u65B9 CLI \u6A21\u5F0F\u9700\u5728 DSH \u4E3B\u673A\u8FD0\u884C qianwen auth login"},mimo:{label:"\u5C0F\u7C73 MiMo Token Plan",credentialEnvs:["MIMO_COOKIE","XIAOMI_MIMO_COOKIE"],keyHint:"\u5C0F\u7C73\u5F00\u653E\u5E73\u53F0\u63A7\u5236\u53F0 Cookie(\u767B\u5F55 platform.xiaomimimo.com \u540E F12\u2192\u7F51\u7EDC\u2192balanceAlertConfig\u2192\u8BF7\u6C42\u5934 cookie \u6574\u6BB5\u590D\u5236)"},workbuddy:{label:"WorkBuddy \u79EF\u5206",credentialEnvs:[],keyHint:"\u65E0\u9700\u590D\u5236\u51ED\u636E;\u901A\u8FC7 dsh-workbuddy-connect \u67E5\u8BE2\u79EF\u5206\uFF0C\u517C\u5BB9\u65E7\u7248\u660E\u6587\u767B\u5F55\u6587\u4EF6"}},ce=Object.keys(ei);var st="https://platform.xiaomimimo.com/api/v1",ti={usage:`${st}/tokenPlan/usage`,detail:`${st}/tokenPlan/detail`,balance:`${st}/balance`},hn=["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"];var ni="open.volcengineapi.com";var oi="2024-01-01",ii=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var ri={"GLM-5.2":{input:7543,cachedInput:189,output:26400},"GLM-5.1":{input:8743,cachedInput:175,output:32057},"GLM-5":{input:8743,cachedInput:175,output:32057},"DeepSeek-V4-Pro":{input:10286,cachedInput:86,output:20571},"DeepSeek-V4-Flash":{input:1200,cachedInput:24,output:2400},"DeepSeek-V4-Flash-0731":{input:1543,cachedInput:31,output:3086},"Kimi-K3":{input:34286,cachedInput:343,output:171429},"Kimi-K2.7-Code":{input:8357,cachedInput:167,output:34714},"Kimi-K2.6":{input:8357,cachedInput:167,output:34714},"Kimi-K2.5":{input:5143,cachedInput:103,output:27e3},"MiniMax-M3":{input:3600,cachedInput:72,output:14400},"MiniMax-M2.7":{input:3600,cachedInput:72,output:14400},"MiniMax-M2.5":{input:2520,cachedInput:50,output:10080},"Qwen3.8-max":{input:18514,cachedInput:231,output:49371}};function mn(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var Qs=Object.fromEntries(Object.entries(ri).map(([e,t])=>[mn(e),t]));var gn=["scnet","scnet-tokenplan","scnet-token-plan"];var si={"qwen3.8-max-preview":{input:60,cachedInput:6,output:60},"qwen3.7-max":{input:60,cachedInput:6,output:60},"qwen3.7-plus":{input:15,cachedInput:1.5,output:60},"qwen3.6-flash":{input:3,cachedInput:.3,output:12},"glm-5.2":{input:45,cachedInput:4.5,output:120},"deepseek-v4-pro":{input:45,cachedInput:4.5,output:90},"deepseek-v4-flash":{input:3,cachedInput:.3,output:12},"kimi-k2.7-code":{input:30,cachedInput:3,output:60},"kimi-k2.6":{input:30,cachedInput:3,output:60},"minimax-m2.5":{input:30,cachedInput:3,output:60}},Vs=Object.fromEntries(Object.entries(si).map(([e,t])=>[mn(e),t])),bn=["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"];var Zs={opendesign:[Se+"/workspaces/{workspaceId}/billing/preflight",Se+"/workspaces/{workspaceId}/wallet/balance"],factory:[ln],anthropic:["https://api.anthropic.com/api/oauth/usage"],zai:["https://open.bigmodel.cn/api/monitor/usage/quota/limit","https://api.z.ai/api/monitor/usage/quota/limit","https://api.z.ai/api/coding/paas/v3/dashboard/billing/coding_plan/usage","https://open.bigmodel.cn/api/coding/paas/v3/dashboard/billing/coding_plan/usage","https://api.z.ai/api/coding/paas/v4/dashboard/billing/coding_plan/usage","https://open.bigmodel.cn/api/coding/paas/v4/dashboard/billing/coding_plan/usage"],minimax:["https://www.minimax.cn/v1/token_plan/remains","https://www.minimax.io/v1/token_plan/remains","https://www.minimaxi.com/v1/token_plan/remains","https://www.minimax.cn/v1/api/openplatform/coding_plan/remains","https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains"],kimi:["https://api.kimi.com/coding/v1/usages","https://api.kimi.com/coding/v1/usage","https://api.moonshot.cn/v1/users/me/balance"],openrouter:["https://openrouter.ai/api/v1/credits"],siliconflow:["https://api.siliconflow.cn/v1/user/info"],commandcode:["https://api.commandcode.ai/alpha/billing/credits"],clinepass:["https://api.cline.bot/api/v1/users/me/plan/usage-limits"],scnet:[],qwen:[],volcengine:ii.map(e=>`https://${ni}/?Action=${e}&Version=${oi}`),mimo:[ti.usage],workbuddy:[]};function yn(e){if(e===void 0||e==="")return"";if(typeof e!="string"||e.length>2048)return null;let t=e.trim();if(!t)return"";if(!/^https:\/\/[^/?#]+\/?$/i.test(t)||/[\s\\@?#]/.test(t))return null;try{let o=new URL(t);return!o.hostname||o.username||o.password||o.pathname!=="/"?null:o.origin}catch{return null}}var at=/^(base|offPeak|peak|legacyBase|longContext|cny)\.(cacheHit|cacheMiss|cacheWrite|output|reasoning)$/;function Ee(e){return Object.fromEntries(["multiplier","separateMultipliers","multipliers"].filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function An(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function ct(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*An(t,o+"."+i));return e.longContext&&(n.longContext={...ct(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function kn(e){let t=Ee(e);return t.multipliers&&(t.multipliers=Object.fromEntries(Object.entries(t.multipliers).filter(([o])=>o.startsWith("cny.")).map(([o,n])=>[o.replace("cny.","base."),n]))),{...e.cny,...t}}function lt(e){if(e.multiplier===void 0&&e.separateMultipliers===void 0&&e.multipliers===void 0)return!0;let t=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0;if(e.multiplier!==void 0&&!t(e.multiplier)||e.separateMultipliers!==void 0&&typeof e.separateMultipliers!="boolean"||e.multipliers!==void 0&&(!e.multipliers||typeof e.multipliers!="object"||Array.isArray(e.multipliers)||Object.entries(e.multipliers).some(([o,n])=>!at.test(o)||!t(n))))return!1;for(let o of[e,...e.rateHistory??[]])for(let n of["base","offPeak","peak","legacyBase","longContext","cny"]){let i=n==="base"?o:o[n];if(i){for(let r of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])if(i[r]!==void 0&&!Number.isFinite(i[r]*An(e,n+"."+r)))return!1}}return!0}var ut={"opencode-zen":{models:{"deepseek-v4.1-flash-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"cat-jam-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"step-5-preview-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"exo-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"mistral-large-4":{input:.68,output:2.09,cachedInput:.07,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15",notes:"Current published gateway rate; independent of the direct API."},"claude-sonnet-5-5":{input:2,output:10,cachedInput:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,output:2.5,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"gemini-4-argon":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15",notes:"Current published promotional rate; gateway pricing is independent of the direct API."},"gpt-6.1-sol":{input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"}}},"opencode-go":{models:{"step-5-preview-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"cat-jam-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"space-bunny":{input:.15,output:.6,cachedInput:.03,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,output:2.5,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"gemini-4-argon-contributor":{input:4,output:20,cachedInput:.2,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15",notes:"Current published promotional rate; gateway pricing is independent of the direct API."}}},anthropic:{models:{"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-15",cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,cacheWrite:.625,output:2.5},notes:"Standard global API; cache writes use 5-minute TTL. Prompts over 100000 tokens, including cache reads/writes, use the higher tier for the entire request. 1-hour TTL and fast/regional surcharges are excluded."},"claude-sonnet-5-5":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-15",cacheWrite:2.5,notes:"Standard global API; 5-minute cache writes. Direct API cache-read rate differs from OpenCode Zen."}}},google:{models:{"gemini-4-argon":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard paid tier. Promotional USD 2/10/0.10 input/output/cache read through 2026-11-30; official announced prices from 2026-12-01 are USD 4/20/0.20. Implicit caching only. Recheck the catalog when the promotion ends; the source does not specify a timezone."}}},mistral:{models:{"mistral-large-4":{input:.68,output:2.09,cachedInput:.07,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-15",notes:"Current published sale price: 50% off USD 1.36/4.18/0.14 input/output/cached input. Public-preview model ID from https://docs.mistral.ai/models/mistral-large-4-0 . No promotion end date is published."}}},openai:{models:{"gpt-rosalind-research":{input:5,output:25,cachedInput:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard global API token price. Trusted-access model; catalog inclusion does not grant access. Research billing begins 2026-10-05. Cache-write pricing does not apply."},"gpt-rosalind-discovery":{input:5,output:25,cachedInput:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard global API token price. Trusted-access model; catalog inclusion does not grant access. Research billing begins 2026-10-05. Cache-write pricing does not apply."},"gpt-5.6-cyber":{input:12.5,output:75,cachedInput:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",cacheWrite:15.625,notes:"Standard global API token price for the restricted-access cyber model. No separate long-context rate is published."}}}};var ai="https://platform.stepfun.ai/docs/en/guides/pricing/details",le=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:ai,checkedAt:"2026-10-16",notes:"StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."}),wn={models:{"step-5-preview":le(1,.1,2.7),"step-3.7-flash":le(.2,.04,1.15),"step-3.5-flash":le(.1,.02,.3),"step-3.5-flash-2603":le(.1,.02,.3),"step-1o-turbo-vision":le(.36,.07,1.15)}};var xe={openai:{models:{"gpt-6-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5}},"gpt-6.1-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5}},"gpt-6-luna":{input:.1,output:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,cacheHit:.02,output:.75,cacheWrite:.25}},"gpt-6-astra":{input:10,output:50,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,output:75,cacheWrite:25}},"gpt-5.6-sol":{input:4,output:20,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,cacheHit:.8,output:30,cacheWrite:10}},"gpt-5.6-terra":{input:2,output:12,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:18,cacheWrite:5}},"gpt-5.6-luna":{input:.2,output:1.2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,cacheHit:.04,output:1.8,cacheWrite:.5}},"gpt-5.5":{input:5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,cacheHit:1,output:45}},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Published direct Standard rates: short input30/output180; long input60/output270 USD/M. The pricing table labels short context<272K, but the model detail does not establish the exact equality/context counting rule. Intentionally unpriced pending clarification; no guessed boundary.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270},unpriced:!0},"gpt-5.4":{input:2.5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,cacheHit:.5,output:22.5}},"gpt-5.4-mini":{input:.75,output:4.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},"gpt-5.4-nano":{input:.2,output:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.02},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270}},"gpt-5.2":{input:1.75,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.175},"gpt-5.2-pro":{input:21,output:168,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-5.1":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5-mini":{input:.25,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-5-nano":{input:.05,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.005},"gpt-5-pro":{input:15,output:120,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4.1":{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"gpt-4.1-mini":{input:.4,output:1.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.1},"gpt-4.1-nano":{input:.1,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-4o":{input:2.5,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:1.25},"gpt-4o-2024-05-13":{input:5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4o-mini":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},o1:{input:15,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:7.5},"o1-pro":{input:150,output:600,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"o3-pro":{input:20,output:80,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},o3:{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"o4-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.275},"o3-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.55},"gpt-4-turbo-2024-04-09":{input:10,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4-0613":{input:30,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-0125":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-1106":{input:1,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-instruct":{input:1.5,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"davinci-002":{input:2,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"babbage-002":{input:.4,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"chat-latest":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for ChatGPT. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Codex. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5-search-api":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Search. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."}}},anthropic:{models:{"claude-fable-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-5-5":{input:4,cachedInput:.2,cacheWrite:5,output:20,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is8USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-5-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-haiku-4-5":{input:1,cachedInput:.1,cacheWrite:1.25,output:5,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is2USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-mythos-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-fable-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-mythos-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-opus-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-8":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-7":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-6":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-sonnet-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-6":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is6USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-5":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Current direct Claude Sonnet 4.5: maximum 200K context; 1M beta retired 2026-04-30 and over-limit requests fail. Standard rates for valid requests; 5-minute cache writes3.75USD/M, 1-hour writes6USD/M need TTL-specific accounting. Zen publishes a separate route with a long-context tier. Sources: https://platform.claude.com/docs/en/build-with-claude/context-windows and https://platform.claude.com/docs/en/release-notes/overview."}}},google:{models:{"gemini-3.8-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.7-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.6-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.1-flash-lite":{input:.25,cachedInput:.025,output:1.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid text/image/video input. Audio input0.50/cacheRead0.05 USD/M is a different modality; this generic token row cannot price that accurately. Cache storage1USD/M/hour and grounding excluded."}}},xai:{models:{"grok-4.7":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2,cacheHit:.4,output:4}},"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:.6,output:12}},"grok-4.3":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-multi-agent-0309":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-non-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-large-latest":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3-5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-latest":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-2603":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-latest":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-2512":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-latest":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-2512":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-latest":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-2512":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-latest":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"zai-glm-5-3":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-5":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-latest":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"codestral-2508":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-latest":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-embed-2505":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."},"codestral-embed":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."}}},"z-ai":{models:{"glm-5.3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3-flashx":{input:.37,output:1.25,cachedInput:.075,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.2":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.1":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5":{input:1,output:3.2,cachedInput:.2,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flashx":{input:.07,output:.4,cachedInput:.01,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-x":{input:2.2,output:8.9,cachedInput:.45,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-air":{input:.2,output:1.1,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-airx":{input:1.1,output:4.5,cachedInput:.22,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4-32b-0414-128k":{input:.1,output:.1,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v":{input:.3,output:.9,cachedInput:.05,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5v":{input:.6,output:1.8,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-ocr":{input:.03,output:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Official direct token pricing row. Separate Layout Parsing API can charge per page; this token entry cannot price page billing."}}},"opencode-zen":{models:{"big-pickle":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.5-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.1-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.0-flash-fin-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3-ultra-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3.5-lightning-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"muse-spark-1.3-contributor-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"jev-1.13-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0},"jev-1.13":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.042,output:0},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:3.2,cachedInput:.2},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"kimi-k2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.6,output:3,cachedInput:.1},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:7.5,cachedInput:.5,cacheWrite:3.125},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5},"qwen3.6-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05,cacheWrite:.625},"qwen3.5-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25},"deepseek-v4.1-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"deepseek-v4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.74,output:3.48,cachedInput:.145},"deepseek-v4-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"deepseek-v4-flash-vision-exp":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"claude-fable-5-1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:.25,cacheWrite:12.5},"claude-fable-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5},"claude-opus-5-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.2,cacheWrite:5},"claude-opus-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-8":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-sonnet-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5},"claude-sonnet-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75},"claude-sonnet-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75,longContext:{aboveInputTokens:2e5,cacheMiss:6,output:22.5,cacheHit:.6,cacheWrite:7.5}},"claude-haiku-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:5,cachedInput:.1,cacheWrite:1.25},"gemini-3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.7-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.5-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:9,cachedInput:.15},"gemini-3.5-flash-lite":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:2.5,cachedInput:.03},"gemini-3.1-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:18,cacheHit:.4}},"gemini-3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.3,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:.6}},"grok-build-0.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:2,cachedInput:.2},"muse-spark-1.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"muse-spark-1.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"gpt-6-astra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25}},"gpt-6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5}},"gpt-6.1-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10}},"gpt-5.6-terra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}},"gpt-5.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:30,cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,output:45,cacheHit:1}},"gpt-5.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:15,cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,output:22.5,cacheHit:.5}},"gpt-5.4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.75,output:4.5,cachedInput:.075},"gpt-5.4-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.25,cachedInput:.02},"gpt-5.3-codex-spark":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.3-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:10,cachedInput:.125},"gpt-5.1-codex-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.25,output:2,cachedInput:.025},"gpt-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.05,output:.4,cachedInput:.005}}},"opencode-go":{models:{"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"longcat-2.0":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.6-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"mimo-v2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06,cacheWrite:.375},"muse-spark-1.3-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"muse-spark-1.2-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5,longContext:{aboveInputTokens:256e3,cacheMiss:1.2,output:4.8,cacheHit:.12,cacheWrite:1.5}},"deepseek-v4.1-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-pro":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.66,output:1.98,cacheHit:.022},input:.66,output:1.98,cachedInput:.022,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:1.32,output:3.96,cacheHit:.044}},"deepseek-v4-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-flash-vision-exp":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"hy4-preview":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.834,output:2.501,cachedInput:.042},hy3:{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.58,cachedInput:.035},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}}}}},dt=Object.fromEntries([...new Set([...Object.keys(xe),...Object.keys(ut)])].map(e=>[e,{models:{...xe[e]?.models,...ut[e]?.models}}]));dt.stepfun=wn;var Mn={"claude-fable-5":{cacheMiss:10,output:50,cacheHit:1,cacheWrite:12.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-fable-5.1":{cacheMiss:10,output:50,cacheHit:.25,cacheWrite:12.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-haiku-5.5":{cacheMiss:.1,output:.5,cacheHit:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,output:2.5,cacheHit:.05,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-4.8":{cacheMiss:5,output:25,cacheHit:.5,cacheWrite:6.25,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-5":{cacheMiss:5,output:25,cacheHit:.5,cacheWrite:6.25,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-5.5":{cacheMiss:4,output:20,cacheHit:.2,cacheWrite:5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-sonnet-5":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-sonnet-5.5":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4.1-flash":{cacheMiss:.3,output:1.2,cacheHit:.006,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-flash":{cacheMiss:.44,output:1.32,cacheHit:.014,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-flash-vision-exp":{cacheMiss:.44,output:1.32,cacheHit:.014,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-pro":{cacheMiss:1.32,output:3.96,cacheHit:.044,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gemini-3.7-flash":{cacheMiss:.75,output:3.75,cacheHit:.075,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gemini-3.8-flash":{cacheMiss:.75,output:3.75,cacheHit:.075,cacheWrite:.08333,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.2":{cacheMiss:1.4,output:4.4,cacheHit:.26,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.3-flash":{cacheMiss:.075,output:.25,cacheHit:.015,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.3-flashx":{cacheMiss:.37,output:1.25,cacheHit:.075,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-luna":{cacheMiss:.2,output:1.2,cacheHit:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-sol":{cacheMiss:4,output:20,cacheHit:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-terra":{cacheMiss:2,output:12,cacheHit:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6.1-sol":{cacheMiss:2,output:10,cacheHit:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-astra":{cacheMiss:10,output:50,cacheHit:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-luna":{cacheMiss:.1,output:.5,cacheHit:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-sol":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.5":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.6":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.7":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"hy4-preview":{cacheMiss:.834,output:2.501,cacheHit:.042,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"kimi-k2.7-code":{cacheMiss:.95,output:4,cacheHit:.19,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"kimi-k3":{cacheMiss:3,output:15,cacheHit:.3,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"mimo-v2.6-flash":{cacheMiss:.14,output:.28,cacheHit:.0028,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"mimo-v2.6-pro":{cacheMiss:.435,output:.87,cacheHit:.0036,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"muse-spark-1.3":{cacheMiss:1.25,output:4.25,cacheHit:.15,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"muse-wonder":{cacheMiss:4,output:20,cacheHit:.2,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"qwen3.7-max":{cacheMiss:2.5,output:7.5,cacheHit:.5,cacheWrite:3.125,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"}};var Sn="2026-08-01T00:00:00Z",gt="2026-08-22T16:00:00Z",ve=["2026-09-25","2026-09-26","2026-09-27","2026-10-01","2026-10-02","2026-10-03","2026-10-04","2026-10-05","2026-10-06","2026-10-07"],pt="2026-09-10T04:00:00Z",ci="2026-08-31T00:00:00Z",In=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function li(e){if(!Number.isFinite(e)||e<Date.parse(gt))return null;let t=Math.floor((e+8*36e5)/864e5),o=(t+4)%7;if(o!==6&&o!==0)return null;let n=o===6?t:t-1,i=Math.max(n*864e5-8*36e5,Date.parse(gt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function ui(e,t=ve){if(!Number.isFinite(e)||e<Date.parse(gt)||!Array.isArray(t))return null;let o=Math.floor((e+8*36e5)/864e5),n=new Date(o*864e5).toISOString().slice(0,10);return t.includes(n)?{start:o*864e5-8*36e5,end:(o+1)*864e5-8*36e5}:null}var di=(e,t)=>ui(e,t)??li(e),pi="2026-08-16T16:00:00Z";var En=[{start:1,end:4},{start:6,end:10}],ue={openai:{models:{"gpt-6-astra":{input:10,cachedInput:1,cacheWrite:12.5,output:50,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,cacheWrite:25,output:75},billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/models/gpt-6-astra",checkedAt:"2026-09-11",notes:"\u6807\u51C6 API \u4EF7\uFF0COpenCode Zen \u540C\u4EF7\uFF1B\u5B8C\u6574\u8F93\u5165\uFF08\u542B\u7F13\u5B58\u8BFB\u5199\uFF09\u8D85\u8FC7 272K \u65F6\u6574\u6B21\u8BF7\u6C42\u6309\u957F\u4E0A\u4E0B\u6587\u6863\u8BA1\u8D39\uFF1B\u4E0D\u542B Batch/Flex/Fast \u670D\u52A1\u6863\u6298\u6263\u6216\u500D\u7387"},"gpt-5.6-sol":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $4/$15 \u8BA1(\u7F13\u5B58\u8BFB $0.40\u3001\u5199\u5165 $5);\u7F13\u5B58\u5199\u5165 $2.50;\u76EE\u5F55\u6807\u6CE8 2026-09-18 \u524D\u4E3A\u4E94\u6298\u4FC3\u9500\u4EF7(issue #58)"},"gpt-5.6-terra":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $4/$18 \u8BA1;\u7F13\u5B58\u5199\u5165 $2.50"},"gpt-5.6-luna":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $0.40/$1.80 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.25"},"gpt-5.5":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $10/$45 \u8BA1"},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4":{input:2.5,cachedInput:.25,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $5/$22.5 \u8BA1"},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4-mini":{input:.75,cachedInput:.075,output:4.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4-nano":{input:.2,cachedInput:.02,output:1.25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.3-codex-spark":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.2":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.2-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.1-codex":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1-codex-max":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1-codex-mini":{input:.25,cachedInput:.025,output:2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5-codex":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5-nano":{input:.05,cachedInput:.005,output:.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5-2025-08-07":{input:1.25,cachedInput:.13,output:10,billingMode:"flat",notes:"2025-08 \u9996\u53D1\u4EF7;\u5F53\u524D\u540C\u540D gpt-5 \u5DF2\u8C03\u4EF7,\u5386\u53F2 id \u4FDD\u7559"},"gpt-4.1-2025-04-14":{input:2,cachedInput:.5,output:8,billingMode:"flat"},"gpt-4.1-mini-2025-04-14":{input:.4,cachedInput:.1,output:1.6,billingMode:"flat"}}},anthropic:{models:{"claude-fable-5":{input:10,cachedInput:1,output:50,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $12.50"},"claude-opus-5":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-opus-4-8":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-opus-4-7":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"claude-opus-4-6":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"claude-opus-4-5":{input:5,cachedInput:.5,output:25,billingMode:"flat",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-sonnet-5":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u65E9\u9E1F\u4EF7(\u81F3 2026-08-31);\u6807\u51C6\u4EF7 $3/$15"},"claude-sonnet-4-6":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $3.75"},"claude-sonnet-4-5":{input:3,cachedInput:.3,output:15,billingMode:"flat",notes:"\u2264200K \u6863;>200K \u6309 $6/$22.5 \u8BA1;\u7F13\u5B58\u5199\u5165 $3.75"},"claude-haiku-4-5":{input:1,cachedInput:.1,output:5,billingMode:"flat",notes:"\u7F13\u5B58\u5199\u5165 $1.25"}}},google:{models:{"gemini-3.7-flash":{input:.75,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"2026 \u5E74\u5E95\u524D\u4FC3\u9500\u4EF7;2027 \u8D77 $1.5/$7.5;Go \u7F51\u5173\u6309 $1.5/$7.5"},"gemini-3.6-flash":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.5-flash":{input:1.5,cachedInput:.15,output:9,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.5-flash-lite":{input:.3,cachedInput:.03,output:2.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.1-pro-preview":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$18 \u8BA1"},"gemini-3.1-pro":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25",notes:"\u2264200K \u6863;>200K \u6309 $4/$18 \u8BA1"},"gemini-3-flash":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"Preview"},"gemini-2.5-pro":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",notes:"\u2264200K \u6863;>200K \u6309 $2.5/$15 \u8BA1"},"gemini-2.5-flash":{input:.3,cachedInput:.03,output:2.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-2.5-flash-lite":{input:.1,cachedInput:.01,output:.4,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"}}},moonshot:{models:{"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u4EBA\u6C11\u5E01\u4EF7 \xA520/\xA5100/\u7F13\u5B58\xA52 \u6BCF\u767E\u4E07;\u6B64\u5904\u4E3A Go \u7F51\u5173\u7F8E\u5143\u4EF7"},"kimi-k2.7-code":{input:.95,cachedInput:.19,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.6":{input:.95,cachedInput:.16,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.5":{input:.6,cachedInput:.1,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-08-05 \u8D77\u5F03\u7528"}}},"z-ai":{models:{"glm-5.3":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01",notes:"\u667A\u8C31\u56FD\u5185\u76F4\u8FDE \xA58/\xA528/\u7F13\u5B58\xA52(\u7EA6 1.11/3.89/0.28 USD,\u76EE\u5F55\u4EF7\u7565\u9AD8\u4E8E\u76F4\u8FDE)"},"glm-5.3-flash":{input:.15,cachedInput:.03,output:.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01",notes:"Ox Alpha \u666E\u60E0\u7248(2026-08-26 \u53D1\u5E03,\u539F\u751F\u591A\u6A21\u6001);Go \u76EE\u5F55\u4E0E Cloudflare \u76EE\u5F55\u540C\u4EF7"},"glm-5.2":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"glm-5.1":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"glm-5":{input:1,cachedInput:.2,output:3.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-05-14 \u8D77\u5F03\u7528"}}},xai:{models:{"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$12 \u8BA1"},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$12 \u8BA1"},"grok-4.3":{input:1.25,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/models/grok-4.3"},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"}}},alibaba:{models:{"qwen3.8-max":{input:2,cachedInput:.25,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $2.50"},"qwen3.7-max":{input:2.5,cachedInput:.5,output:7.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $3.125"},"qwen3.7-plus":{input:.4,cachedInput:.04,output:1.6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u2264256K \u6863;>256K \u6309 $1.2/$4.8 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.50"},"qwen3.6-plus":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u2264256K \u6863;>256K \u6309 $2/$6 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.625"},"qwen3.5-plus":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $0.25"},"qwen3-plus":{input:.4,output:1.2,billingMode:"flat",sourceUrl:"https://www.alibabacloud.com/help/en/model-studio/model-pricing"}}},minimax:{models:{"minimax-m3":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"minimax-m2.7":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"minimax-m2.5":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-08-05 \u8D77\u5F03\u7528"}}},tencent:{models:{"hunyuan-a13b":{input:.0694,output:.2778,billingMode:"flat",notes:"\u5B98\u65B9\u4EF7\u4E3A CNY \xA50.5/\xA52 \u6BCF\u767E\u4E07 token,\u6309\u9ED8\u8BA4\u5C55\u793A\u6C47\u7387 7.2 \u6298\u7B97\u4E3A USD \u5165\u8D26"},hy3:{input:.14,cachedInput:.035,output:.58,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"OpenCode Go \u76EE\u5F55\u4EF7;\u5382\u5546\u5F52\u5C5E\u672A\u5B98\u5BA3"}}},xiaomi:{models:{"mimo-v2.6-pro":{input:.435,cachedInput:.0036,output:.87,cny:{cacheHit:.025,cacheMiss:3,output:6},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u6279\u91CF\u63A8\u7406\u6309\u534A\u4EF7"},"mimo-v2.6-flash":{input:.14,cachedInput:.0028,output:.28,cny:{cacheHit:.02,cacheMiss:1,output:2},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u6279\u91CF\u63A8\u7406\u6309\u534A\u4EF7"},"mimo-v2.6-pro-ultraspeed":{input:4.35,cachedInput:.036,output:8.7,cny:{cacheHit:.25,cacheMiss:30,output:60},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u901F\u5EA6\u4F18\u5148\u6863;\u5B98\u65B9\u672A\u63D0\u4F9B\u6279\u91CF\u63A8\u7406\u6863"},"mimo-v2.5":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u6807\u6CE8\u5373\u5C06\u4E0B\u7EBF,\u7531 mimo-v2.6-flash \u63A5\u66FF"},"mimo-v2.5-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u6807\u6CE8\u5373\u5C06\u4E0B\u7EBF,\u7531 mimo-v2.6-pro \u63A5\u66FF"}}},upstage:{models:{"solar-pro4":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://www.upstage.ai/pricing/api"},"solar-pro3":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://www.upstage.ai/pricing/api"}}},meta:{models:{"muse-spark-1.2":{input:1.25,cachedInput:.15,output:4.25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25"}}},meituan:{models:{"longcat-2.0":{input:.3,cachedInput:.006,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25"}}},nvidia:{models:{"nvidia/nemotron-3-ultra-550b-a55b":{unpriced:!0,billingMode:"flat",notes:"Official catalog does not publish token price."}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat"},"mistral-medium-3.5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat"},"mistral-small-4.0":{input:.15,cachedInput:.015,output:.6,billingMode:"flat"}}},"opencode-go":{models:{"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25"},"glm-5.3":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01"},"glm-5.3-flash":{input:.15,cachedInput:.03,output:.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01"},"glm-5.2":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"glm-5.1":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"gpt-5.6-luna":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.7-code":{input:.95,cachedInput:.19,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.6":{input:.95,cachedInput:.16,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"mimo-v2.6-flash":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-28"},"mimo-v2.6-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-28"},"mimo-v2.5":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"mimo-v2.5-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"minimax-m3":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"minimax-m2.7":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.8-max":{input:2,cachedInput:.25,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.7-max":{input:2.5,cachedInput:.5,output:7.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.7-plus":{input:.4,cachedInput:.04,output:1.6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.6-plus":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},hy3:{input:.14,cachedInput:.035,output:.58,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"longcat-2.0":{input:.3,cachedInput:.006,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25"},"muse-spark-1.2-contributor":{input:.1,cachedInput:.002,output:.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25",notes:"\u4F4E\u4EF7\u6362\u53D6\u63D0\u793A\u8BCD/\u8865\u5168\u7528\u4E8E\u8BAD\u7EC3 Meta \u6A21\u578B;\u9650\u5730\u533A"}}},openrouter:{models:{"meta/muse-spark-1.3-contributor":{input:.1,cachedInput:.002,output:.2,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"google/gemini-3.8-flash":{input:.75,cachedInput:.075,cacheWrite:.041667,output:3.75,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"qwen/qwen3.8-flash":{input:.15,cachedInput:.016,cacheWrite:.2,output:.47,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"z-ai/glm-5.3-flash":{input:.09,cachedInput:.018,output:.3,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"}}}},xn=Object.freeze(Object.keys(ue["opencode-go"].models)),Z={...ue};Z.opendesign={models:Mn};for(let[e,t]of Object.entries(dt)){let o=ue[e]?.models??{};Z[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function Pe(e,t=ue){if(!e||typeof e!="object"||(e.prices??={},typeof e.prices!="object"||Array.isArray(e.prices))||(e.prices.providers??={},typeof e.prices.providers!="object"||Array.isArray(e.prices.providers)))return;let o=e.prices.providers;for(let[n,i]of Object.entries(Z)){if(["__proto__","constructor","prototype"].includes(n))continue;let r=t[n]?.models??{},a=Object.hasOwn(o,n)?o[n]?.models:null;if(!a||typeof a!="object"||Array.isArray(a)){Object.hasOwn(o,n)||(o[n]=structuredClone(i));continue}for(let[s,c]of Object.entries(i.models)){if(!Object.hasOwn(a,s)){Object.hasOwn(r,s)||(a[s]=structuredClone(c));continue}let u=new Set(["input","cacheMiss","cachedInput","cacheHit","cacheRead","cacheWrite","output","reasoning","cny","longContext","legacy","billingMode","sourceUrl","checkedAt","notes","offPeak","peak","legacyBase","rateHistory","unpriced"]);if(a[s]&&Object.keys(a[s]).some(m=>!u.has(m)))continue;let d=T(r[s]),l=T(a[s]);d&&l&&JSON.stringify(d)===JSON.stringify(l)&&(a[s]=structuredClone(c))}}}function On(e){let t=Object.fromEntries(Object.keys(Z).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ue[o]?.models,...xe[o]?.models}}]));Pe(e,t)}function Cn(e){Pe(e,Object.fromEntries(Object.entries(Z).filter(([t])=>t!=="stepfun")))}var fi={models:{"deepseek-v4-flash":{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32},legacyBase:{cacheHit:.0028,cacheMiss:.14,output:.28}},"deepseek-v4-pro":{cacheHit:.022,cacheMiss:.66,output:1.98,offPeak:{cacheHit:.022,cacheMiss:.66,output:1.98},peak:{cacheHit:.044,cacheMiss:1.32,output:3.96},legacyBase:{cacheHit:.003625,cacheMiss:.435,output:.87}},"deepseek-v4-flash-vision-exp":{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32}}},default:{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32},legacyBase:{cacheHit:.0028,cacheMiss:.14,output:.28}}},hi={models:{"deepseek-v4-flash":{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9},legacyBase:{cacheHit:.02,cacheMiss:1,output:2}},"deepseek-v4-pro":{cacheHit:.15,cacheMiss:4.5,output:13.5,offPeak:{cacheHit:.15,cacheMiss:4.5,output:13.5},peak:{cacheHit:.3,cacheMiss:9,output:27},legacyBase:{cacheHit:.025,cacheMiss:3,output:6}},"deepseek-v4-flash-vision-exp":{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9}}},default:{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9},legacyBase:{cacheHit:.02,cacheMiss:1,output:2}}};function ft(e,t,o){let n=t==="CNY"?{cacheHit:.02,cacheMiss:1,output:4}:{cacheHit:.003,cacheMiss:.15,output:.6},i=Object.fromEntries(Object.entries(n).map(([r,a])=>[r,a*2]));return{...structuredClone(e),...n,offPeak:n,peak:i,rateHistory:[{before:o,cacheHit:e.cacheHit,cacheMiss:e.cacheMiss,output:e.output,offPeak:{...e.offPeak},peak:{...e.peak}}]}}function _n(e){let t=e==="CNY"?hi:fi,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):ft(i,e,pt)]));return o["deepseek-v4.1-flash"]=ft(t.models["deepseek-v4-flash-vision-exp"],e,pt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:ft(t.default,e,pt)}}var bt=_n("USD"),vn=_n("CNY");function Pn(e,t=Date.now()){if(!e||!Number.isFinite(t)||!Array.isArray(e.rateHistory))return e;let o=null,n=1/0;for(let a of e.rateHistory){let s=Date.parse(a.before);t<s&&s<n&&(o=a,n=s)}if(!o)return e;let{before:i,...r}=o;return{...e,...r}}function F(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=s=>{let c=e[s];return typeof c=="number"&&Number.isFinite(c)&&c>=0?c:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),a=t("cacheWrite");return{cacheHit:n,cacheMiss:o,output:i,...r===void 0?{}:{reasoning:r},...a===void 0?{}:{cacheWrite:a}}}function T(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e.unpriced===!0){let a={unpriced:!0};for(let s of["billingMode","sourceUrl","checkedAt","notes"])typeof e[s]=="string"&&(a[s]=e[s]);return a}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e))return null;let t=F(e),o=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0;if(e.cacheWrite!==void 0&&!o(e.cacheWrite))return null;if(e.longContext!==void 0){let a=e.longContext;if(!a||typeof a!="object"||Array.isArray(a)||!o(a.aboveInputTokens)||a.aboveInputTokens===0||!["cacheMiss","cacheHit","output"].every(s=>o(a[s]))||a.cacheWrite!==void 0&&!o(a.cacheWrite))return null;t.longContext={aboveInputTokens:a.aboveInputTokens,...F(a)}}e.legacy===!0&&(t.legacy=!0),(e.billingMode==="flat"||e.billingMode==="deepseek-peak"||e.billingMode==="utc-peak"||e.billingMode==="batch")&&(t.billingMode=e.billingMode);for(let a of["sourceUrl","checkedAt","notes"])typeof e[a]=="string"&&(t[a]=e[a]);if(e.cny!==void 0){if(!e.cny||typeof e.cny!="object"||Array.isArray(e.cny)||!["cacheHit","cacheMiss","output"].every(a=>o(e.cny[a])))return null;t.cny=F(e.cny)}let n=F(e.offPeak);n!==void 0&&(t.offPeak=n);let i=F(e.peak);i!==void 0&&(t.peak=i);let r=F(e.legacyBase);if(r!==void 0&&(t.legacyBase=r),e.rateHistory!==void 0){if(!Array.isArray(e.rateHistory)||e.rateHistory.length>16)return null;let a=new Set;t.rateHistory=[];for(let s of e.rateHistory){if(!s||typeof s.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(s.before)||!Number.isFinite(Date.parse(s.before))||a.has(Date.parse(s.before))||!["cacheHit","cacheMiss","output"].every(u=>typeof s[u]=="number"&&Number.isFinite(s[u])&&s[u]>=0))return null;a.add(Date.parse(s.before));let c={before:s.before,...F(s)};for(let u of["offPeak","peak"])if(s[u]!==void 0){if(!s[u]||!["cacheHit","cacheMiss","output"].every(d=>typeof s[u][d]=="number"&&Number.isFinite(s[u][d])&&s[u][d]>=0))return null;c[u]=F(s[u])}t.rateHistory.push(c)}t.rateHistory.sort((s,c)=>Date.parse(s.before)-Date.parse(c.before))}return Object.assign(t,Ee(e)),lt(t)?t:null}function mi(e,t){let o=t?.models??{};if(typeof e=="string"&&e.length>0){let n=Object.hasOwn(o,e)?o[e]:void 0;if(n!==void 0)return n}return t?.default??{cacheHit:0,cacheMiss:0,output:0}}function yt(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function P(e){return yt(e).replace(/[^\p{L}\p{N}]+/gu,"")}function gi(e,t=!0,o=!0){let n=yt(e);return t&&/[-_./:@](?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(n)?n.slice(0,-5):t&&o&&/[-_./:@]\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(n)?n.slice(0,-7):n.replace(/[-_./:@](?:\d{4}-?\d{2}-?\d{2}|v\d+(?:\.\d+)*|\d+k|latest)$/,"")}function _e(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(c=>typeof c=="string"&&c.length>0):[],a=r.find(c=>c===o);if(a!==void 0)return a;let s=e.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(s))return null;for(;;){let c=P(s);if(c.length===0)return null;let u=r.filter(l=>P(l)===c);if(u.length>0)return u.length===1?u[0]:null;let d=gi(s,n,i);if(d===s.toLowerCase())return null;s=d}}var ht=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...tt]),Ce={openai:/^(?:gpt|o\d|codex)/i,anthropic:/^claude/i,google:/^gemini/i,stepfun:/^step-/i,deepseek:/^deepseek/i,moonshot:/^kimi/i,"z-ai":/^glm/i,xai:/^grok/i,alibaba:/^qwen/i,minimax:/^minimax/i,tencent:/^(?:hunyuan|hy\d)/i,xiaomi:/^mimo/i,upstage:/^solar/i,nvidia:/^nemotron/i,mistral:/^mistral/i,meta:/^(?:muse|llama)/i,meituan:/^longcat/i};function mt(e){return["deepseek-peak","utc-peak"].includes(e?.billingMode)?e.billingMode:"flat"}function ne(e,t,o,n,i){if(typeof e!="string")return null;if(Object.hasOwn(t,e))return e;if(n!=="auto")return null;let r=e.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),a=r.search(/[/:]/);if(a>0){let s=r.slice(0,a).trim().toLowerCase(),c=r.slice(a+1).trim();if(Object.hasOwn(Ce,s)&&(s===o||(o==="opencode-zen"||o==="opencode-go")&&(Ce[s].test(c)||_e(c,Object.keys(s==="deepseek"?i?.models??{}:i?.providers?.[s]?.models??{}),c,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=c;else if(Object.hasOwn(Ce,s))return null}return _e(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function bi(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},a=t,s=e,c=(e===""?"deepseek":e)+":"+t,u=r[c];if(u==="__custom__"){let f=Ne(o?.custom?.[c]);return{entry:f,billingMode:"flat",priced:f!==null,currency:f?.currency??"USD"}}if(u==="__local__")return{entry:null,billingMode:"flat",priced:!1};if(typeof u=="string"&&u.length>0){let f=u.indexOf(":");if(f>0&&u.slice(f+1).length>0?(s=u.slice(0,f).trim().toLowerCase(),a=u.slice(f+1)):a=u,s==="deepseek"&&a==="__default__"){let b=o?.default??{cacheHit:0,cacheMiss:0,output:0},k=T(b);return k===null?{entry:null,billingMode:"flat",priced:!1}:{entry:k,billingMode:"deepseek-peak",priced:k.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(s)){let f=ne(a,o?.providers?.[s]?.models??{},"opencode-go",i,o);f===null?s="opencode-go":a=f}if(tt.includes(s)&&s!=="opendesign"&&ne(a,o?.providers?.[s]?.models??{},s,i,o)===null&&(s="opendesign"),Nn(s,a))return{entry:null,billingMode:"flat",priced:!1};if(s==="openrouter"){let f=o?.providers?.openrouter?.models??{},b=Object.hasOwn(f,a)?T(f[a]):null;return{entry:b,billingMode:"flat",priced:b!==null&&b.unpriced!==!0}}if(s===""||s==="deepseek"||s.includes("deepseek")){let f=o?.models??{},b=ne(a,f,"deepseek",i,o);if(b!=null){let M=f[b],E=T(M);return E===null||E.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:E,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let M=null,E=-1,w=!1,I="flat";for(let[C,R]of Object.entries(o?.providers??{})){if(ht.has(C))continue;let Y=R?.models??{},G=ne(a,Y,C,i,o);if(G===null)continue;let te=T(Y[G]);if(te===null)continue;let D=+(G===a||P(G)===P(a));D>E?(M=te,E=D,w=!1,I=mt(Y[G])):D===E&&(w=!0)}if(w)return{entry:null,billingMode:"flat",priced:!1};if(M!==null)return{entry:M,billingMode:I,priced:M.unpriced!==!0}}let k=mi(a,o),g=T(k);return g===null?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:"deepseek-peak",priced:g.unpriced!==!0}}let l=o?.providers?.[s]?.models??{},m=ne(a,l,s,i,o);if(m===null&&ht.has(s))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&Object.hasOwn(Ce,s))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&i==="auto"){let f=null,b=-1,k=!1,g="flat";for(let[M,E]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(M===s||ht.has(M))continue;let w=E?.models??{},I=ne(a,w,M,i,o);if(I===null)continue;let C=T(w[I]);if(C===null)continue;let R=+(I===a||P(I)===P(a));R>b?(f=C,b=R,k=!1,g=M==="deepseek"?"deepseek-peak":mt(w[I])):R===b&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(f!==null)return{entry:f,billingMode:g,priced:f.unpriced!==!0}}if(m===null)return{entry:null,billingMode:"flat",priced:!1};let A=T(l[m]);return A===null||A.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:A,billingMode:mt(l[m]),priced:!0}}function yi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?_e(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],a=T(r);return a===null||a.unpriced===!0?null:{entry:a,billingMode:"deepseek-peak",priced:!0}}var Ai=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),ki=["lmstudio:","lmstudio/","ollama:","ollama/","jan:","jan/","gpt4all:","gpt4all/","koboldcpp:","koboldcpp/","llamacpp:","llamacpp/","llama-cpp:","llama-cpp/","localai:","localai/","vllm:","vllm/","sglang:","sglang/","tabbyapi:","tabbyapi/","lmdeploy:","oobabooga/","text-generation-webui/","llama-server:","gguf:","local:"];function Nn(e,t){if(typeof e=="string"&&Ai.has(e))return!0;let o=typeof t=="string"?yt(t):"";return ki.some(n=>o.startsWith(n))}function Rn(e,t,o,n){let i=typeof e=="string"?e.trim().toLowerCase():"",r=i.startsWith("llm-")?i.slice(4):i;if(["our-free-model","our-free-model-region"].includes(r)&&n?.overrides?.[r+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let a=wi(r,t,o,n);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"?{...a,entry:{...a.entry,peakSchedule:"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?In.has(typeof t=="string"?t.trim().toLowerCase():""):_e(t,[...In])!==null)?{...a,entry:{...a.entry,peakSchedule:"ollama"}}:a}function wi(e,t,o,n){let i=bi(e,t,o,n);if(i.currency)return i;if(i.priced||e===""||e==="deepseek"||e.includes("deepseek"))return Oe(i,o);let a=(n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{})[e+":"+t];if(typeof a!="string"||a.length===0||a==="__local__"||a.includes(":"))return Oe(i,o);let s=n?.mode==="exact"?"exact":"auto";return Oe(yi(a,o,s)??i,o)}function Oe(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:kn(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(o=>typeof e[o]=="number"&&Number.isFinite(e[o])&&e[o]>=0)||["cacheWrite","reasoning"].some(o=>e[o]!==void 0&&(typeof e[o]!="number"||!Number.isFinite(e[o])||e[o]<0)))return null;let t={...F(e),...Ee(e),currency:e.currency,billingMode:"flat"};return lt(t)?t:null}function Mi(e,t,o,n=ve){if(!Array.isArray(o)||o.length===0||di(e,n)!==null||Number.isFinite(t)&&e<t)return!1;let i=new Date(e).getUTCHours();return o.some(r=>{let a=Number(r?.start),s=Number(r?.end);return!Number.isFinite(a)||!Number.isFinite(s)?!1:a<s?i>=a&&i<s:i>=a||i<s})}function Ii(e,t,o){let n=Pn(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(s,c="base")=>ct(s,n,c),r=n.peakSchedule==="ollama";if(r||n.billingMode==="utc-peak"){if(o?.enabled!==!0||!Number.isFinite(t)||r&&t<Date.parse(ci))return i(n);let s=new Date(t),c=s.getUTCDay(),u=s.getUTCHours(),d=c>0&&c<6&&(r?u>=12&&u<18:u>=1&&u<4||u>=6&&u<10);return i((d?n.peak:n.offPeak)??n,(d?n.peak:n.offPeak)?d?"peak":"offPeak":"base")}if(Number.isFinite(t)&&t<Date.parse(pi)){let s=n.legacyBase;return s===void 0?i(n):i(s,"legacyBase")}if(o?.enabled!==!0)return i(n);let a=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(Mi(t,a,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let s=n.peak;return s===void 0?i(n):i(s,"peak")}if(a!==void 0&&t>=a){let s=n.offPeak;return s===void 0?i(n):i(s,"offPeak")}return i(n)}function Tn(e,t,o,n){let i=Ii(t,o,n),r=Math.max(0,Number(e?.input)||0),a=Math.max(0,Number(e?.output)||0),s=Math.max(0,Number(e?.cacheRead)||0),c=Math.max(0,Number(e?.cacheWrite)||0),u=Math.max(0,Number(e?.reasoning)||0);i.longContext&&r+s+c>i.longContext.aboveInputTokens&&(i=i.longContext);let d=typeof i.reasoning=="number"?i.reasoning:0,l=(r*i.cacheMiss+a*i.output+s*i.cacheHit+c*(i.cacheWrite??i.cacheHit)+u*d)/1e6;return Number.isFinite(l)&&l>0?l:0}function Un(e,t,o){let n=Math.max(0,Number(e)||0);if(t!=="CNY")return n;let i=Number(o);return n/(Number.isFinite(i)&&i>0?i:1)}var Si={opendesign:"opendesign|open[._-]?design",codex:"codex|chatgpt","baidu-coding":"baidu|qianfan|\u767E\u5EA6|\u5343\u5E06","tencent-coding":"tencent|tokenhub|\u817E\u8BAF",anthropic:"anthropic|claude",zai:"z[._-]?ai|zhipu|glm|\u667A\u8C31",minimax:"minimax|\u6D77\u87BA",kimi:"kimi|moonshot|moonshotai|\u6708\u4E4B\u6697\u9762",openrouter:"openrouter",siliconflow:"siliconflow|\u7845\u57FA",commandcode:"commandcode",clinepass:"cline[._-]?pass|clinepass",scnet:"scnet|sugon|\u8D85\u7B97",volcengine:"volcengine|volcano|volc|ark|\u706B\u5C71|\u65B9\u821F",qwen:"qwen|qianwen|\u5343\u95EE|\u901A\u4E49",mimo:"mimo|xiaomi|\u5C0F\u7C73",factory:"factory|droid",go:"opencode(?:[-_\\s]?go)?|zen|go"},Ei=Object.entries(Si).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function Dn(e,t){for(let o of[e,t]){let n=String(o??"").normalize("NFKC").replace(/([a-zA-Z0-9\u3400-\u9fff])(?=(?:Coding|Token|Agent|Plan|Subscription))/g,"$1-").replace(/([a-z0-9])((?:coding|token|agent)?plan|subscription)$/i,"$1-$2").toLowerCase();if(!/(?:^|[^a-z0-9])(?:(?:coding|token|agent)[-_\s]*)?plan(?:$|[^a-z0-9])|(?:^|[^a-z0-9])subscription(?:$|[^a-z0-9])|套餐|订阅/.test(n))continue;let i=Ei.filter(([,r])=>r.test(n));if(i.length){if(i.length!==1)return null;let r=i[0][0];if(r==="volcengine"&&/agent[-_\s]*plan|智能体.*套餐/.test(n))return"volcengine-agent";if(r==="tencent-coding"){let a=/token[-_\s]*plan|令牌.*套餐/.test(n),s=/coding[-_\s]*plan|编程.*套餐/.test(n);return a===s?null:a?"tencent-token":r}return r}}return null}var J=[...ce,"go","codex","volcengine-agent","tencent-coding","tencent-token","baidu-coding","antigravity","stepfun"],xi={opendesign:["opendesign","open-design","open-design-api","amr-link.open-design.ai"],go:["go","zen","opencode","opencode-go","opencode-go-plus","dsh-opencode-go"],codex:["codex","openai-codex","dsh-openai-codex","codex-chatgpt"],anthropic:["anthropic","claude-subscription"],zai:["zai","glm-coding-plan"],minimax:["minimax","minimax-code"],kimi:["kimi","kimi-code"],commandcode:["commandcode","command-code"],clinepass:["clinepass","cline-pass"],workbuddy:["workbuddy","workbuddy-subscription","workbuddy-ai","workbuddy-global"],antigravity:["antigravity"],stepfun:["stepfun","step-code"],"volcengine-agent":["volcengine-agent","ark-agent-plan","volcengine-agent-plan"],"tencent-coding":["tencent-coding","tencent-coding-plan","tokenhub-coding-plan"],"tencent-token":["tencent-token","tencent-token-plan","tokenhub-token-plan"],"baidu-coding":["baidu-coding-plan","qianfan-coding-plan"],qwen:bn,scnet:gn,mimo:hn,factory:["factory","droid","factory-a","factory-g","factory-o"]},At={opendesign:"plan",anthropic:"auto",zai:"auto",minimax:"auto",kimi:"auto",openrouter:"api",siliconflow:"api",commandcode:"auto",clinepass:"auto",scnet:"auto",volcengine:"auto",qwen:"auto",mimo:"auto",factory:"auto",go:"auto",codex:"auto",workbuddy:"auto",antigravity:"auto",stepfun:"auto","volcengine-agent":"plan","tencent-coding":"plan","tencent-token":"plan","baidu-coding":"plan"},Hn=400,Ln=2160*36e5,ya=168*36e5;var Oi=840*36e5;function kt(e,t,o){let n=String(e??"").trim().toLowerCase();n.startsWith("llm-")&&(n=n.slice(4));let i=t?.modelPlans?.[`${e}:${o}`]??t?.modelPlans?.[`${n}:${o}`];if(J.includes(i))return i;if(n.length===0)return null;for(let[r,a]of Object.entries(xi))if(a.includes(n))return r;return J.includes(n)?n:Dn(e,o)}var jn=new WeakMap;function Ci(e){let t=jn.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(P)),n=new Set,i=new Set(xn.map(P));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(P(r))&&n.add(P(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},jn.set(e,t)}return t}function wt(e,t,o){if(o===null||typeof o!="object")return!1;let n=String(e??"").trim().toLowerCase();if(n.length>0&&n!=="deepseek"&&!n.includes("deepseek"))return!1;let i=P(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:a}=Ci(o);return!r.has(i)&&a.has(i)}function Bn(e,t,o,n,i){if(nn(e,t))return"api";let r=kt(e,o,t);r===null&&wt(e,t,i)&&(r="go");let a=o?.models;if(a!==null&&typeof a=="object"){let c=a[`${e}:${t}`];if(c==="plan"||c==="api")return c;if(r!==null){let u=a[`${r}:${t}`];if(u==="plan"||u==="api")return u}}let s=o?.providers;for(let c of[e,r]){if(c==null)continue;let u=s?.[c];if(u==="plan"||u==="api")return u}return r===null?"api":n instanceof Set&&n.has(r)?"plan":"api"}function Re(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>J.includes(n)));let t=new Set,o=e?.codingPlans;if(o!==null&&typeof o=="object")for(let n of ce)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function Fn(e){return JSON.stringify([e?.planBilling,[...Re(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function Mt(e,t,o,n,i){let r=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},a=r[t]!==null&&typeof r[t]=="object"&&!Array.isArray(r[t])?r[t]:{},s=Number(o);if(!Number.isFinite(s)||s<=0)return r;let c=Math.floor(s/36e5)*36e5,u=a[c]!==null&&typeof a[c]=="object"?a[c]:{tokens:0,cost:0};return u.tokens+=Math.max(0,Number(n)||0),u.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...a,[c]:u}}}function Wn(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Oi,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},a=!1;for(let[s,c]of Object.entries(i)){if(c===null||typeof c!="object"||Array.isArray(c)){a=!0;continue}let u={};for(let[d,l]of Object.entries(c)){let m=Number(d);if(!Number.isFinite(m)||m<n||m>o+36e5){a=!0;continue}u[m]={tokens:Math.max(0,Number(l?.tokens)||0),cost:Math.max(0,Number(l?.cost)||0)}}Object.keys(u).length>0&&(r[s]=u)}return a||Object.keys(r).length!==Object.keys(i).length?r:i}function It(e){let t={};for(let o of Array.isArray(e)?e:[]){if(o===null||typeof o!="object")continue;let n=String(o.provider??"");n.length!==0&&(t=Mt(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as Ue,readlinkSync as _i,statSync as vi}from"node:fs";import{execFileSync as zn}from"node:child_process";import{hostname as Pi}from"node:os";import{join as Ni}from"node:path";import{performance as Ri}from"node:perf_hooks";var $n=Pi(),De=process.platform==="win32"?Ri.timeOrigin:Date.now()-process.uptime()*1e3,Kn={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},St,Et,Te;function xt(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=Ue(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=Ue("/proc/sys/kernel/random/boot_id","utf8").trim(),a=_i(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!a)return null;let s=e===process.pid?De:null;if(t&&e!==process.pid){Te??=Number(zn("getconf",["CLK_TCK"],Kn).trim());let c=Ue("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(Te)&&Te>0&&c&&(s=(Number(c)+Number(i)/Te)*1e3)}return{platform:"linux",boot:r,namespace:a,start:i,startedAtMs:s}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(De)),unit:"ms",startedAtMs:De};let n=Ni(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=zn(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],Kn).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function Ot(){return St===void 0&&(St=xt(process.pid)),St}function qn(){let e=Ot();return JSON.stringify({version:e?.unit==="ms"?2:1,host:$n,identity:e})}function Yn(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=Ue(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==$n)return!1;let s=Ot();if(i?.identity?.platform==="linux"&&s?.platform==="linux"&&i.identity.boot===s.boot&&i.identity.namespace!==s.namespace)return!1}try{process.kill(t,0)}catch(s){return s.code==="ESRCH"}let r=(i?.version===1||i?.version===2)&&i.identity;if(n!==""&&(!r||typeof r.start!="string"||!/^\d+$/.test(r.start))||process.platform==="win32"&&n!==""&&!(i.version===1&&r.platform==="win32"&&r.unit===void 0||i.version===2&&r.platform==="win32"&&r.unit==="ms")||process.platform==="linux"&&n!==""&&i.version!==1)return!1;t!==process.pid&&!o.has(t)&&o.set(t,xt(t,n===""));let a=t===process.pid?Ot():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(Et===void 0&&(Et=xt(t,!1,!0)),a=Et),n===""){let s=t===process.pid?a?.startedAtMs??De:a?.startedAtMs;return Number.isFinite(s)&&vi(e).mtimeMs<s-2e3}if(!r||!a||r.platform!==a.platform||typeof r.start!="string"||!/^\d+$/.test(r.start))return!1;if(a.platform==="linux")return typeof r.boot!="string"||typeof r.namespace!="string"?!1:r.boot!==a.boot||r.start!==a.start;if(r.unit==="ms"||a.unit==="ms"){let s=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),c=s(r),u=s(a);return!Number.isSafeInteger(c)||c<=0||!Number.isSafeInteger(u)||u<=0?!1:c<u-2e3}return r.start!==a.start}import{createHash as Ui,randomUUID as vt}from"node:crypto";import{createHash as Ti}from"node:crypto";var U=new WeakMap,Gn=/^[a-f\d]{64}$/,de=e=>e&&typeof e=="object"&&!Array.isArray(e),Qn=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),Ct=e=>Ti("sha256").update(JSON.stringify(e)).digest("hex"),Vn=24;function He(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))He(t);return Object.freeze(e)}function Zn(e,t,o=[],n=[]){if(e===t)return n;if(de(e)&&de(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))Qn(i)&&(!Object.hasOwn(t,i)||t[i]===void 0?Object.hasOwn(e,i)&&e[i]!==void 0&&n.push([[...o,i]]):Object.hasOwn(e,i)?Zn(e[i],t[i],[...o,i],n):n.push([[...o,i],t[i]]));else JSON.stringify(e)!==JSON.stringify(t)&&n.push([o,t]);return n}function Jn(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=Jn(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function je(e,t,o,n){let i=o.get(n);if(i&&i.depth<Vn){let r={base:n,patch:Zn(t[n],e)};if(JSON.stringify(r).length<JSON.stringify(e).length)return{record:He(r),depth:i.depth+1,signature:Ct(r),baseValue:t[n]}}return{record:e,depth:0,signature:Ct(e)}}function Le(e,t,o,n){let i=U.get(e)??new Map;U.set(e,i),Object.hasOwn(e,t)||(e[t]=He(o)),i.has(t)||i.set(t,je(e[t],e,i,n))}function Xn(e={}){let t={...e};return U.set(t,new Map(U.get(e)??[])),t}function eo(e,t){let o={...t,...e};return U.set(o,new Map([...U.get(t)??[],...U.get(e)??[]])),o}function to(e){let t=U.get(e)??new Map;U.set(e,t);let o;for(let[n,i]of Object.entries(e)){let r=t.get(n);(!r||r.record.base&&r.baseValue!==e[r.record.base])&&t.set(n,je(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function no(e,t,o){let n={},i=new Map,r=U.get(o),a=new Set,s=c=>{if(i.has(c))return!0;if(!Gn.test(c)||a.has(c)||a.size>Vn||!de(e[c]))return!1;a.add(c);let u=e[c],d;if(!de(u.prices)){if(!Gn.test(u.base)||!Array.isArray(u.patch)||u.patch.length>1e5||u.patch.some(f=>!Array.isArray(f)||![1,2].includes(f.length)||!Array.isArray(f[0])||f[0].length>16||!f[0].every(Qn))||!s(u.base))return a.delete(c),!1;d=i.get(u.base)}let l=Ct(u),m=d?n[u.base]:void 0,A=r?.get(c);if(A&&o[c]&&(A.sourceSignature===l&&A.sourceBase===m||A.signature===l&&A.baseValue===m))n[c]=o[c],i.set(c,A);else{let f=d?n[u.base]:u;if(d)for(let k of u.patch)f=Jn(f,k[0],k);if(!de(f?.prices))return a.delete(c),!1;n[c]=He(t(f));let b=je(n[c],n,i,d?u.base:void 0);i.set(c,{...b,sourceSignature:l,sourceBase:m})}return a.delete(c),!0};for(let c of Object.keys(e))s(c);if(U.set(n,i),![...i.values()].some(c=>c.depth>0)){let c;for(let u of Object.keys(n)){let{sourceSignature:d,sourceBase:l}=i.get(u);i.set(u,{...je(n[u],n,i,c),sourceSignature:d,sourceBase:l}),c=u}}return n}var ro=new WeakMap,Fe=new WeakMap,pe=new WeakSet,Di=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],Nt=e=>Ui("sha256").update(JSON.stringify(e)).digest("hex"),oe=e=>!["__proto__","constructor","prototype"].includes(e),Be=e=>e&&typeof e=="object"&&!Array.isArray(e),ji=new Set(["cacheHit","cacheMiss","cacheWrite","input","cachedInput","output","reasoning","billingMode","unpriced","legacy","currency","aboveInputTokens","before","offPeak","peak","longContext","legacyBase","rateHistory","cny","multiplier","separateMultipliers","multipliers"]),fe=e=>Array.isArray(e)?e.map(fe):Be(e)?Object.fromEntries(Object.entries(e).filter(([t])=>ji.has(t)||at.test(t)).map(([t,o])=>[t,fe(o)])):e,_t=e=>Object.fromEntries(Object.entries(e??{}).filter(([t])=>oe(t)).map(([t,o])=>[t,fe(o)])),oo=["at","before","after","days","sessions","skipped"],Pt=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function so(e){let t=Fe.get(e);if(t)return t;let o=new Map;for(let n of Object.values(e.revisions)){let i=JSON.stringify([n.sessionId,n.date,n.model??""]),r=o.get(i);(!r||Pt(n,r)>=0)&&o.set(i,n)}return t={changes:Object.values(e.changes).sort(Pt),revisions:o,fingerprint:Nt([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((n,i)=>n.at-i.at||(n.sequence??0)-(i.sequence??0))},Fe.set(e,t),t}function Rt(e,t=!1){let o=structuredClone(Object.fromEntries(Di.filter(i=>i!=="prices"&&e?.[i]!==void 0).map(i=>[i,e[i]]))),n=e?.prices??{};return o.prices={...n.currency?{currency:n.currency}:{},ollamaPeak:!t||n.ollamaPeak===!0,ollamaTaggedPeak:!t||n.ollamaTaggedPeak===!0,snapshotTags:!t||n.snapshotTags===!0,shortSnapshotTags:!t||n.shortSnapshotTags===!0,volcenginePeak:!t||n.volcenginePeak===!0,default:fe(n.default),models:_t(n.models),...n.custom?{custom:_t(n.custom)}:{},providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([i])=>oe(i)).map(([i,r])=>[i,{...r.currency?{currency:r.currency}:{},...r.default?{default:fe(r.default)}:{},models:_t(r.models)}]))},o}function io(e,t=!1){let o=Rt(e,t),n=Nt(o),i={};Le(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:_(e)}}};return pe.add(r),r}function he(e,t,o,n=!1){if(pe.has(e))return e;if(!Be(e?.versions)||!Be(e?.changes))return io(t,n);let i=no(e.versions,d=>Rt(d,!0),o?.versions),r=Object.fromEntries(Object.entries(e.changes).filter(([d,l])=>oe(d)&&Number.isFinite(l?.at)&&l.at>=0&&i[l.version]));if(!Object.values(r).some(d=>d.at===0)){let d=Object.values(i),l={...t?.prices};for(let A of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])d.length&&(l[A]=d.every(f=>f.prices?.[A]===!0));let m=io({...t,prices:l},n);for(let[A,f]of Object.entries(m.versions))Le(i,A,f);r[vt()]=m.changes.initial}let a=Object.fromEntries(Object.entries(e.revisions??{}).filter(([d,l])=>oe(d)&&typeof l?.sessionId=="string"&&(l.model===void 0||typeof l.model=="string"&&l.model.includes(":")&&l.model.length<=2048)&&/^\d{4}-\d{2}-\d{2}$/.test(l.date)&&Number.isFinite(l.at)&&i[l.version])),s=Object.fromEntries(Object.entries(Be(e.runs)?e.runs:{}).filter(([d,l])=>oe(d)&&oo.every(m=>Number.isFinite(l?.[m])&&l[m]>=0)).map(([d,l])=>[d,{...Object.fromEntries([...oo,...["beforeCny","afterCny","beforeEur","afterEur"].filter(m=>Number.isFinite(l[m])&&l[m]>=0)].map(m=>[m,l[m]])),...typeof l.model=="string"?{model:l.model}:{}}])),c=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([d,l])=>oe(d)&&Number.isFinite(l?.at)&&l.at>=0&&["CNY","EUR"].every(m=>Number.isFinite(l.rates?.[m])&&l.rates[m]>0)));if(!Object.keys(c).length)for(let[d,l]of Object.entries(r))c[d]={at:l.at,sequence:l.sequence??0,rates:_({...i[l.version],currency:t.currency})};let u={versions:i,changes:r,revisions:a,runs:s,fxChanges:c};return pe.add(u),u}function We(e,t,o=Date.now()){let n=Rt(t),i=Nt(n),r=so(e),a=r.changes.at(-1),s=_(t),c=r.fx.at(-1),u=JSON.stringify(c?.rates)!==JSON.stringify(s);u&&(e.fxChanges??={},e.fxChanges[vt()]={at:Math.max(o,c?.at??0),sequence:(c?.sequence??0)+1,rates:s},Fe.delete(e));let d=l=>{let{exchangeRate:m,...A}=l??{};return A};return a?.version===i||JSON.stringify(d(e.versions[a?.version]))===JSON.stringify(d(n))?u:(Le(e.versions,i,n,a?.version),e.changes[vt()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,version:i},Fe.delete(e),!0)}function ao(e,t){return e&&t&&ro.set(e,t),e}function Tt(e,t,o="",n=""){if(e?._repriceFxConfig){let I=Tt(e._repriceFxConfig,t,o,n),C=_(I);return{...e,fxRates:C,exchangeRate:C[e.currency]??e.exchangeRate}}let i=ro.get(e);if(!i||!Number.isFinite(t))return e;let r=so(i),a=new Date(t),s=Number.isFinite(t)?`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`:"",c=0,u=r.changes.length;for(;c<u;){let I=c+u>>>1;r.changes[I].at<=t?c=I+1:u=I}let d=r.changes[c-1],l=I=>I&&t<=I.at?I:null,m=l(r.revisions.get(JSON.stringify([o,s,""]))),A=n?l(r.revisions.get(JSON.stringify([o,s,n]))):null,f=m&&A?Pt(m,A)>0?m:A:m??A,b=(f??d)?.version,k=b&&i.versions[b]?{...e,...i.versions[b]}:e,g=0,M=r.fx.length;for(;g<M;){let I=g+M>>>1;r.fx[I].at<=t?g=I+1:M=I}let E=r.fx[g-1]?.rates,w=f?.preserveFx?m?.fxRates??E??_(i.versions[d?.version]??e):f?f.fxRates??_(k):E??_(k);return{...k,fxRates:w,exchangeRate:w[k.currency]??k.exchangeRate}}function co(e,t){if(!e)return t;if(!t)return e;let o={...t.revisions};for(let[i,r]of Object.entries(e.revisions??{}))(!o[i]||r.at>=o[i].at)&&(o[i]=r);let n={versions:eo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return pe.add(n),n}function lo(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Xn(t)};return pe.add(n),n}function uo(e){return e&&{...e,format:2,versions:to(e.versions)}}var $=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...v],q=e=>!["__proto__","constructor","prototype"].includes(e),O=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ie=e=>e===void 0?void 0:structuredClone(e);function jt(e,t){if(O(e)){if(!O(t)){for(let o of v)delete e[o];return}for(let o of v)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))jt(n,t.byProviderModel?.[o]);if(Array.isArray(e.sessions)){let o=new Map((Array.isArray(t.sessions)?t.sessions:[]).filter(n=>O(n)&&typeof n.id=="string").map(n=>[n.id,n]));for(let n of e.sessions)O(n)&&o.has(n.id)&&jt(n,o.get(n.id))}}}function $i(e,t){if(!O(e)||!O(t))return e;for(let[o,n]of Object.entries(e))O(n)&&jt(n,t[o]);return e}function Ht(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,i)=>Ht(n,t[i]));if(!O(e)||!O(t))return!1;let o=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of o)if(!v.includes(n)&&!Ht(e[n],t[n]))return!1;return!0}function Lt(e,t,o){if(!O(e))return e;for(let n of v){let i=j(t?.[n],o?.[n],e[n],!0);i===void 0?delete e[n]:e[n]=i}for(let[n,i]of Object.entries(e.byProviderModel??{}))Lt(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=a=>new Map((Array.isArray(a)?a:[]).filter(s=>O(s)&&typeof s.id=="string").map(s=>[s.id,s])),i=n(t?.sessions),r=n(o?.sessions);for(let a of e.sessions)O(a)&&typeof a.id=="string"&&Lt(a,i.get(a.id),r.get(a.id))}return e}function ge(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:lo(t)}:{}}}var qi=new Int32Array(new SharedArrayBuffer(4)),go=e=>typeof e=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}:[a-f\d]{64}$/i.test(e),X=e=>Object.fromEntries(Object.entries(O(e)?e:{}).filter(([t,o])=>go(t)&&Number.isSafeInteger(o)&&o>=0)),H=e=>[...new Set((Array.isArray(e)?e:[]).filter(t=>typeof t=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i.test(t)))].slice(-128);function be(e,t,o=5e3,n=mo()){po(Ki(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,a=qn(),s=new Map,c=Date.now()+o;for(;;)try{po(i);try{ho(me(i,r),a,{flag:"wx"})}catch(u){try{Ke(me(i,r))}catch{}throw ze(i),u}break}catch(u){if(!["EEXIST","EPERM"].includes(u.code))throw u;try{let d=Hi(i),l=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(l){if(Yn(me(i,d[0]),Number(l[1]),s)){Ke(me(i,d[0])),ze(i);continue}}else if(d.length===0&&Date.now()-Fi(i).mtimeMs>3e4){ze(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=c)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait(qi,0,0,10)}try{return t()}finally{Ke(me(i,r)),ze(i)}}function bo(e){let t;try{t=Li(e,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!O(o)||o.version!==1)throw new Error("Unsupported ledger format");return o}function $e(e,t,o=!1){let n=`${e}.${process.pid}-${mo()}.tmp`;try{if(o)try{Wi(e,`${e}.pricing-history-v1.bak`,zi.COPYFILE_EXCL)}catch(i){if(!["EEXIST","ENOENT"].includes(i.code))throw i}ho(n,JSON.stringify({...t,pricingHistory:uo(t.pricingHistory)}),{encoding:"utf8",flag:"wx"}),Bi(n,e)}finally{try{Ke(n)}catch(i){if(i.code!=="ENOENT")throw i}}}var Ut=()=>Object.fromEntries($.map(e=>[e,0]));function fo(e,t){for(let o of $)e[o]=(Number(e[o])||0)+(t[o]??0)}function re(e,t){if(t.meter){let{source:d,seq:l}=t.meter;if(!go(d)||!Number.isSafeInteger(l)||l<1)throw Error("Invalid metered call identity");if((e.usageCursors?.[d]??0)>=l)return!1;if(e.usageCursors??={},e.usageCursors[d]=l,t.skip)return!0}let{date:o,sessionId:n,atMs:i,providerKey:r,values:a,planId:s}=t;O(e.days[o])||(e.days[o]={date:o,...Ut(),byProviderModel:{},sessions:[]});let c=e.days[o];Array.isArray(c.sessions)||(c.sessions=[]);let u=[c];if(typeof n=="string"&&n.length>0){let d=c.sessions.find(l=>l.id===n);d||(d={id:n,at:i,...Ut(),byProviderModel:{}},c.sessions.push(d)),u.push(d)}for(let d of u){fo(d,a),d.byProviderModel??={};let l=d.byProviderModel[r]??=Ut();fo(l,a)}return s!==null&&(e.planHourBuckets=Mt(e.planHourBuckets,s,i,Xe(a),a.cost)),!0}function j(e,t,o,n=!1){if(N(t,e))return ie(o);if(N(o,e)||N(t,o))return ie(t);if(O(t)&&O(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!q(r))continue;let a=j(e?.[r],t[r],o[r],n&&(O(t[r])||$.includes(r)||r==="tokens"));a!==void 0&&(i[r]=a)}return i}return n&&typeof t=="number"&&typeof o=="number"?Math.max(0,o+t-(Number(e)||0)):ie(t)}var Dt=e=>Object.fromEntries((e?.sessions??[]).filter(t=>q(t.id)).map(t=>[t.id,t]));function Yi(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!q(i))continue;let r=e[i],a=t[i],s=o[i];if(Ht(r,a)){s!==void 0&&(n[i]=Lt(ie(s),r,a));continue}if(!a||!s){a&&(n[i]=ie(a));continue}if(N(a,s)){n[i]=ie(s);continue}let c=j(r,a,s,!0),u=Dt(r),d=Dt(a),l=Dt(s),m=j(u,d,l,!0),A=(f,b,k)=>Object.fromEntries($.map(g=>[g,(k?.[g]??0)+(b?.[g]??0)-(f?.[g]??0)]));Object.assign(c,A(r,a,s)),c.byProviderModel={};for(let f of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(a.byProviderModel??{}),...Object.keys(s.byProviderModel??{})]))q(f)&&(c.byProviderModel[f]=A(r?.byProviderModel?.[f],a.byProviderModel?.[f],s.byProviderModel?.[f]));for(let f of Object.keys(d))if(!(!l[f]||N(u[f],d[f])||N(u[f],l[f]))){for(let b of $)c[b]-=(d[f][b]??0)-(u[f]?.[b]??0)-((m[f]?.[b]??0)-(l[f][b]??0));for(let[b,k]of Object.entries(d[f].byProviderModel??{}))if(!(!q(b)||!c.byProviderModel[b]))for(let g of $)c.byProviderModel[b][g]-=(k[g]??0)-(u[f]?.byProviderModel?.[b]?.[g]??0)-((m[f]?.byProviderModel?.[b]?.[g]??0)-(l[f].byProviderModel?.[b]?.[g]??0))}for(let f of[c,...Object.values(c.byProviderModel)])for(let b of $)f[b]=Math.max(0,f[b]);c.sessions=Object.values(m).sort((f,b)=>(f.at??0)-(b.at??0)),n[i]=c}return n}function Gi(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(q(r)){i[r]={};for(let a of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!q(a))continue;let s=u=>Object.fromEntries((Array.isArray(u)?u:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),c=j(s(e[r]?.[a]),s(t[r]?.[a]),s(o[r]?.[a]));i[r][a]=Object.values(c).filter(u=>u.t>=n-Ln).sort((u,d)=>u.t-d.t).slice(-Hn)}}return i}function se(e,t,o,n,i=Date.now(),r=[],a={}){let s=a.ownLocal===!0,c=o!==void 0&&o===e,u=ge(e),d=c?u:ge(o??e),l=s?t:ge(t);$i(u.days,d.days);let m=!N(l.historyReset,u.historyReset),A=!N(d.historyReset,u.historyReset),f=m?l.historyReset:d.historyReset;if(m||A)for(let w of[u,...m?[d]:[l]])w.days={},w.planSamples={},w.planHourBuckets={},w.balanceRef=null;for(let w of n)A&&!m&&w.recordedAt<=(f?.at??0)||(re(u,w),d!==u&&re(d,w),A&&!m&&re(l,w));let b={version:1,writeReceipts:H([...d.writeReceipts??[],...l.writeReceipts??[]]),config:j(u.config,l.config,d.config),days:Yi(u.days,l.days,d.days),balanceRef:N(u.balanceRef,l.balanceRef)?d.balanceRef:N(u.balanceRef,d.balanceRef)?l.balanceRef:l.balanceRef==null||d.balanceRef==null?null:(d.balanceRef?.at??0)>(l.balanceRef?.at??0)?d.balanceRef:l.balanceRef,migrations:[...new Set([...d.migrations??[],...l.migrations??[]])],planSamples:Gi(u.planSamples,l.planSamples,d.planSamples,i),planHourBuckets:Wn(j(u.planHourBuckets,l.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:j(u.openrouterPriceHashes,l.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:co(l.pricingHistory,d.pricingHistory),historyReset:f??null},k=X(l.usageCursors);for(let[w,I]of Object.entries(X(d.usageCursors)))k[w]=Math.max(k[w]??0,I);Object.keys(k).length&&(b.usageCursors=k);let g=j(u.providerPriceHashes,l.providerPriceHashes,d.providerPriceHashes);g&&Object.keys(g).length&&(b.providerPriceHashes=g);let M=Object.keys(b.days).sort(),E=Math.max(7,Math.min(3650,Number(b.config.historyDays)||180));for(;M.length>E;)delete b.days[M.shift()];return Q(b.days).includes(b.balanceRef?.date)&&(b.balanceRef=null),Qi(b,r),b}function Qi(e,t){let o=(n,i)=>$.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(Fn(e.config)!==n.fingerprint||!N(e.historyReset??null,n.historyReset))continue;let i=e.days?.[n.date],r=n.expected;if(!(!i||!o(i,r)||[...new Set([...Object.keys(i.byProviderModel??{}),...Object.keys(r.byProviderModel??{})])].some(s=>!o(i.byProviderModel?.[s],r.byProviderModel?.[s]))))for(let s of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!q(s))continue;let c=e.planHourBuckets?.[s]??{},u=Object.fromEntries(Object.entries(c).filter(([l])=>+l>=n.start&&+l<n.end)),d=n.buckets[s]??{};N(u,d)||(e.planHourBuckets[s]={...Object.fromEntries(Object.entries(c).filter(([l])=>+l<n.start||+l>=n.end)),...d},e.planSamples&&delete e.planSamples[s])}}}function yo(e,t,o){return j(e,t,o)}import{join as wo}from"node:path";var Mo=1,Oo=180;function ye(e){try{let t=Zi(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Bt=["antigravity","claude","codex","kimi","xai","workbuddy"],Ji=["sidebar","settings","both","off"],Xi=/^[a-z0-9][a-z0-9_-]{0,47}$/;function er(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function Io(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function tr(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(t.length===0||t!==e.trim()||/[\s/?#@\\]/.test(t))return!1;if(t.startsWith("[")){let r=t.indexOf("]");if(r<0)return!1;let a=t.slice(1,r),s=t.slice(r+1);return!a.includes(":")||!/^[0-9a-f:.]+$/.test(a)?!1:s===""||s.startsWith(":")&&Io(s.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!Io(o[2]))return!1;let n=o[1],i=n.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);return i!==null?i.slice(1).every(r=>Number(r)>=0&&Number(r)<=255):/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$/.test(n)}function nr(e,t={}){let o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},n=typeof o.id=="string"?o.id.trim():typeof t.id=="string"?t.id:"",i=Array.isArray(o.includeProviders)?[...new Set(o.includeProviders.filter(s=>typeof s=="string").map(s=>er(s)).filter(s=>Bt.includes(s)))]:Bt.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(s=>tr(s)).map(s=>s.trim().toLowerCase()))].slice(0,16):[],a=Number(o.refreshMinutes);return{id:n,type:typeof o.type=="string"?o.type:"cliproxyapi",label:typeof o.label=="string"?o.label.slice(0,80):typeof t.label=="string"?t.label:n,baseURL:typeof o.baseURL=="string"?o.baseURL.trim().replace(/\/+$/,""):"",enabled:o.enabled!==!1,display:Ji.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(a)?Math.min(1440,Math.max(1,a)):15,includeProviders:i.length>0?i:Bt.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function or(e){try{let t=new URL(e);return["http:","https:"].includes(t.protocol)&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"}catch{return!1}}function Kt(){return{locale:"auto",position:"dock",sidebar:!0,currency:"CNY",symbol:"\xA5",decimals:4,exchangeRateAuto:!0,fxRates:{USD:1,CNY:7.2,EUR:.92},exchangeRateCheckedAt:0,exchangeRateDate:"",exchangeRate:7.2,pricingCurrency:"USD",peakEnabled:!0,peakEffectiveAt:Sn,peakWindows:En.map(e=>({...e})),peakHolidays:[...ve],peakNotice:!0,peakAlertEnabled:!0,peakAlertAhead:2,peakAlertTarget:"both",peakAlertPosition:"corner",peakAlertWebNotify:!1,showSessionId:!1,sessionListCosts:!1,sessionListCostPeriod:"total",hideOfficialBalance:!1,hideBudget:!1,hideTodayCost:!1,modelStatistics:{},hideSessionCostHeader:!1,hideSessionCostDock:!1,hideTurnCost:!1,sessionCostCompact:!1,followSkinTransparency:!1,contextCostsEnabled:!1,contextCostsPromptSeen:!1,statisticsBasis:"auto",sidebarTodayMetric:"cost",sidebarTodayBalanceInline:!1,sidebarOrder:[],showTotalWithPlan:!1,includeSubagentCost:!1,codexQuotaEnabled:!1,codexQuotaSidebar:!0,codexQuotaStrip:!0,codexQuotaSource:"auto",codexCompatPromptDismissed:!1,codexCompatHistoryAppliedAt:0,sidebarSimple:!1,sidebarSimplePromptSeen:!1,sidebarModels:{enabled:!1,period:"today",topN:5,summary:"total",position:"last",defaultOpen:!1,remember:!0,tokens:!1,shares:!0,refreshSeconds:60,dock:!1},sidebarSummaryPromptSeen:!1,billionContextNoticeEnabled:!0,billionContextNoticesSeen:[],billingStorageRetentionDays:7,sidebarStyle:"standard",legacyAutoImportedAt:0,peakStyle:"compact",peakTimeDisplay:"both",peakProgressPromptSeen:!1,priceMatch:"auto",priceMatchDismissed:[],priceOverrides:{},priceTableDisplay:{},prices:{models:Object.fromEntries(Object.entries(bt.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(bt.default),providers:Object.fromEntries(Object.entries(Z).map(([e,t])=>[e,{models:Object.fromEntries(Object.entries(t.models).map(([o,n])=>[o,structuredClone(n)]))}]))},budget:{enabled:!1,amount:100,period:"month",customStart:null,customEnd:null,detail:!0},codingPlans:{opendesign:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",workspaceId:""},factory:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",orgId:"",factoryPool:"standard"},anthropic:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},zai:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},minimax:{enabled:!1,display:"both",refreshMinutes:15,apiKey:"",baseUrl:""},kimi:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},openrouter:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},siliconflow:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},commandcode:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},clinepass:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},scnet:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",planCredits:24e4,planStart:""},qwen:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",quotaSource:"local",planCredits:5e5,planStart:"",rates:{}},volcengine:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",accessKeyId:"",secretAccessKey:""}},balance:{display:"both",refreshMinutes:5,showProgressBar:!1,showSource:!1,budgetCap:null,reconcile:!0,clickHintSeen:!1},goQuota:{enabled:!0,display:"both",refreshMinutes:15,apiKey:"",main:"rolling",detail:!0},customBalance:{enabled:!1,label:"",labelEn:"",display:"both",unit:"USD",convertToDisplayCurrency:!1,refreshMinutes:15,request:{url:"",method:"GET",headers:{}},extract:{remaining:{op:"subtract",paths:["info.max_budget","info.spend"]},maxBudget:"info.max_budget",spend:"info.spend",unit:"USD"}},customBalances:[],gatewayQuotas:{sources:[]},corner:{enabled:!1,goRolling:!0,goWeekly:!0,goMonthly:!0,budget:!0},quotaStrip:{enabled:!1,budget:!0,go:!0,plans:!0,promptSeen:!1},barDirections:{balance:"remaining",budget:"used",go:"used",plan:"used"},usage:{position:"cost"},planBilling:{providers:{...At},models:{},modelPlans:{}},historyDays:Oo,fetchedAt:null,priceSource:"bundled"}}var fc=Object.keys(Kt());function Ft(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Wt(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function ir(e){if(e==null||typeof e!="object")return 0;let t=e.byProviderModel;if(t===null||typeof t!="object"||Object.keys(t).length===0)return Number(e.cost)||0;let o=0;for(let[n,i]of Object.entries(t)){let r=n.indexOf(":"),a=r>=0?n.slice(0,r):n;a.startsWith("llm-")&&(a=a.slice(4)),/^deepseek(?:-official|-account)?$/.test(a)&&(o+=Number(i?.cost)||0)}return o}function rr(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function qe(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=rr(e[o]);let t=Number(e.apiCost);return e.apiCost=Number.isFinite(t)&&t>=0?Math.min(t,Number(e.cost)||0):Number(e.cost)||0,e}function So(e){for(let t of Object.values(e))if(qe(t)!==null){t.byProviderModel=t.byProviderModel!==null&&typeof t.byProviderModel=="object"&&!Array.isArray(t.byProviderModel)?t.byProviderModel:{};for(let[o,n]of Object.entries(t.byProviderModel))qe(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>qe(o)!==null);for(let o of t.sessions){o.id=typeof o.id=="string"?o.id:"",(typeof o.title!="string"||o.title.length===0)&&delete o.title,(!Number.isFinite(Number(o.at))||Number(o.at)<=0)&&delete o.at,o.byProviderModel=o.byProviderModel!==null&&typeof o.byProviderModel=="object"&&!Array.isArray(o.byProviderModel)?o.byProviderModel:{};for(let[n,i]of Object.entries(o.byProviderModel))qe(i)===null&&delete o.byProviderModel[n]}}return e}function ke(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return t===void 0?e:t;let o={...e};for(let[n,i]of Object.entries(t)){if(n==="__proto__"||n==="constructor"||n==="prototype")continue;let r=o[n];o[n]=r!==null&&typeof r=="object"&&!Array.isArray(r)&&i!==null&&typeof i=="object"&&!Array.isArray(i)?ke(r,i):i}return o}function Ae(e){let t=Kt(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(vn),currency:"CNY"});let n=ke(t,o);o.prices?.custom!==void 0&&(n.prices.custom=Object.fromEntries(Object.entries(o.prices.custom&&typeof o.prices.custom=="object"&&!Array.isArray(o.prices.custom)?o.prices.custom:{}).filter(([p,h])=>p.includes(":")&&p.length<=512&&Ne(h)!==null).map(([p,h])=>[p,Ne(h)])));for(let[p,h]of Object.entries(o.prices?.providers??{}))!h?.models||typeof h.models!="object"||Array.isArray(h.models)||Object.hasOwn(n.prices?.providers??{},p)&&(n.prices.providers[p].models=ke({},h.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=ke({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:p,cacheMiss:h,output:y}=t.prices.default;n.prices.default=ke({cacheHit:p,cacheMiss:h,output:y},r)}let a=p=>typeof p=="number"&&Number.isFinite(p),s=(p,h,y)=>typeof p=="string"&&h.includes(p)?p:y;for(let[p,h]of Object.entries(t)){let y=n[p],x=typeof h;x==="boolean"&&typeof y!="boolean"||x==="number"&&!a(y)||x==="string"&&typeof y!="string"?n[p]=h:x==="object"&&h!==null&&y!==null&&typeof y=="object"&&p==="gatewayQuotas"&&Array.isArray(y)||x==="object"&&h!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(h))&&(n[p]=h)}n.locale=s(n.locale,["auto","zh","en"],"auto"),n.position=s(n.position,["dock","header","off"],"dock"),n.peakStyle=s(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=s(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=s(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=s(n.pricingCurrency,["USD","CNY"],"USD"),n.prices!==null&&typeof n.prices=="object"&&(delete n.prices.ollamaPeak,delete n.prices.ollamaTaggedPeak,delete n.prices.snapshotTags,delete n.prices.shortSnapshotTags,delete n.prices.volcenginePeak),n.prices!==null&&typeof n.prices=="object"&&!Array.isArray(n.prices)&&n.prices.currency!==void 0&&(n.prices.currency=s(n.prices.currency,["USD","CNY"],"USD")),n.decimals=Math.max(0,Math.min(10,Math.floor(Number(n.decimals)||0))),n.historyDays=Math.max(7,Math.min(3650,Math.floor(Number(n.historyDays)||180))),n.showSessionId=n.showSessionId===!0,n.sessionListCosts=n.sessionListCosts===!0,n.sessionListCostPeriod=s(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=en(n.modelStatistics);for(let p of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline"])n[p]=n[p]===!0;n.sessionCostCompact=n.sessionCostCompact===!0,n.contextCostsEnabled=n.contextCostsEnabled===!0,n.contextCostsPromptSeen=n.contextCostsPromptSeen===!0,n.sidebarTodayMetric=s(n.sidebarTodayMetric,["cost","tokens","both"],"cost"),n.sidebarOrder=Array.isArray(n.sidebarOrder)?[...new Set(n.sidebarOrder.filter(p=>typeof p=="string"&&/^(balance|customBalance|today|peak|models|go|budget|codex|(plan|gateway):[A-Za-z0-9_-]{1,100})$/.test(p)))].slice(0,64):[],n.statisticsBasis=["api","plan","total"].includes(n.statisticsBasis)?n.statisticsBasis:"auto",n.showTotalWithPlan=n.showTotalWithPlan===!0,n.includeSubagentCost=n.includeSubagentCost===!0,n.codexQuotaEnabled=n.codexQuotaEnabled===!0,n.codexQuotaSidebar=n.codexQuotaSidebar!==!1,n.codexQuotaStrip=n.codexQuotaStrip!==!1,n.codexQuotaSource=s(n.codexQuotaSource,["auto","connect","subscription","chatgpt","pi-ai","chatgpt-sub"],"auto"),n.codexCompatPromptDismissed=n.codexCompatPromptDismissed===!0,n.codexCompatHistoryAppliedAt=Number.isFinite(n.codexCompatHistoryAppliedAt)&&n.codexCompatHistoryAppliedAt>0?n.codexCompatHistoryAppliedAt:0,n.sidebarSimple=n.sidebarSimple===!0,n.sidebarSimplePromptSeen=n.sidebarSimplePromptSeen===!0,n.sidebarSummaryPromptSeen=n.sidebarSummaryPromptSeen===!0,n.billionContextNoticeEnabled=n.billionContextNoticeEnabled!==!1,n.billingStorageRetentionDays=[0,7,30].includes(n.billingStorageRetentionDays)?n.billingStorageRetentionDays:7,n.billionContextNoticesSeen=[...new Set((Array.isArray(n.billionContextNoticesSeen)?n.billionContextNoticesSeen:[]).filter(p=>typeof p=="string"&&p.length<=160))].slice(-32),n.sidebarModels=Object.fromEntries(Object.entries(t.sidebarModels).map(([p,h])=>{let y=n.sidebarModels?.[p],x={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[p];return[p,x?x.includes(y)?y:h:typeof h=="boolean"?typeof y=="boolean"?y:h:typeof y=="number"&&Number.isFinite(y)?Math.min(p==="topN"?10:60,Math.max(p==="topN"?1:10,Math.floor(y))):h]})),n.sidebarStyle=s(n.sidebarStyle,["standard","compact","summary"],"standard"),n.priceMatchDismissed=Array.isArray(n.priceMatchDismissed)?[...new Set(n.priceMatchDismissed.filter(p=>typeof p=="string"&&p.length>0&&p.length<=512))].slice(0,1e3):[],delete n.hideAmounts,n.peakAlertEnabled=n.peakAlertEnabled!==!1;let c=Number(n.peakAlertAhead);n.peakAlertAhead=Number.isInteger(c)&&c>=1&&c<=30?c:2,n.peakAlertTarget=s(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=s(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=a(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=_(n),n.exchangeRateCheckedAt=Number.isFinite(n.exchangeRateCheckedAt)&&n.exchangeRateCheckedAt>0?n.exchangeRateCheckedAt:0,n.exchangeRateDate=/^\d{4}-\d{2}-\d{2}$/.test(n.exchangeRateDate??"")?n.exchangeRateDate:"",(!a(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(p=>p!==null&&typeof p=="object"&&a(Number(p.start))&&a(Number(p.end))):n.peakWindows=t.peakWindows,Array.isArray(n.peakHolidays)?n.peakHolidays=[...new Set(n.peakHolidays.filter(p=>typeof p=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(p)&&!Number.isNaN(Date.parse(p+"T00:00:00Z"))&&new Date(p+"T00:00:00Z").toISOString().slice(0,10)===p))].slice(0,366).sort():n.peakHolidays=t.peakHolidays,Number.isNaN(Date.parse(n.peakEffectiveAt))&&(n.peakEffectiveAt=t.peakEffectiveAt);let u={};if(n.priceOverrides!==null&&typeof n.priceOverrides=="object")for(let[p,h]of Object.entries(n.priceOverrides))typeof p=="string"&&typeof h=="string"&&(u[p]=h);n.priceOverrides=u;let d={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[p,h]of Object.entries(n.priceTableDisplay))typeof p=="string"&&(d[p]=typeof h=="boolean"?h:t.priceTableDisplay[p]===!0);n.priceTableDisplay={...t.priceTableDisplay,...d};let l=n.budget;l.enabled=l.enabled===!0,l.amount=a(l.amount)&&l.amount>=0?l.amount:100,l.period=s(l.period,["day","month","all","custom"],"month"),l.customStart=typeof l.customStart=="string"?l.customStart:null,l.customEnd=typeof l.customEnd=="string"?l.customEnd:null,l.detail=l.detail!==!1;let m=n.balance;m.display=s(m.display,["sidebar","settings","both","off"],"both"),m.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(m.refreshMinutes)||5))),m.showProgressBar===void 0&&(m.showProgressBar=n.customBalance?.showProgressBar!==void 0?n.customBalance.showProgressBar===!0:t.balance.showProgressBar===!0),m.showProgressBar=m.showProgressBar===!0,m.showSource=m.showSource===!0,m.clickHintSeen=m.clickHintSeen===!0,m.reconcile=m.reconcile!==!1;let A=Number(m.budgetCap);m.budgetCap=Number.isFinite(A)&&A>0?A:null;let f=n.goQuota;f.enabled=f.enabled===!0,typeof f.showInComposer!="boolean"&&delete f.showInComposer,f.display=s(f.display,["sidebar","settings","both","off"],"both"),f.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(f.refreshMinutes)||15))),f.apiKey=typeof f.apiKey=="string"?f.apiKey:"",f.main=s(f.main,["rolling","weekly","monthly"],"rolling"),f.detail=f.detail!==!1;let b=n.customBalance??t.customBalance,k=(p,h)=>{let y=p??{},x={...["aliyun","tokenrhythm"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:s(y.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),label:typeof y.label=="string"?y.label:h.label,labelEn:typeof y.labelEn=="string"?y.labelEn:h.labelEn,unit:y.adapter==="tokenrhythm"?"CNY":s(y.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))x.request={...h.request};else{let W={};for(let[L,z]of Object.entries(y.request.headers??{}))typeof L=="string"&&typeof z=="string"&&(W[L]=z);x.request={...h.request,...y.request,url:typeof y.request.url=="string"?y.request.url:"",method:typeof y.request.method=="string"?y.request.method:"GET",headers:{...h.request?.headers??{},...W}}}if(y.extract===null||typeof y.extract!="object"||Array.isArray(y.extract)?x.extract={...h.extract}:x.extract={...h.extract,...y.extract},Array.isArray(y.allowedHosts)){let W=y.allowedHosts.filter(L=>typeof L=="string"&&L.length>0);W.length>0&&(x.allowedHosts=W)}return x},g=k(b,t.customBalance);n.customBalance=g;let M=n.gatewayQuotas,E=Array.isArray(M)?M:M!==null&&typeof M=="object"&&Array.isArray(M.sources)?M.sources:[],w=[],I=new Set;for(let p of E.slice(0,4)){let h=nr(p);!Xi.test(h.id)||I.has(h.id)||h.type!=="cliproxyapi"||!or(h.baseURL)||(I.add(h.id),w.push(h))}n.gatewayQuotas={sources:w};let C=n.customBalances;Array.isArray(C)||(C=[]);let R=t.customBalances?.[0]??t.customBalance,Y=C.slice(0,8).map(p=>k(p,R)),G=g.enabled===!0||typeof g.request?.url=="string"&&g.request.url.length>0;Y.length===0&&G&&Y.push(g),n.customBalances=Y;let te=n.corner;for(let p of["enabled","goRolling","goWeekly","goMonthly","budget"])te[p]=te[p]===!0||te[p]!==!1&&p!=="enabled";let D=n.quotaStrip;D.enabled=D.enabled===!0,D.promptSeen=D.promptSeen===!0;for(let p of["budget","go","plans"])D[p]=D[p]!==!1;let Me=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:Me.balance==="used"?"used":"remaining",budget:Me.budget==="remaining"?"remaining":"used",go:Me.go==="remaining"?"remaining":"used",plan:Me.plan==="remaining"?"remaining":"used"};let S={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[p,h]of Object.entries(n.codingPlans))if(!(!ce.includes(p)||h===null||typeof h!="object"||Array.isArray(h))){if(S[p]={enabled:h.enabled===!0,...typeof h.showInComposer=="boolean"?{showInComposer:h.showInComposer}:{},display:s(h.display,["sidebar","settings","both","off"],"settings"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(h.refreshMinutes)||15))),apiKey:typeof h.apiKey=="string"?h.apiKey:""},p==="minimax"){let y=yn(h.baseUrl);S[p].baseUrl=y??"",y===null&&(S[p].enabled=!1)}if(p==="workbuddy"&&(S[p].accountScope=s(h.accountScope,["current","all","selected"],"current"),S[p].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(it))].slice(0,400):[]),p==="opendesign"){let y=dn(h.workspaceId);S[p].workspaceId=y??"",y===null&&(S[p].enabled=!1)}if(p==="factory"){let y=un(h.orgId);S[p].orgId=y??"",y===null&&(S[p].enabled=!1),S[p].factoryPool=s(h.factoryPool,["standard","core","both"],"standard")}if(p==="scnet"){let y=Number(h.planCredits);S[p].planCredits=Number.isFinite(y)&&y>0?y:24e4,S[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:""}if(p==="qwen"){S[p].quotaSource=h.quotaSource==="cli"||h.quotaSource==="bailian"?h.quotaSource:"local";let y=Number(h.planCredits);S[p].planCredits=Number.isFinite(y)&&y>0?y:5e5,S[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:"";let x=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},W={};for(let[L,z]of Object.entries(x)){if(typeof L!="string"||L.length===0||z===null||typeof z!="object")continue;let Qe=To=>{let Ve=Number(To);return Number.isFinite(Ve)&&Ve>0?Ve:null},Yt=Qe(z.input),Gt=Qe(z.cachedInput),Qt=Qe(z.output);Yt===null||Gt===null||Qt===null||(W[L]={input:Yt,cachedInput:Gt,output:Qt})}S[p].rates=W}if(p==="volcengine"){let y=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",x=typeof h.apiKey=="string"?h.apiKey.trim():"";S[p].accessKeyId=y.length>0?y:x,S[p].secretAccessKey=typeof h.secretAccessKey=="string"?h.secretAccessKey:"",S[p].accessKeyId.length>0&&S[p].apiKey!==S[p].accessKeyId&&(S[p].apiKey=S[p].accessKeyId)}}}n.codingPlans=S;let Ge={};for(let p of J){let h=n.planBilling?.providers?.[p];Ge[p]=["auto","plan","api"].includes(h)?h:At[p]??"auto"}if(n.planBilling?.providers&&typeof n.planBilling.providers=="object"&&!Array.isArray(n.planBilling.providers))for(let[p,h]of Object.entries(n.planBilling.providers))p.trim()&&!["__proto__","constructor","prototype"].includes(p)&&["auto","plan","api"].includes(h)&&(Ge[p]=h);let qt={};if(n.planBilling?.models!==null&&typeof n.planBilling?.models=="object"&&!Array.isArray(n.planBilling?.models))for(let[p,h]of Object.entries(n.planBilling.models))typeof p=="string"&&p.length>0&&(h==="plan"||h==="api")&&(qt[p]=h);let No=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([p,h])=>p.includes(":")&&J.includes(h))),Ro=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(p=>J.includes(p)):[...Re(n)])];return n.planBilling={providers:Ge,models:qt,modelPlans:No,autoProviders:Ro},n}var sr={balance:"DEEPSEEK_BALANCE_API_KEY",goQuota:"OPENCODE_GO_API_KEY","codingPlans.opendesign":"OPENDESIGN_CONTROL_KEY","codingPlans.anthropic":"ANTHROPIC_OAUTH_TOKEN","codingPlans.zai":"ZAI_API_KEY","codingPlans.minimax":"MINIMAX_API_KEY","codingPlans.kimi":"KIMI_CODING_API_KEY","codingPlans.openrouter":"OPENROUTER_API_KEY","codingPlans.siliconflow":"SILICONFLOW_API_KEY","codingPlans.commandcode":"COMMANDCODE_API_KEY","codingPlans.clinepass":"CLINE_PASS_API_KEY","codingPlans.volcengine.ak":"VOLC_ACCESSKEY","codingPlans.volcengine.sk":"VOLC_SECRETKEY","codingPlans.mimo":"MIMO_COOKIE","codingPlans.factory":"FACTORY_API_KEY"},hc=Object.keys(sr);function Eo(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;let t=e.request;if(t===null||typeof t!="object"||Array.isArray(t))return e;let o=t.headers;if(o===null||typeof o!="object"||Array.isArray(o))return e;let n=!1,i={};for(let[r,a]of Object.entries(o))et(r,a)?(i[r]="",n=!0):i[r]=a;return n?{...e,request:{...t,headers:i}}:e}function xo(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;let t={...e};if(t.goQuota!==null&&typeof t.goQuota=="object"&&!Array.isArray(t.goQuota)){let o={...t.goQuota};"apiKey"in o&&(o.apiKey=""),t.goQuota=o}if(t.codingPlans!==null&&typeof t.codingPlans=="object"&&!Array.isArray(t.codingPlans)){let o={};for(let[n,i]of Object.entries(t.codingPlans)){if(i===null||typeof i!="object"||Array.isArray(i)){o[n]=i;continue}let r={...i};"apiKey"in r&&(r.apiKey=""),"accessKeyId"in r&&(r.accessKeyId=""),"secretAccessKey"in r&&(r.secretAccessKey=""),o[n]=r}t.codingPlans=o}if(t.customBalance!==null&&typeof t.customBalance=="object"&&!Array.isArray(t.customBalance)&&(t.customBalance=Eo(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(Eo)),Array.isArray(t.gatewayQuotas))t.gatewayQuotas=t.gatewayQuotas.map(o=>{if(o===null||typeof o!="object"||Array.isArray(o))return o;let n={...o};for(let i of["managementKey","apiKey","key","token"])delete n[i];return n});else if(t.gatewayQuotas!==null&&typeof t.gatewayQuotas=="object"){let o={...t.gatewayQuotas};Array.isArray(o.sources)&&(o.sources=o.sources.map(n=>{if(n===null||typeof n!="object"||Array.isArray(n))return n;let i={...n};for(let r of["managementKey","apiKey","key","token"])delete i[r];return i})),t.gatewayQuotas=o}return t}var zt=[{id:"provider-catalog-2026-10-03",apply:Pe},{id:"provider-catalog-2026-10-15",apply:On},{id:"stepfun-catalog-2026-10-16",apply:Cn},{id:"v1.5.26-coding-plan-sidebar-display",apply(e){let t=e?.codingPlans?.minimax;t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.enabled===!0&&(t.display="both")}}],Ye=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=he(r.pricingHistory,t),this.config=t,Zt(o,t),this.days=o,this.path=n,this.writeTimer=null,this.closed=!1,this.pendingWrite=!1,this.backgroundWrite=null,this.backgroundWriteDisabled=!1,this.writeGeneration=0,this.startWrite=r.backgroundWriter??an,this.writeReceipts=H(r.writeReceipts),this.diskRevision=null,this.balanceRef=r.balanceRef??null,this.historyReset=r.historyReset??null,this.usageCursors=X(r.usageCursors),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.migrations=Array.isArray(i)?i.filter(a=>typeof a=="string"):[],this.secretMigration={ran:!1,pending:[]},this.planSamples=r.planSamples??{},this.planHourBuckets=r.planHourBuckets??{},this.openrouterPriceHashes=Object.fromEntries(Object.entries(r.openrouterPriceHashes??{}).filter(([a,s])=>!["__proto__","constructor","prototype"].includes(a)&&typeof s=="string"&&/^[a-f0-9]{64}$/.test(s))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([a,s])=>a.startsWith("opendesign:")&&typeof s=="string"&&/^[a-f0-9]{64}$/.test(s))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&We(this.pricingHistory,t),this._config=ao(t,this.pricingHistory)}static open(){let t=wo(ot(),"storages","cost-meter"),o=wo(t,"ledger.json");return be(o,()=>e.load(o))}static load(t){let o=Kt(),n={},i=null,r=[...zt.map(g=>g.id),"quota-token-window-v2"],a={},s={},c={},u={},d=null,l={},m=[],A,f=!1;try{let g=JSON.parse(Vi(t,"utf8"));if(g===null||typeof g!="object"||Array.isArray(g))throw new Error("Unsupported ledger format");if(g!==null&&typeof g=="object")if(g.version!==Mo){try{Ao(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(g.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=g.historyReset??null,l=X(g.usageCursors),m=H(g.writeReceipts);let M=typeof g.config=="object"&&g.config!==null?g.config:{};A=he(g.pricingHistory,Ae(M),void 0,!0),f=!!g.pricingHistory&&g.pricingHistory.format!==2,r=Array.isArray(g.migrations)?g.migrations.filter(I=>typeof I=="string"):[];let E=new Set(r);for(let I of zt)E.has(I.id)||(I.apply(M),r.push(I.id));o=Ae(M),g.openrouterPriceHashes&&typeof g.openrouterPriceHashes=="object"&&!Array.isArray(g.openrouterPriceHashes)&&(c=g.openrouterPriceHashes),g.providerPriceHashes&&typeof g.providerPriceHashes=="object"&&!Array.isArray(g.providerPriceHashes)&&(u=g.providerPriceHashes),g.days!==null&&typeof g.days=="object"&&!Array.isArray(g.days)&&(n=So(g.days));let w=g.balanceRef;w!==null&&typeof w=="object"&&typeof w.date=="string"&&Number.isFinite(w.total)&&Number.isFinite(w.granted)&&Number.isFinite(w.topped)&&(i={date:w.date,total:w.total,granted:w.granted,topped:w.topped,currency:typeof w.currency=="string"?w.currency:void 0,at:Number(w.at)||0,ledgerCost:Number.isFinite(w.ledgerCost)&&w.ledgerCost>=0?w.ledgerCost:void 0}),g.planSamples!==null&&typeof g.planSamples=="object"&&!Array.isArray(g.planSamples)&&(a=g.planSamples),g.planHourBuckets!==null&&typeof g.planHourBuckets=="object"&&!Array.isArray(g.planHourBuckets)?s=g.planHourBuckets:Array.isArray(g.planRecentCalls)&&(s=It(g.planRecentCalls))}}catch(g){if(g?.code!=="ENOENT"){try{Ao(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(g?.message??g)}`)}}let b=new e(o,n,t,r,{planSamples:a,planHourBuckets:s,openrouterPriceHashes:c,providerPriceHashes:u,balanceRef:i,historyReset:d,usageCursors:l,writeReceipts:m,pricingHistory:A});b.legacyPricingHistory=f,b.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),b.quotaStatsNeedRepair&&(b.planSamples={}),f&&b.scheduleWrite();let k=Q(b.days);return k.length&&(k.includes(b.balanceRef?.date)&&(b.balanceRef=null),b.scheduleWrite()),b}account(t,o,n,i,r,a,s){if(this.closed)return;if(s!==void 0&&(!rn(s,i)||r!=="deepseek-official"||!on(o,s)))throw new Error("Invalid official web request fee");let c=Tt(this.config,i,n,`${r||"deepseek"}:${o}`),u=Rn(r,o,c.prices,{mode:c.priceMatch==="exact"?"exact":"auto",overrides:c.priceOverrides}),d=u.entry??{cacheHit:0,cacheMiss:0,output:0},l={enabled:["deepseek-peak","utc-peak"].includes(u.billingMode)&&c.peakEnabled===!0,effectiveAtMs:Date.parse(c.peakEffectiveAt),windows:c.peakWindows,holidays:c.peakHolidays},m=s?s.requests*s.rateCny:u.priced?Tn(t,d,i,l):0,A=Un(m,s?"CNY":u.currency,_(c).CNY),f=this.config.planBilling,b=Re(this.config),k=s?"api":Bn(r,o,f,b,this.config.prices),g=k==="api"?A:0,M=C=>{let R=Number(C);return Number.isFinite(R)&&R>0?R:0},E={input:M(t?.input),output:M(t?.output),cacheRead:M(t?.cacheRead),cacheWrite:M(t?.cacheWrite),reasoning:M(t?.reasoning)},w=k==="plan"?kt(r,f,o)??(wt(r,o,this.config.prices)?"go":null):null,I={...a?{meter:a}:{},date:Ft(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:w,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...E,calls:1,cost:A,apiCost:g,...Ze(A,g,c)}};return re(this,I)?(this.pendingAccounts.push(I),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};re(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||Oo)),o=Object.keys(this.days).sort();for(;o.length>t;)delete this.days[o.shift()]}scheduleWrite(){this.writeGeneration++,this.pendingWrite=!0,this.writeTimer===null&&(this.writeTimer=setTimeout(()=>{this.writeTimer=null,this.flushAsync()},2e3))}snapshot(){return ge({version:Mo,config:xo(this.config),days:this.days,writeReceipts:this.writeReceipts,balanceRef:this.balanceRef??null,migrations:this.migrations,planSamples:this.planSamples??{},planHourBuckets:this.planHourBuckets??{},openrouterPriceHashes:this.openrouterPriceHashes??{},historyReset:this.historyReset??null,...Object.keys(this.usageCursors).length?{usageCursors:this.usageCursors}:{},...Object.keys(this.providerPriceHashes).length?{providerPriceHashes:this.providerPriceHashes}:{},pricingHistory:this.pricingHistory})}resetHistory(){this.days={},this.planSamples={},this.planHourBuckets={},this.balanceRef=null,this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.historyReset={id:ko(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=ye(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=bo(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=he(o.pricingHistory,Ae(o.config),this.pricingHistory,!0);for(let i of zt)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:xo(Ae(o.config)),days:So(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??It(o.planRecentCalls??[]),openrouterPriceHashes:o.openrouterPriceHashes??{},historyReset:o.historyReset??null,usageCursors:X(o.usageCursors),writeReceipts:H(o.writeReceipts),providerPriceHashes:o.providerPriceHashes??{},pricingHistory:n}}adoptSnapshot(t){this.pricingHistory=he(t.pricingHistory,t.config),this.config=Ae(yo(this.writeBase.config,this.config,t.config));for(let o of["days","balanceRef","migrations","planSamples","planHourBuckets","openrouterPriceHashes","historyReset"])this[o]=t[o];this.usageCursors=X(t.usageCursors),this.writeReceipts=H(t.writeReceipts),this.providerPriceHashes=t.providerPriceHashes??{}}refresh(){if(!this.closed){if(this.pendingWrite){ye(this.path)!==this.diskRevision?this.flush():this.flushAsync();return}try{let t=ye(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(se(this.writeBase,this.snapshot(),o,[],Date.now(),[],{ownLocal:!0})),this.writeBase=this.snapshot(),this.diskRevision=t}catch(t){t?.code!=="ENOENT"&&console.warn(`[dsh-cost-meter] \u8D26\u672C\u5237\u65B0\u5931\u8D25,\u4FDD\u7559\u5F53\u524D\u8BB0\u5F55: ${String(t?.message??t)}`)}}}repairPlanHours(t){this.closed||!t.length||(this.pendingPlanHourRepairs.push(...t),this.writeGeneration++,this.pendingWrite=!0,this.flush())}flush(t=0){if(!(this.backgroundWrite&&!this.backgroundWrite.wait(Math.max(8e3,t)))&&!(!this.pendingWrite||this.closed))try{be(this.path,()=>{We(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=Q(n.days);i.includes(n.balanceRef?.date)&&(n.balanceRef=null);let r=(o===null||o===this.writeBase)&&!this.pendingPlanHourRepairs.length&&!i.length,a=r?n:se(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});$e(this.path,a,this.legacyPricingHistory),this.legacyPricingHistory=!1,r||this.adoptSnapshot(a),this.writeBase=r?a:this.snapshot(),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.pendingWrite=!1,this.diskRevision=ye(this.path)},t)}catch(o){(o?.code!=="EBUSY"||t>0)&&console.warn(`[dsh-cost-meter] \u8D26\u672C\u5199\u5165\u5931\u8D25,\u7A0D\u540E\u91CD\u8BD5: ${String(o?.message??o)}`),this.closed||this.scheduleWrite()}}fallbackWrite(t){this.backgroundWriteDisabled||(this.backgroundWriteDisabled=!0,console.warn(`[dsh-cost-meter] \u540E\u53F0\u8D26\u672C\u4FDD\u5B58\u4E0D\u53EF\u7528\uFF0C\u5DF2\u5207\u6362\u4E3A\u540C\u6B65\u63D0\u4EA4\uFF0C\u672C\u6B21\u8FD0\u884C\u4E0D\u518D\u542F\u52A8\u540E\u53F0\u7EBF\u7A0B: ${String(t?.message??t)}`)),this.flush()}flushAsync(){if(this.backgroundWrite)return this.backgroundWrite.promise;if(this.closed||!this.pendingWrite)return Promise.resolve();if(this.backgroundWriteDisabled)return this.flush(),Promise.resolve();We(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,a=this.writeGeneration,s=ko();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:s,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},c=>{if(this.backgroundWrite=null,c.error){let l;try{l=this.readDiskSnapshot()}catch{}if(H(l?.writeReceipts).includes(s))c={merged:l,revision:ye(this.path)};else{c.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(c.error);return}}let u=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(c.ownDisk)this.writeReceipts=H(c.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let l=se(t,this.snapshot(),c.merged,u,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(l),this.writeBase=c.merged}this.pendingAccounts=u,this.pendingPlanHourRepairs=d,this.pendingWrite=a!==this.writeGeneration||u.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=c.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(c){return this.fallbackWrite(c),Promise.resolve()}}close(){if(this.backgroundWrite)return this.backgroundWrite.promise.then(()=>this.close());this.flush(5e3),this.closed=!0,this.writeTimer!==null&&(clearTimeout(this.writeTimer),this.writeTimer=null)}sumDays(t){let o=Wt(t===void 0?"total":t);for(let[n,i]of Object.entries(this.days))if(!(t!==void 0&&!n.startsWith(t))){o.input+=i.input??0,o.output+=i.output??0,o.cacheRead+=i.cacheRead??0,o.cacheWrite+=i.cacheWrite??0,o.reasoning+=i.reasoning??0,o.calls+=i.calls??0,ae(o,i),o.cost+=i.cost??0,o.apiCost=(o.apiCost??0)+(i.apiCost??i.cost??0);for(let[r,a]of Object.entries(i.byProviderModel??{})){let s=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={...ae({...Ie(s)},a),input:s.input+(a.input??0),output:s.output+(a.output??0),cacheRead:s.cacheRead+(a.cacheRead??0),cacheWrite:s.cacheWrite+(a.cacheWrite??0),reasoning:s.reasoning+(a.reasoning??0),calls:s.calls+(a.calls??0),cost:s.cost+(a.cost??0),apiCost:(s.apiCost??0)+(a.apiCost??a.cost??0)}}}return o.date=t===void 0?"total":t,o}sumRange(t,o){let n=Wt(`${t}..${o}`);if(typeof t!="string"||typeof o!="string")return n;for(let[i,r]of Object.entries(this.days))if(!(i<t||i>o)){n.input+=r.input??0,n.output+=r.output??0,n.cacheRead+=r.cacheRead??0,n.cacheWrite+=r.cacheWrite??0,n.reasoning+=r.reasoning??0,n.calls+=r.calls??0,ae(n,r),n.cost+=r.cost??0,n.apiCost=(n.apiCost??0)+(r.apiCost??r.cost??0);for(let[a,s]of Object.entries(r.byProviderModel??{})){let c=n.byProviderModel[a]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[a]={...ae({...Ie(c)},s),input:c.input+(s.input??0),output:c.output+(s.output??0),cacheRead:c.cacheRead+(s.cacheRead??0),cacheWrite:c.cacheWrite+(s.cacheWrite??0),reasoning:c.reasoning+(s.reasoning??0),calls:c.calls+(s.calls??0),cost:c.cost+(s.cost??0),apiCost:(c.apiCost??0)+(s.apiCost??s.cost??0)}}}return n}today(){let t=Ft(Date.now()),o=this.days[t];return o===void 0?Wt(t):this.copyDay(o)}todayOfficialCost(){return ir(this.days[Ft(Date.now())])}history(t=60){return Object.keys(this.days).sort().reverse().slice(0,t).map(o=>this.copyDay(this.days[o],!0))}copyDay(t,o=!1){let n=o||!Array.isArray(t.sessions)?[]:t.sessions.slice().sort((i,r)=>r.cost-i.cost).map(i=>({...i}));return{...Ie(t),date:String(t.date),input:t.input??0,output:t.output??0,cacheRead:t.cacheRead??0,cacheWrite:t.cacheWrite??0,reasoning:t.reasoning??0,calls:t.calls??0,cost:t.cost??0,apiCost:t.apiCost??t.cost??0,byProviderModel:t.byProviderModel??{},sessions:n}}};var Co=e=>{try{let t=cr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:we,base:_o,local:ee,pending:lr,repairs:vo,revision:ur,backupHistory:dr,transactionId:pr,now:fr,port:$t,signal:Po,lockId:hr}=ar;try{let e=be(we,()=>{let t=Co(we)===ur,o=Q(ee.days);o.includes(ee.balanceRef?.date)&&(ee.balanceRef=null);let n=t&&!vo.length&&!o.length,i=ee;if(!n){let r=new Ye(ee.config,{},we,[],{pricingHistory:ee.pricingHistory});r.writeBase=_o,i=se(_o,ee,r.readDiskSnapshot(),lr,fr,vo,{ownLocal:!0})}return i.writeReceipts=H([...i.writeReceipts??[],pr]),$e(we,i,dr),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Co(we)}},5e3,hr);$t.postMessage(e)}catch(e){$t.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Po,0,1),Atomics.notify(Po,0),$t.close()}
2
+ import{workerData as ar}from"node:worker_threads";import{statSync as cr}from"node:fs";var v=["costCny","apiCostCny","costEur","apiCostEur"],Vt=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function _(e={}){let t={USD:1,CNY:7.2,EUR:.92};for(let o of["CNY","EUR"])Vt(e.fxRates?.[o])&&(t[o]=e.fxRates[o]);return["CNY","EUR"].includes(e.currency)&&Vt(e.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ze(e,t,o){let n=_(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Ie(e){return Object.fromEntries(v.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function ae(e,t,o=1){for(let n of v)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Zt(e,t){let o=n=>{let i=Ze(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of v)(!Number.isFinite(n[r])||n[r]<0)&&(n[r]=i[r]);for(let r of Object.values(n.byProviderModel??{}))r&&typeof r=="object"&&o(r);for(let r of n.sessions??[])o(r)};for(let n of Object.values(e??{}))o(n)}var Jt=["today","summary","budget"],Xt=e=>e&&typeof e=="object"&&!Array.isArray(e);function en(e){return Xt(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Xt(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Jt.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Jt.some(o=>!t[o]))):{}}import{readFileSync as Vi,renameSync as Ao,statSync as Zi}from"node:fs";import{randomUUID as ko}from"node:crypto";var tn=5/1e3,Uo=Date.parse("2026-11-01T00:00:00+08:00"),nn=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function on(e,t){return t.source==="server-tool"?e==="deepseek-search-server"&&t.kind==="search":[`deepseek-web-${t.kind}`,`deepseek-${t.kind}-api`].includes(e)}function rn(e,t){return!e||!["search","fetch"].includes(e.kind)||e.requests!==1?!1:e.source==="server-tool"?e.kind==="search"&&Number.isFinite(t)&&e.rateCny===(t<Uo?0:tn):e.source===void 0&&e.rateCny===tn}var Je=["input","output","cacheRead","cacheWrite","reasoning","calls"],B=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Q(e){let t=[];for(let[o,n]of Object.entries(e??{})){let i=n?.sessions;if(!Array.isArray(i)||!i.length||!(n.calls>0))continue;let r=new Set,a=v.filter(l=>i.every(h=>B(h?.[l]))),s=Object.fromEntries([...Je,"cost","apiCost",...a].map(l=>[l,0])),c=new Map,u=!0;for(let l of i){if(!l?.id||r.has(l.id)){u=!1;break}r.add(l.id);for(let h of Object.keys(s)){let A=h==="apiCost"?l.apiCost??l.cost:l[h]??0;if(!B(A)){u=!1;break}s[h]+=A}if(!u||s.apiCost>s.cost+1e-8){u=!1;break}for(let[h,A]of Object.entries(l.byProviderModel??{})){if(c.has(h)&&c.get(h)===null)continue;let f=c.get(h)??Object.fromEntries(Object.keys(s).map(k=>[k,0])),b=A!==null&&typeof A=="object";for(let k of Object.keys(f)){if(v.includes(k)&&!B(A?.[k])){delete f[k];continue}let g=k==="apiCost"?A?.apiCost??A?.cost:A?.[k]??0;if(!B(g)){b=!1;break}f[k]+=g}c.set(h,b?f:null)}}if(!u||!Object.values(s).every(B)||!Je.every(l=>B(n[l]??0)&&s[l]===(n[l]??0)))continue;let d=Math.abs(s.cost-(n.cost??0))>1e-8||Math.abs(s.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=s.cost,n.apiCost=s.apiCost);for(let l of a)Math.abs(s[l]-(n[l]??0))>1e-8&&(n[l]=s[l],d=!0);for(let[l,h]of c){let A=n.byProviderModel?.[l];if(!(!h||!A||!h.calls||!Object.values(h).every(B)||!Je.every(f=>h[f]===(A[f]??0)))&&!(Math.abs(h.cost-(A.cost??0))<=1e-8&&Math.abs(h.apiCost-(A.apiCost??A.cost??0))<=1e-8&&a.every(f=>!B(h[f])||Math.abs(h[f]-(A[f]??0))<=1e-8))){for(let f of a)B(h[f])&&(A[f]=h[f]);A.cost=h.cost,A.apiCost=h.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as Do,MessageChannel as jo,receiveMessageOnPort as sn}from"node:worker_threads";import{randomUUID as Ho}from"node:crypto";import{unlinkSync as Lo,rmdirSync as Bo}from"node:fs";import{join as Fo}from"node:path";function an(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new jo,a=new Int32Array(new SharedArrayBuffer(4)),s=!1,c,u,d,l=Ho(),h=new Promise(k=>{c=k}),A=new Do(n,{workerData:{...e,signal:a,port:r,lockId:l},transferList:[r],execArgv:[]}),f=k=>{if(!s){s=!0,clearTimeout(b);try{t(k)}finally{i.close(),A.terminate(),c()}}},b=setTimeout(()=>{u={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},A.terminate().then(()=>f(u))},o);return b.unref?.(),i.on("message",f),A.on("error",k=>{d={error:{message:k.message,code:k.code}}}),A.on("exit",k=>{if(!s){try{Lo(Fo(`${e.path}.lock`,`${process.pid}-${l}`)),Bo(`${e.path}.lock`)}catch{}f(sn(i)?.message??u??d??{error:{message:`Ledger worker exited (${k})`}})}}),{promise:h,wait(k=8e3){let g=Date.now()+k;for(;!s;){let M=sn(i);if(M){f(M.message);break}if(Date.now()>=g)return!1;Atomics.wait(a,0,0,Math.min(50,g-Date.now()))}return!0}}}function Xe(e){return["input","output","cacheRead","cacheWrite"].reduce((t,o)=>{let n=e?.[o];return t+(typeof n=="number"&&Number.isFinite(n)&&n>0?n:0)},0)}import{mkdirSync as po,readdirSync as Hi,writeFileSync as ho,readFileSync as Li,renameSync as Bi,unlinkSync as Ke,rmdirSync as ze,statSync as Fi,copyFileSync as Wi,constants as zi}from"node:fs";import{dirname as Ki,join as me}from"node:path";import{randomUUID as mo}from"node:crypto";import{isDeepStrictEqual as N}from"node:util";var cn=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,Wo=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,zo=/^(sk-[A-Za-z0-9_-]|rk-[A-Za-z0-9_-]|gsk_[A-Za-z0-9]|AIza[0-9A-Za-z_-]{10,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[bap]-|eyJ[A-Za-z0-9_-]{10,})/;function et(e,t){if(typeof t!="string"||t.length===0)return!1;if(cn.test(t)){let n=t.replace(new RegExp(cn.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(Wo.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||zo.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var ln="https://api.factory.ai/api/billing/limits";var un=e=>{if(e==null||e==="")return"";if(typeof e!="string")return null;let t=e.trim();return t===""||/^[A-Za-z0-9_.:-]{1,128}$/.test(t)?t:null};var Se="https://amr-api.open-design.ai/api/v1",Pr=Se+"/public/model-prices",tt=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],Nr=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var Ko=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function dn(e){return e===void 0||e===""?"":typeof e=="string"&&Ko(e.trim())?e.trim():null}import{homedir as nt}from"node:os";import{basename as Dr,dirname as jr,join as pn,resolve as $o}from"node:path";var fn=".dsh",Hr=`~/${fn}`,qo="DSH_HOME",Yo=".agents",Lr=`~/${Yo}`;function Go(){return pn(nt(),fn)}function Qo(e){return e==="~"?nt():e.startsWith("~/")||e.startsWith("~\\")?pn(nt(),e.slice(2)):e}function Vo(e,t,o,n){let i=t[o];return $o(Qo(e??(i!==void 0&&i.trim().length>0?i:n())))}function ot(e,t=process.env){return Vo(e,t,qo,Go)}var it=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var Xo=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var ss=672*60*60,as=744*60*60;var ys=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),As=Object.freeze(["CPA_REDIRECT_REFUSED","CPA_AUTH_FAILED","CPA_OUTER_HTTP_ERROR","CPA_INNER_HTTP_ERROR","CPA_RESPONSE_INVALID","PROVIDER_PARSE_ERROR","PROVIDER_CAPABILITY_MISSING","WORKBUDDY_PLUGIN_UNAVAILABLE","SOURCE_BLOCKED_BY_POLICY"]);var ei={opendesign:{label:"OpenDesign",credentialEnvs:["OPENDESIGN_CONTROL_KEY","VELA_CONTROL_KEY"],keyHint:"OpenDesign Control Key (quota only; not the inference API key)"},factory:{label:"Factory (Droid)",credentialEnvs:["FACTORY_API_KEY"],keyHint:"Factory \u989D\u5EA6\u67E5\u8BE2\u51ED\u636E(DSH \u51ED\u636E\u5E93 / FACTORY_API_KEY)"},anthropic:{label:"Anthropic (Claude Pro/Max)",credentialEnvs:["ANTHROPIC_OAUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN"],keyHint:"Claude Code OAuth access token(~/.claude/.credentials.json)"},zai:{label:"Z.ai / \u667A\u8C31 GLM Coding Plan",credentialEnvs:["ZAI_API_KEY","BIGMODEL_API_KEY"],keyHint:"Coding Plan \u4E13\u5C5E API Key(z.ai / bigmodel.cn \u63A7\u5236\u53F0)"},minimax:{label:"MiniMax Token Plan",credentialEnvs:["MINIMAX_API_KEY"],keyHint:"MiniMax API Key(sk-* / sk-cp-*)"},kimi:{label:"Kimi / Moonshot",credentialEnvs:["KIMI_CODING_API_KEY","MOONSHOT_API_KEY","KIMI_API_KEY"],keyHint:"Kimi Code \u8BA2\u9605 Key(sk-kimi-*,\u5373 coding \u63A8\u7406\u7AEF\u70B9\u7528\u7684 Key)\u663E\u793A\u672C\u5468/5 \u5C0F\u65F6\u914D\u989D;\u4EC5\u914D\u5F00\u653E\u5E73\u53F0 Key \u65F6\u663E\u793A PAYG \u4F59\u989D"},openrouter:{label:"OpenRouter",credentialEnvs:["OPENROUTER_API_KEY"],keyHint:"OpenRouter API Key(sk-or-*;\u663E\u793A\u9884\u4ED8 credits \u5DF2\u7528%)"},siliconflow:{label:"SiliconFlow \u7845\u57FA\u6D41\u52A8",credentialEnvs:["SILICONFLOW_API_KEY"],keyHint:"SiliconFlow API Key(sk-*;\u663E\u793A\u8D26\u6237\u4F59\u989D)"},commandcode:{label:"CommandCode",credentialEnvs:["COMMANDCODE_API_KEY"],keyHint:"commandcode.ai API Key(user_*;\u663E\u793A 5 \u5C0F\u65F6/\u5468\u7A97\u53E3\u7528\u91CF% \u4E0E\u6708\u5EA6 Credits \u4F59\u989D)"},clinepass:{label:"Cline Pass",credentialEnvs:["CLINE_PASS_API_KEY"],keyHint:"Cline Pass API Key(sk_*;\u663E\u793A 5 \u5C0F\u65F6/\u5468/\u6708\u4E09\u7A97\u53E3\u7528\u91CF%)"},scnet:{label:"SCNet \u8D85\u7B97\u4E92\u8054\u7F51 Token Plan",credentialEnvs:[],keyHint:"\u65E0\u9700\u51ED\u636E:\u6309\u5B98\u65B9 Credits \u62B5\u6263\u8868(2026-08-11 \u751F\u6548)\u7531\u672C\u5730\u8D26\u672C\u4F30\u7B97\u6708\u5EA6\u7528\u91CF"},volcengine:{label:"\u706B\u5C71\u65B9\u821F Volcano Ark Coding Plan",credentialEnvs:["VOLC_ACCESSKEY","VOLCENGINE_ACCESS_KEY_ID","VOLCENGINE_ACCESS_KEY","ARK_ACCESS_KEY_ID"],credentialEnvsSecret:["VOLC_SECRETKEY","VOLCENGINE_SECRET_ACCESS_KEY","VOLCENGINE_SECRET_KEY","ARK_SECRET_ACCESS_KEY"],keyHint:"\u706B\u5C71\u5F15\u64CE\u8BBF\u95EE\u5BC6\u94A5 AccessKeyID + SecretAccessKey(\u63A7\u5236\u53F0 IAM\u2192\u7528\u6237\u2192\u5BC6\u94A5,\u9700 ArkReadOnlyAccess + BillingCenterReadOnlyAccess;\u6216\u5BFC\u51FA VOLC_ACCESSKEY / VOLC_SECRETKEY)"},qwen:{label:"\u5343\u95EE Qwen Token Plan",credentialEnvs:[],keyHint:"\u672C\u5730\u4F30\u7B97\u65E0\u9700\u51ED\u636E\uFF1B\u5B98\u65B9 CLI \u6A21\u5F0F\u9700\u5728 DSH \u4E3B\u673A\u8FD0\u884C qianwen auth login"},mimo:{label:"\u5C0F\u7C73 MiMo Token Plan",credentialEnvs:["MIMO_COOKIE","XIAOMI_MIMO_COOKIE"],keyHint:"\u5C0F\u7C73\u5F00\u653E\u5E73\u53F0\u63A7\u5236\u53F0 Cookie(\u767B\u5F55 platform.xiaomimimo.com \u540E F12\u2192\u7F51\u7EDC\u2192balanceAlertConfig\u2192\u8BF7\u6C42\u5934 cookie \u6574\u6BB5\u590D\u5236)"},workbuddy:{label:"WorkBuddy \u79EF\u5206",credentialEnvs:[],keyHint:"\u65E0\u9700\u590D\u5236\u51ED\u636E\uFF1B\u652F\u6301 dsh-workbuddy-connect / dsh-connect-workbuddy / dsh-xdpool\uFF0C\u517C\u5BB9\u65E7\u7248\u660E\u6587\u767B\u5F55\u6587\u4EF6"}},ce=Object.keys(ei);var st="https://platform.xiaomimimo.com/api/v1",ti={usage:`${st}/tokenPlan/usage`,detail:`${st}/tokenPlan/detail`,balance:`${st}/balance`},hn=["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"];var ni="open.volcengineapi.com";var oi="2024-01-01",ii=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var ri={"GLM-5.2":{input:7543,cachedInput:189,output:26400},"GLM-5.1":{input:8743,cachedInput:175,output:32057},"GLM-5":{input:8743,cachedInput:175,output:32057},"DeepSeek-V4-Pro":{input:10286,cachedInput:86,output:20571},"DeepSeek-V4-Flash":{input:1200,cachedInput:24,output:2400},"DeepSeek-V4-Flash-0731":{input:1543,cachedInput:31,output:3086},"Kimi-K3":{input:34286,cachedInput:343,output:171429},"Kimi-K2.7-Code":{input:8357,cachedInput:167,output:34714},"Kimi-K2.6":{input:8357,cachedInput:167,output:34714},"Kimi-K2.5":{input:5143,cachedInput:103,output:27e3},"MiniMax-M3":{input:3600,cachedInput:72,output:14400},"MiniMax-M2.7":{input:3600,cachedInput:72,output:14400},"MiniMax-M2.5":{input:2520,cachedInput:50,output:10080},"Qwen3.8-max":{input:18514,cachedInput:231,output:49371}};function mn(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var Qs=Object.fromEntries(Object.entries(ri).map(([e,t])=>[mn(e),t]));var gn=["scnet","scnet-tokenplan","scnet-token-plan"];var si={"qwen3.8-max-preview":{input:60,cachedInput:6,output:60},"qwen3.7-max":{input:60,cachedInput:6,output:60},"qwen3.7-plus":{input:15,cachedInput:1.5,output:60},"qwen3.6-flash":{input:3,cachedInput:.3,output:12},"glm-5.2":{input:45,cachedInput:4.5,output:120},"deepseek-v4-pro":{input:45,cachedInput:4.5,output:90},"deepseek-v4-flash":{input:3,cachedInput:.3,output:12},"kimi-k2.7-code":{input:30,cachedInput:3,output:60},"kimi-k2.6":{input:30,cachedInput:3,output:60},"minimax-m2.5":{input:30,cachedInput:3,output:60}},Vs=Object.fromEntries(Object.entries(si).map(([e,t])=>[mn(e),t])),bn=["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"];var Zs={opendesign:[Se+"/workspaces/{workspaceId}/billing/preflight",Se+"/workspaces/{workspaceId}/wallet/balance"],factory:[ln],anthropic:["https://api.anthropic.com/api/oauth/usage"],zai:["https://open.bigmodel.cn/api/monitor/usage/quota/limit","https://api.z.ai/api/monitor/usage/quota/limit","https://api.z.ai/api/coding/paas/v3/dashboard/billing/coding_plan/usage","https://open.bigmodel.cn/api/coding/paas/v3/dashboard/billing/coding_plan/usage","https://api.z.ai/api/coding/paas/v4/dashboard/billing/coding_plan/usage","https://open.bigmodel.cn/api/coding/paas/v4/dashboard/billing/coding_plan/usage"],minimax:["https://www.minimax.cn/v1/token_plan/remains","https://www.minimax.io/v1/token_plan/remains","https://www.minimaxi.com/v1/token_plan/remains","https://www.minimax.cn/v1/api/openplatform/coding_plan/remains","https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains"],kimi:["https://api.kimi.com/coding/v1/usages","https://api.kimi.com/coding/v1/usage","https://api.moonshot.cn/v1/users/me/balance"],openrouter:["https://openrouter.ai/api/v1/credits"],siliconflow:["https://api.siliconflow.cn/v1/user/info"],commandcode:["https://api.commandcode.ai/alpha/billing/credits"],clinepass:["https://api.cline.bot/api/v1/users/me/plan/usage-limits"],scnet:[],qwen:[],volcengine:ii.map(e=>`https://${ni}/?Action=${e}&Version=${oi}`),mimo:[ti.usage],workbuddy:[]};function yn(e){if(e===void 0||e==="")return"";if(typeof e!="string"||e.length>2048)return null;let t=e.trim();if(!t)return"";if(!/^https:\/\/[^/?#]+\/?$/i.test(t)||/[\s\\@?#]/.test(t))return null;try{let o=new URL(t);return!o.hostname||o.username||o.password||o.pathname!=="/"?null:o.origin}catch{return null}}var at=/^(base|offPeak|peak|legacyBase|longContext|cny)\.(cacheHit|cacheMiss|cacheWrite|output|reasoning)$/;function xe(e){return Object.fromEntries(["multiplier","separateMultipliers","multipliers"].filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function An(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function ct(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*An(t,o+"."+i));return e.longContext&&(n.longContext={...ct(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function kn(e){let t=xe(e);return t.multipliers&&(t.multipliers=Object.fromEntries(Object.entries(t.multipliers).filter(([o])=>o.startsWith("cny.")).map(([o,n])=>[o.replace("cny.","base."),n]))),{...e.cny,...t}}function lt(e){if(e.multiplier===void 0&&e.separateMultipliers===void 0&&e.multipliers===void 0)return!0;let t=o=>typeof o=="number"&&Number.isFinite(o)&&o>=0;if(e.multiplier!==void 0&&!t(e.multiplier)||e.separateMultipliers!==void 0&&typeof e.separateMultipliers!="boolean"||e.multipliers!==void 0&&(!e.multipliers||typeof e.multipliers!="object"||Array.isArray(e.multipliers)||Object.entries(e.multipliers).some(([o,n])=>!at.test(o)||!t(n))))return!1;for(let o of[e,...e.rateHistory??[]])for(let n of["base","offPeak","peak","legacyBase","longContext","cny"]){let i=n==="base"?o:o[n];if(i){for(let r of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])if(i[r]!==void 0&&!Number.isFinite(i[r]*An(e,n+"."+r)))return!1}}return!0}var ut={"opencode-zen":{models:{"deepseek-v4.1-flash-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"cat-jam-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"step-5-preview-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"exo-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"mistral-large-4":{input:.68,output:2.09,cachedInput:.07,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15",notes:"Current published gateway rate; independent of the direct API."},"claude-sonnet-5-5":{input:2,output:10,cachedInput:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,output:2.5,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"},"gemini-4-argon":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15",notes:"Current published promotional rate; gateway pricing is independent of the direct API."},"gpt-6.1-sol":{input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-15"}}},"opencode-go":{models:{"step-5-preview-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"cat-jam-free":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"space-bunny":{input:.15,output:.6,cachedInput:.03,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,output:2.5,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15"},"gemini-4-argon-contributor":{input:4,output:20,cachedInput:.2,billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-15",notes:"Current published promotional rate; gateway pricing is independent of the direct API."}}},anthropic:{models:{"claude-haiku-5-5":{input:.1,output:.5,cachedInput:.01,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-15",cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,cacheHit:.05,cacheWrite:.625,output:2.5},notes:"Standard global API; cache writes use 5-minute TTL. Prompts over 100000 tokens, including cache reads/writes, use the higher tier for the entire request. 1-hour TTL and fast/regional surcharges are excluded."},"claude-sonnet-5-5":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-15",cacheWrite:2.5,notes:"Standard global API; 5-minute cache writes. Direct API cache-read rate differs from OpenCode Zen."}}},google:{models:{"gemini-4-argon":{input:2,output:10,cachedInput:.1,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard paid tier. Promotional USD 2/10/0.10 input/output/cache read through 2026-11-30; official announced prices from 2026-12-01 are USD 4/20/0.20. Implicit caching only. Recheck the catalog when the promotion ends; the source does not specify a timezone."}}},mistral:{models:{"mistral-large-4":{input:.68,output:2.09,cachedInput:.07,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-15",notes:"Current published sale price: 50% off USD 1.36/4.18/0.14 input/output/cached input. Public-preview model ID from https://docs.mistral.ai/models/mistral-large-4-0 . No promotion end date is published."}}},openai:{models:{"gpt-rosalind-research":{input:5,output:25,cachedInput:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard global API token price. Trusted-access model; catalog inclusion does not grant access. Research billing begins 2026-10-05. Cache-write pricing does not apply."},"gpt-rosalind-discovery":{input:5,output:25,cachedInput:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",notes:"Standard global API token price. Trusted-access model; catalog inclusion does not grant access. Research billing begins 2026-10-05. Cache-write pricing does not apply."},"gpt-5.6-cyber":{input:12.5,output:75,cachedInput:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-15",cacheWrite:15.625,notes:"Standard global API token price for the restricted-access cyber model. No separate long-context rate is published."}}}};var ai="https://platform.stepfun.ai/docs/en/guides/pricing/details",le=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:ai,checkedAt:"2026-10-16",notes:"StepFun global API, USD per million tokens. Reasoning is included in output. Regional pricing, Step Plan, search and audio/image generation charges are not included."}),wn={models:{"step-5-preview":le(1,.1,2.7),"step-3.7-flash":le(.2,.04,1.15),"step-3.5-flash":le(.1,.02,.3),"step-3.5-flash-2603":le(.1,.02,.3),"step-1o-turbo-vision":le(.36,.07,1.15)}};var Ee={openai:{models:{"gpt-6-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5}},"gpt-6.1-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5}},"gpt-6-luna":{input:.1,output:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,cacheHit:.02,output:.75,cacheWrite:.25}},"gpt-6-astra":{input:10,output:50,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,output:75,cacheWrite:25}},"gpt-5.6-sol":{input:4,output:20,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,cacheHit:.8,output:30,cacheWrite:10}},"gpt-5.6-terra":{input:2,output:12,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:18,cacheWrite:5}},"gpt-5.6-luna":{input:.2,output:1.2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,cacheHit:.04,output:1.8,cacheWrite:.5}},"gpt-5.5":{input:5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,cacheHit:1,output:45}},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Published direct Standard rates: short input30/output180; long input60/output270 USD/M. The pricing table labels short context<272K, but the model detail does not establish the exact equality/context counting rule. Intentionally unpriced pending clarification; no guessed boundary.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270},unpriced:!0},"gpt-5.4":{input:2.5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,cacheHit:.5,output:22.5}},"gpt-5.4-mini":{input:.75,output:4.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},"gpt-5.4-nano":{input:.2,output:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.02},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270}},"gpt-5.2":{input:1.75,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.175},"gpt-5.2-pro":{input:21,output:168,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-5.1":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5-mini":{input:.25,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-5-nano":{input:.05,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.005},"gpt-5-pro":{input:15,output:120,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4.1":{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"gpt-4.1-mini":{input:.4,output:1.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.1},"gpt-4.1-nano":{input:.1,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-4o":{input:2.5,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:1.25},"gpt-4o-2024-05-13":{input:5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4o-mini":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},o1:{input:15,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:7.5},"o1-pro":{input:150,output:600,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"o3-pro":{input:20,output:80,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},o3:{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"o4-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.275},"o3-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.55},"gpt-4-turbo-2024-04-09":{input:10,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4-0613":{input:30,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-0125":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-1106":{input:1,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-instruct":{input:1.5,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"davinci-002":{input:2,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"babbage-002":{input:.4,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"chat-latest":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for ChatGPT. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Codex. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5-search-api":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Search. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."}}},anthropic:{models:{"claude-fable-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-5-5":{input:4,cachedInput:.2,cacheWrite:5,output:20,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is8USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-5-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-haiku-4-5":{input:1,cachedInput:.1,cacheWrite:1.25,output:5,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is2USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-mythos-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-fable-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-mythos-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-opus-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-8":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-7":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-6":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-sonnet-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-6":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is6USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-5":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Current direct Claude Sonnet 4.5: maximum 200K context; 1M beta retired 2026-04-30 and over-limit requests fail. Standard rates for valid requests; 5-minute cache writes3.75USD/M, 1-hour writes6USD/M need TTL-specific accounting. Zen publishes a separate route with a long-context tier. Sources: https://platform.claude.com/docs/en/build-with-claude/context-windows and https://platform.claude.com/docs/en/release-notes/overview."}}},google:{models:{"gemini-3.8-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.7-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.6-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.1-flash-lite":{input:.25,cachedInput:.025,output:1.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid text/image/video input. Audio input0.50/cacheRead0.05 USD/M is a different modality; this generic token row cannot price that accurately. Cache storage1USD/M/hour and grounding excluded."}}},xai:{models:{"grok-4.7":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2,cacheHit:.4,output:4}},"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:.6,output:12}},"grok-4.3":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-multi-agent-0309":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-non-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-large-latest":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3-5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-latest":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-2603":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-latest":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-2512":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-latest":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-2512":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-latest":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-2512":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-latest":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"zai-glm-5-3":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-5":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-latest":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"codestral-2508":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-latest":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-embed-2505":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."},"codestral-embed":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."}}},"z-ai":{models:{"glm-5.3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3-flashx":{input:.37,output:1.25,cachedInput:.075,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.2":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.1":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5":{input:1,output:3.2,cachedInput:.2,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flashx":{input:.07,output:.4,cachedInput:.01,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-x":{input:2.2,output:8.9,cachedInput:.45,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-air":{input:.2,output:1.1,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-airx":{input:1.1,output:4.5,cachedInput:.22,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4-32b-0414-128k":{input:.1,output:.1,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v":{input:.3,output:.9,cachedInput:.05,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5v":{input:.6,output:1.8,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-ocr":{input:.03,output:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Official direct token pricing row. Separate Layout Parsing API can charge per page; this token entry cannot price page billing."}}},"opencode-zen":{models:{"big-pickle":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.5-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.1-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.0-flash-fin-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3-ultra-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3.5-lightning-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"muse-spark-1.3-contributor-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"jev-1.13-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0},"jev-1.13":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.042,output:0},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:3.2,cachedInput:.2},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"kimi-k2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.6,output:3,cachedInput:.1},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:7.5,cachedInput:.5,cacheWrite:3.125},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5},"qwen3.6-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05,cacheWrite:.625},"qwen3.5-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25},"deepseek-v4.1-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"deepseek-v4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.74,output:3.48,cachedInput:.145},"deepseek-v4-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"deepseek-v4-flash-vision-exp":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"claude-fable-5-1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:.25,cacheWrite:12.5},"claude-fable-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5},"claude-opus-5-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.2,cacheWrite:5},"claude-opus-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-8":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-sonnet-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5},"claude-sonnet-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75},"claude-sonnet-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75,longContext:{aboveInputTokens:2e5,cacheMiss:6,output:22.5,cacheHit:.6,cacheWrite:7.5}},"claude-haiku-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:5,cachedInput:.1,cacheWrite:1.25},"gemini-3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.7-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.5-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:9,cachedInput:.15},"gemini-3.5-flash-lite":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:2.5,cachedInput:.03},"gemini-3.1-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:18,cacheHit:.4}},"gemini-3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.3,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:.6}},"grok-build-0.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:2,cachedInput:.2},"muse-spark-1.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"muse-spark-1.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"gpt-6-astra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25}},"gpt-6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5}},"gpt-6.1-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10}},"gpt-5.6-terra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}},"gpt-5.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:30,cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,output:45,cacheHit:1}},"gpt-5.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:15,cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,output:22.5,cacheHit:.5}},"gpt-5.4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.75,output:4.5,cachedInput:.075},"gpt-5.4-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.25,cachedInput:.02},"gpt-5.3-codex-spark":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.3-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:10,cachedInput:.125},"gpt-5.1-codex-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.25,output:2,cachedInput:.025},"gpt-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.05,output:.4,cachedInput:.005}}},"opencode-go":{models:{"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"longcat-2.0":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.6-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"mimo-v2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06,cacheWrite:.375},"muse-spark-1.3-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"muse-spark-1.2-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5,longContext:{aboveInputTokens:256e3,cacheMiss:1.2,output:4.8,cacheHit:.12,cacheWrite:1.5}},"deepseek-v4.1-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-pro":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.66,output:1.98,cacheHit:.022},input:.66,output:1.98,cachedInput:.022,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:1.32,output:3.96,cacheHit:.044}},"deepseek-v4-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-flash-vision-exp":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"hy4-preview":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.834,output:2.501,cachedInput:.042},hy3:{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.58,cachedInput:.035},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}}}}},dt=Object.fromEntries([...new Set([...Object.keys(Ee),...Object.keys(ut)])].map(e=>[e,{models:{...Ee[e]?.models,...ut[e]?.models}}]));dt.stepfun=wn;var Mn={"claude-fable-5":{cacheMiss:10,output:50,cacheHit:1,cacheWrite:12.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-fable-5.1":{cacheMiss:10,output:50,cacheHit:.25,cacheWrite:12.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-haiku-5.5":{cacheMiss:.1,output:.5,cacheHit:.01,cacheWrite:.125,longContext:{aboveInputTokens:1e5,cacheMiss:.5,output:2.5,cacheHit:.05,cacheWrite:.625},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-4.8":{cacheMiss:5,output:25,cacheHit:.5,cacheWrite:6.25,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-5":{cacheMiss:5,output:25,cacheHit:.5,cacheWrite:6.25,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-opus-5.5":{cacheMiss:4,output:20,cacheHit:.2,cacheWrite:5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-sonnet-5":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"claude-sonnet-5.5":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4.1-flash":{cacheMiss:.3,output:1.2,cacheHit:.006,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-flash":{cacheMiss:.44,output:1.32,cacheHit:.014,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-flash-vision-exp":{cacheMiss:.44,output:1.32,cacheHit:.014,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"deepseek-v4-pro":{cacheMiss:1.32,output:3.96,cacheHit:.044,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gemini-3.7-flash":{cacheMiss:.75,output:3.75,cacheHit:.075,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gemini-3.8-flash":{cacheMiss:.75,output:3.75,cacheHit:.075,cacheWrite:.08333,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.2":{cacheMiss:1.4,output:4.4,cacheHit:.26,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.3-flash":{cacheMiss:.075,output:.25,cacheHit:.015,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"glm-5.3-flashx":{cacheMiss:.37,output:1.25,cacheHit:.075,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-luna":{cacheMiss:.2,output:1.2,cacheHit:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-sol":{cacheMiss:4,output:20,cacheHit:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-5.6-terra":{cacheMiss:2,output:12,cacheHit:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6.1-sol":{cacheMiss:2,output:10,cacheHit:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-astra":{cacheMiss:10,output:50,cacheHit:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-luna":{cacheMiss:.1,output:.5,cacheHit:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"gpt-6-sol":{cacheMiss:2,output:10,cacheHit:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5},billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.5":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.6":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"grok-4.7":{cacheMiss:2,output:6,cacheHit:.5,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"hy4-preview":{cacheMiss:.834,output:2.501,cacheHit:.042,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"kimi-k2.7-code":{cacheMiss:.95,output:4,cacheHit:.19,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"kimi-k3":{cacheMiss:3,output:15,cacheHit:.3,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"mimo-v2.6-flash":{cacheMiss:.14,output:.28,cacheHit:.0028,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"mimo-v2.6-pro":{cacheMiss:.435,output:.87,cacheHit:.0036,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"muse-spark-1.3":{cacheMiss:1.25,output:4.25,cacheHit:.15,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"muse-wonder":{cacheMiss:4,output:20,cacheHit:.2,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"},"qwen3.7-max":{cacheMiss:2.5,output:7.5,cacheHit:.5,cacheWrite:3.125,billingMode:"flat",sourceUrl:"https://amr-api.open-design.ai/api/v1/public/model-prices",checkedAt:"2026-10-15"}};var Sn="2026-08-01T00:00:00Z",gt="2026-08-22T16:00:00Z",ve=["2026-09-25","2026-09-26","2026-09-27","2026-10-01","2026-10-02","2026-10-03","2026-10-04","2026-10-05","2026-10-06","2026-10-07"],pt="2026-09-10T04:00:00Z",ci="2026-08-31T00:00:00Z",In=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function li(e){if(!Number.isFinite(e)||e<Date.parse(gt))return null;let t=Math.floor((e+8*36e5)/864e5),o=(t+4)%7;if(o!==6&&o!==0)return null;let n=o===6?t:t-1,i=Math.max(n*864e5-8*36e5,Date.parse(gt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function ui(e,t=ve){if(!Number.isFinite(e)||e<Date.parse(gt)||!Array.isArray(t))return null;let o=Math.floor((e+8*36e5)/864e5),n=new Date(o*864e5).toISOString().slice(0,10);return t.includes(n)?{start:o*864e5-8*36e5,end:(o+1)*864e5-8*36e5}:null}var di=(e,t)=>ui(e,t)??li(e),pi="2026-08-16T16:00:00Z";var xn=[{start:1,end:4},{start:6,end:10}],ue={openai:{models:{"gpt-6-astra":{input:10,cachedInput:1,cacheWrite:12.5,output:50,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,cacheWrite:25,output:75},billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/models/gpt-6-astra",checkedAt:"2026-09-11",notes:"\u6807\u51C6 API \u4EF7\uFF0COpenCode Zen \u540C\u4EF7\uFF1B\u5B8C\u6574\u8F93\u5165\uFF08\u542B\u7F13\u5B58\u8BFB\u5199\uFF09\u8D85\u8FC7 272K \u65F6\u6574\u6B21\u8BF7\u6C42\u6309\u957F\u4E0A\u4E0B\u6587\u6863\u8BA1\u8D39\uFF1B\u4E0D\u542B Batch/Flex/Fast \u670D\u52A1\u6863\u6298\u6263\u6216\u500D\u7387"},"gpt-5.6-sol":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $4/$15 \u8BA1(\u7F13\u5B58\u8BFB $0.40\u3001\u5199\u5165 $5);\u7F13\u5B58\u5199\u5165 $2.50;\u76EE\u5F55\u6807\u6CE8 2026-09-18 \u524D\u4E3A\u4E94\u6298\u4FC3\u9500\u4EF7(issue #58)"},"gpt-5.6-terra":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $4/$18 \u8BA1;\u7F13\u5B58\u5199\u5165 $2.50"},"gpt-5.6-luna":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $0.40/$1.80 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.25"},"gpt-5.5":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $10/$45 \u8BA1"},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4":{input:2.5,cachedInput:.25,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264272K \u6863;\u8D85\u8FC7 272K \u6309 $5/$22.5 \u8BA1"},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4-mini":{input:.75,cachedInput:.075,output:4.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.4-nano":{input:.2,cachedInput:.02,output:1.25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.3-codex-spark":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.2":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.2-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5.1-codex":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1-codex-max":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5.1-codex-mini":{input:.25,cachedInput:.025,output:2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5-codex":{input:1.07,cachedInput:.107,output:8.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-07-23 \u8D77\u5F03\u7528"},"gpt-5-nano":{input:.05,cachedInput:.005,output:.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"gpt-5-2025-08-07":{input:1.25,cachedInput:.13,output:10,billingMode:"flat",notes:"2025-08 \u9996\u53D1\u4EF7;\u5F53\u524D\u540C\u540D gpt-5 \u5DF2\u8C03\u4EF7,\u5386\u53F2 id \u4FDD\u7559"},"gpt-4.1-2025-04-14":{input:2,cachedInput:.5,output:8,billingMode:"flat"},"gpt-4.1-mini-2025-04-14":{input:.4,cachedInput:.1,output:1.6,billingMode:"flat"}}},anthropic:{models:{"claude-fable-5":{input:10,cachedInput:1,output:50,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $12.50"},"claude-opus-5":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-opus-4-8":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-opus-4-7":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"claude-opus-4-6":{input:5,cachedInput:.5,output:25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"claude-opus-4-5":{input:5,cachedInput:.5,output:25,billingMode:"flat",notes:"\u7F13\u5B58\u5199\u5165 $6.25"},"claude-sonnet-5":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u65E9\u9E1F\u4EF7(\u81F3 2026-08-31);\u6807\u51C6\u4EF7 $3/$15"},"claude-sonnet-4-6":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $3.75"},"claude-sonnet-4-5":{input:3,cachedInput:.3,output:15,billingMode:"flat",notes:"\u2264200K \u6863;>200K \u6309 $6/$22.5 \u8BA1;\u7F13\u5B58\u5199\u5165 $3.75"},"claude-haiku-4-5":{input:1,cachedInput:.1,output:5,billingMode:"flat",notes:"\u7F13\u5B58\u5199\u5165 $1.25"}}},google:{models:{"gemini-3.7-flash":{input:.75,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"2026 \u5E74\u5E95\u524D\u4FC3\u9500\u4EF7;2027 \u8D77 $1.5/$7.5;Go \u7F51\u5173\u6309 $1.5/$7.5"},"gemini-3.6-flash":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.5-flash":{input:1.5,cachedInput:.15,output:9,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.5-flash-lite":{input:.3,cachedInput:.03,output:2.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-3.1-pro-preview":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$18 \u8BA1"},"gemini-3.1-pro":{input:2,cachedInput:.2,output:12,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25",notes:"\u2264200K \u6863;>200K \u6309 $4/$18 \u8BA1"},"gemini-3-flash":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17",notes:"Preview"},"gemini-2.5-pro":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",notes:"\u2264200K \u6863;>200K \u6309 $2.5/$15 \u8BA1"},"gemini-2.5-flash":{input:.3,cachedInput:.03,output:2.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"},"gemini-2.5-flash-lite":{input:.1,cachedInput:.01,output:.4,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing",checkedAt:"2026-08-17"}}},moonshot:{models:{"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u4EBA\u6C11\u5E01\u4EF7 \xA520/\xA5100/\u7F13\u5B58\xA52 \u6BCF\u767E\u4E07;\u6B64\u5904\u4E3A Go \u7F51\u5173\u7F8E\u5143\u4EF7"},"kimi-k2.7-code":{input:.95,cachedInput:.19,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.6":{input:.95,cachedInput:.16,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.5":{input:.6,cachedInput:.1,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-08-05 \u8D77\u5F03\u7528"}}},"z-ai":{models:{"glm-5.3":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01",notes:"\u667A\u8C31\u56FD\u5185\u76F4\u8FDE \xA58/\xA528/\u7F13\u5B58\xA52(\u7EA6 1.11/3.89/0.28 USD,\u76EE\u5F55\u4EF7\u7565\u9AD8\u4E8E\u76F4\u8FDE)"},"glm-5.3-flash":{input:.15,cachedInput:.03,output:.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01",notes:"Ox Alpha \u666E\u60E0\u7248(2026-08-26 \u53D1\u5E03,\u539F\u751F\u591A\u6A21\u6001);Go \u76EE\u5F55\u4E0E Cloudflare \u76EE\u5F55\u540C\u4EF7"},"glm-5.2":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"glm-5.1":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"glm-5":{input:1,cachedInput:.2,output:3.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-05-14 \u8D77\u5F03\u7528"}}},xai:{models:{"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$12 \u8BA1"},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u2264200K \u6863;>200K \u6309 $4/$12 \u8BA1"},"grok-4.3":{input:1.25,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/models/grok-4.3"},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"}}},alibaba:{models:{"qwen3.8-max":{input:2,cachedInput:.25,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $2.50"},"qwen3.7-max":{input:2.5,cachedInput:.5,output:7.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $3.125"},"qwen3.7-plus":{input:.4,cachedInput:.04,output:1.6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u2264256K \u6863;>256K \u6309 $1.2/$4.8 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.50"},"qwen3.6-plus":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u2264256K \u6863;>256K \u6309 $2/$6 \u8BA1;\u7F13\u5B58\u5199\u5165 $0.625"},"qwen3.5-plus":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"\u7F13\u5B58\u5199\u5165 $0.25"},"qwen3-plus":{input:.4,output:1.2,billingMode:"flat",sourceUrl:"https://www.alibabacloud.com/help/en/model-studio/model-pricing"}}},minimax:{models:{"minimax-m3":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"minimax-m2.7":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17"},"minimax-m2.5":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-17",notes:"2026-08-05 \u8D77\u5F03\u7528"}}},tencent:{models:{"hunyuan-a13b":{input:.0694,output:.2778,billingMode:"flat",notes:"\u5B98\u65B9\u4EF7\u4E3A CNY \xA50.5/\xA52 \u6BCF\u767E\u4E07 token,\u6309\u9ED8\u8BA4\u5C55\u793A\u6C47\u7387 7.2 \u6298\u7B97\u4E3A USD \u5165\u8D26"},hy3:{input:.14,cachedInput:.035,output:.58,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"OpenCode Go \u76EE\u5F55\u4EF7;\u5382\u5546\u5F52\u5C5E\u672A\u5B98\u5BA3"}}},xiaomi:{models:{"mimo-v2.6-pro":{input:.435,cachedInput:.0036,output:.87,cny:{cacheHit:.025,cacheMiss:3,output:6},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u6279\u91CF\u63A8\u7406\u6309\u534A\u4EF7"},"mimo-v2.6-flash":{input:.14,cachedInput:.0028,output:.28,cny:{cacheHit:.02,cacheMiss:1,output:2},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u6279\u91CF\u63A8\u7406\u6309\u534A\u4EF7"},"mimo-v2.6-pro-ultraspeed":{input:4.35,cachedInput:.036,output:8.7,cny:{cacheHit:.25,cacheMiss:30,output:60},billingMode:"flat",sourceUrl:"https://mimo.mi.com/docs/zh-CN/price/pay-as-you-go",checkedAt:"2026-09-28",notes:"\u901F\u5EA6\u4F18\u5148\u6863;\u5B98\u65B9\u672A\u63D0\u4F9B\u6279\u91CF\u63A8\u7406\u6863"},"mimo-v2.5":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u6807\u6CE8\u5373\u5C06\u4E0B\u7EBF,\u7531 mimo-v2.6-flash \u63A5\u66FF"},"mimo-v2.5-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17",notes:"\u5B98\u65B9\u6807\u6CE8\u5373\u5C06\u4E0B\u7EBF,\u7531 mimo-v2.6-pro \u63A5\u66FF"}}},upstage:{models:{"solar-pro4":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://www.upstage.ai/pricing/api"},"solar-pro3":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://www.upstage.ai/pricing/api"}}},meta:{models:{"muse-spark-1.2":{input:1.25,cachedInput:.15,output:4.25,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25"}}},meituan:{models:{"longcat-2.0":{input:.3,cachedInput:.006,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25"}}},nvidia:{models:{"nvidia/nemotron-3-ultra-550b-a55b":{unpriced:!0,billingMode:"flat",notes:"Official catalog does not publish token price."}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat"},"mistral-medium-3.5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat"},"mistral-small-4.0":{input:.15,cachedInput:.015,output:.6,billingMode:"flat"}}},"opencode-go":{models:{"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-08-25"},"glm-5.3":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01"},"glm-5.3-flash":{input:.15,cachedInput:.03,output:.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-01"},"glm-5.2":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"glm-5.1":{input:1.4,cachedInput:.26,output:4.4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"gpt-5.6-luna":{input:.2,cachedInput:.02,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.7-code":{input:.95,cachedInput:.19,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"kimi-k2.6":{input:.95,cachedInput:.16,output:4,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"mimo-v2.6-flash":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-28"},"mimo-v2.6-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-09-28"},"mimo-v2.5":{input:.14,cachedInput:.0028,output:.28,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"mimo-v2.5-pro":{input:.435,cachedInput:.003625,output:.87,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"minimax-m3":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"minimax-m2.7":{input:.3,cachedInput:.06,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.8-max":{input:2,cachedInput:.25,output:6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.7-max":{input:2.5,cachedInput:.5,output:7.5,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.7-plus":{input:.4,cachedInput:.04,output:1.6,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"qwen3.6-plus":{input:.5,cachedInput:.05,output:3,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},hy3:{input:.14,cachedInput:.035,output:.58,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-17"},"longcat-2.0":{input:.3,cachedInput:.006,output:1.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25"},"muse-spark-1.2-contributor":{input:.1,cachedInput:.002,output:.2,billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-08-25",notes:"\u4F4E\u4EF7\u6362\u53D6\u63D0\u793A\u8BCD/\u8865\u5168\u7528\u4E8E\u8BAD\u7EC3 Meta \u6A21\u578B;\u9650\u5730\u533A"}}},openrouter:{models:{"meta/muse-spark-1.3-contributor":{input:.1,cachedInput:.002,output:.2,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"google/gemini-3.8-flash":{input:.75,cachedInput:.075,cacheWrite:.041667,output:3.75,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"qwen/qwen3.8-flash":{input:.15,cachedInput:.016,cacheWrite:.2,output:.47,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"},"z-ai/glm-5.3-flash":{input:.09,cachedInput:.018,output:.3,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-09-17"}}}},En=Object.freeze(Object.keys(ue["opencode-go"].models)),Z={...ue};Z.opendesign={models:Mn};for(let[e,t]of Object.entries(dt)){let o=ue[e]?.models??{};Z[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function Pe(e,t=ue){if(!e||typeof e!="object"||(e.prices??={},typeof e.prices!="object"||Array.isArray(e.prices))||(e.prices.providers??={},typeof e.prices.providers!="object"||Array.isArray(e.prices.providers)))return;let o=e.prices.providers;for(let[n,i]of Object.entries(Z)){if(["__proto__","constructor","prototype"].includes(n))continue;let r=t[n]?.models??{},a=Object.hasOwn(o,n)?o[n]?.models:null;if(!a||typeof a!="object"||Array.isArray(a)){Object.hasOwn(o,n)||(o[n]=structuredClone(i));continue}for(let[s,c]of Object.entries(i.models)){if(!Object.hasOwn(a,s)){Object.hasOwn(r,s)||(a[s]=structuredClone(c));continue}let u=new Set(["input","cacheMiss","cachedInput","cacheHit","cacheRead","cacheWrite","output","reasoning","cny","longContext","legacy","billingMode","sourceUrl","checkedAt","notes","offPeak","peak","legacyBase","rateHistory","unpriced"]);if(a[s]&&Object.keys(a[s]).some(h=>!u.has(h)))continue;let d=T(r[s]),l=T(a[s]);d&&l&&JSON.stringify(d)===JSON.stringify(l)&&(a[s]=structuredClone(c))}}}function On(e){let t=Object.fromEntries(Object.keys(Z).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ue[o]?.models,...Ee[o]?.models}}]));Pe(e,t)}function Cn(e){Pe(e,Object.fromEntries(Object.entries(Z).filter(([t])=>t!=="stepfun")))}var fi={models:{"deepseek-v4-flash":{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32},legacyBase:{cacheHit:.0028,cacheMiss:.14,output:.28}},"deepseek-v4-pro":{cacheHit:.022,cacheMiss:.66,output:1.98,offPeak:{cacheHit:.022,cacheMiss:.66,output:1.98},peak:{cacheHit:.044,cacheMiss:1.32,output:3.96},legacyBase:{cacheHit:.003625,cacheMiss:.435,output:.87}},"deepseek-v4-flash-vision-exp":{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32}}},default:{cacheHit:.007,cacheMiss:.22,output:.66,offPeak:{cacheHit:.007,cacheMiss:.22,output:.66},peak:{cacheHit:.014,cacheMiss:.44,output:1.32},legacyBase:{cacheHit:.0028,cacheMiss:.14,output:.28}}},hi={models:{"deepseek-v4-flash":{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9},legacyBase:{cacheHit:.02,cacheMiss:1,output:2}},"deepseek-v4-pro":{cacheHit:.15,cacheMiss:4.5,output:13.5,offPeak:{cacheHit:.15,cacheMiss:4.5,output:13.5},peak:{cacheHit:.3,cacheMiss:9,output:27},legacyBase:{cacheHit:.025,cacheMiss:3,output:6}},"deepseek-v4-flash-vision-exp":{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9}}},default:{cacheHit:.05,cacheMiss:1.5,output:4.5,offPeak:{cacheHit:.05,cacheMiss:1.5,output:4.5},peak:{cacheHit:.1,cacheMiss:3,output:9},legacyBase:{cacheHit:.02,cacheMiss:1,output:2}}};function ft(e,t,o){let n=t==="CNY"?{cacheHit:.02,cacheMiss:1,output:4}:{cacheHit:.003,cacheMiss:.15,output:.6},i=Object.fromEntries(Object.entries(n).map(([r,a])=>[r,a*2]));return{...structuredClone(e),...n,offPeak:n,peak:i,rateHistory:[{before:o,cacheHit:e.cacheHit,cacheMiss:e.cacheMiss,output:e.output,offPeak:{...e.offPeak},peak:{...e.peak}}]}}function _n(e){let t=e==="CNY"?hi:fi,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):ft(i,e,pt)]));return o["deepseek-v4.1-flash"]=ft(t.models["deepseek-v4-flash-vision-exp"],e,pt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:ft(t.default,e,pt)}}var bt=_n("USD"),vn=_n("CNY");function Pn(e,t=Date.now()){if(!e||!Number.isFinite(t)||!Array.isArray(e.rateHistory))return e;let o=null,n=1/0;for(let a of e.rateHistory){let s=Date.parse(a.before);t<s&&s<n&&(o=a,n=s)}if(!o)return e;let{before:i,...r}=o;return{...e,...r}}function F(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=s=>{let c=e[s];return typeof c=="number"&&Number.isFinite(c)&&c>=0?c:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),a=t("cacheWrite");return{cacheHit:n,cacheMiss:o,output:i,...r===void 0?{}:{reasoning:r},...a===void 0?{}:{cacheWrite:a}}}function T(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e.unpriced===!0){let a={unpriced:!0};for(let s of["billingMode","sourceUrl","checkedAt","notes"])typeof e[s]=="string"&&(a[s]=e[s]);return a}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e))return null;let t=F(e),o=a=>typeof a=="number"&&Number.isFinite(a)&&a>=0;if(e.cacheWrite!==void 0&&!o(e.cacheWrite))return null;if(e.longContext!==void 0){let a=e.longContext;if(!a||typeof a!="object"||Array.isArray(a)||!o(a.aboveInputTokens)||a.aboveInputTokens===0||!["cacheMiss","cacheHit","output"].every(s=>o(a[s]))||a.cacheWrite!==void 0&&!o(a.cacheWrite))return null;t.longContext={aboveInputTokens:a.aboveInputTokens,...F(a)}}e.legacy===!0&&(t.legacy=!0),(e.billingMode==="flat"||e.billingMode==="deepseek-peak"||e.billingMode==="utc-peak"||e.billingMode==="batch")&&(t.billingMode=e.billingMode);for(let a of["sourceUrl","checkedAt","notes"])typeof e[a]=="string"&&(t[a]=e[a]);if(e.cny!==void 0){if(!e.cny||typeof e.cny!="object"||Array.isArray(e.cny)||!["cacheHit","cacheMiss","output"].every(a=>o(e.cny[a])))return null;t.cny=F(e.cny)}let n=F(e.offPeak);n!==void 0&&(t.offPeak=n);let i=F(e.peak);i!==void 0&&(t.peak=i);let r=F(e.legacyBase);if(r!==void 0&&(t.legacyBase=r),e.rateHistory!==void 0){if(!Array.isArray(e.rateHistory)||e.rateHistory.length>16)return null;let a=new Set;t.rateHistory=[];for(let s of e.rateHistory){if(!s||typeof s.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(s.before)||!Number.isFinite(Date.parse(s.before))||a.has(Date.parse(s.before))||!["cacheHit","cacheMiss","output"].every(u=>typeof s[u]=="number"&&Number.isFinite(s[u])&&s[u]>=0))return null;a.add(Date.parse(s.before));let c={before:s.before,...F(s)};for(let u of["offPeak","peak"])if(s[u]!==void 0){if(!s[u]||!["cacheHit","cacheMiss","output"].every(d=>typeof s[u][d]=="number"&&Number.isFinite(s[u][d])&&s[u][d]>=0))return null;c[u]=F(s[u])}t.rateHistory.push(c)}t.rateHistory.sort((s,c)=>Date.parse(s.before)-Date.parse(c.before))}return Object.assign(t,xe(e)),lt(t)?t:null}function mi(e,t){let o=t?.models??{};if(typeof e=="string"&&e.length>0){let n=Object.hasOwn(o,e)?o[e]:void 0;if(n!==void 0)return n}return t?.default??{cacheHit:0,cacheMiss:0,output:0}}function yt(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function P(e){return yt(e).replace(/[^\p{L}\p{N}]+/gu,"")}function gi(e,t=!0,o=!0){let n=yt(e);return t&&/[-_./:@](?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(n)?n.slice(0,-5):t&&o&&/[-_./:@]\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(n)?n.slice(0,-7):n.replace(/[-_./:@](?:\d{4}-?\d{2}-?\d{2}|v\d+(?:\.\d+)*|\d+k|latest)$/,"")}function _e(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(c=>typeof c=="string"&&c.length>0):[],a=r.find(c=>c===o);if(a!==void 0)return a;let s=e.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(s))return null;for(;;){let c=P(s);if(c.length===0)return null;let u=r.filter(l=>P(l)===c);if(u.length>0)return u.length===1?u[0]:null;let d=gi(s,n,i);if(d===s.toLowerCase())return null;s=d}}var ht=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...tt]),Ce={openai:/^(?:gpt|o\d|codex)/i,anthropic:/^claude/i,google:/^gemini/i,stepfun:/^step-/i,deepseek:/^deepseek/i,moonshot:/^kimi/i,"z-ai":/^glm/i,xai:/^grok/i,alibaba:/^qwen/i,minimax:/^minimax/i,tencent:/^(?:hunyuan|hy\d)/i,xiaomi:/^mimo/i,upstage:/^solar/i,nvidia:/^nemotron/i,mistral:/^mistral/i,meta:/^(?:muse|llama)/i,meituan:/^longcat/i};function mt(e){return["deepseek-peak","utc-peak"].includes(e?.billingMode)?e.billingMode:"flat"}function ne(e,t,o,n,i){if(typeof e!="string")return null;if(Object.hasOwn(t,e))return e;if(n!=="auto")return null;let r=e.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),a=r.search(/[/:]/);if(a>0){let s=r.slice(0,a).trim().toLowerCase(),c=r.slice(a+1).trim();if(Object.hasOwn(Ce,s)&&(s===o||(o==="opencode-zen"||o==="opencode-go")&&(Ce[s].test(c)||_e(c,Object.keys(s==="deepseek"?i?.models??{}:i?.providers?.[s]?.models??{}),c,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=c;else if(Object.hasOwn(Ce,s))return null}return _e(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function bi(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},a=t,s=e,c=(e===""?"deepseek":e)+":"+t,u=r[c];if(u==="__custom__"){let f=Ne(o?.custom?.[c]);return{entry:f,billingMode:"flat",priced:f!==null,currency:f?.currency??"USD"}}if(u==="__local__")return{entry:null,billingMode:"flat",priced:!1};if(typeof u=="string"&&u.length>0){let f=u.indexOf(":");if(f>0&&u.slice(f+1).length>0?(s=u.slice(0,f).trim().toLowerCase(),a=u.slice(f+1)):a=u,s==="deepseek"&&a==="__default__"){let b=o?.default??{cacheHit:0,cacheMiss:0,output:0},k=T(b);return k===null?{entry:null,billingMode:"flat",priced:!1}:{entry:k,billingMode:"deepseek-peak",priced:k.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(s)){let f=ne(a,o?.providers?.[s]?.models??{},"opencode-go",i,o);f===null?s="opencode-go":a=f}if(tt.includes(s)&&s!=="opendesign"&&ne(a,o?.providers?.[s]?.models??{},s,i,o)===null&&(s="opendesign"),Nn(s,a))return{entry:null,billingMode:"flat",priced:!1};if(s==="openrouter"){let f=o?.providers?.openrouter?.models??{},b=Object.hasOwn(f,a)?T(f[a]):null;return{entry:b,billingMode:"flat",priced:b!==null&&b.unpriced!==!0}}if(s===""||s==="deepseek"||s.includes("deepseek")){let f=o?.models??{},b=ne(a,f,"deepseek",i,o);if(b!=null){let M=f[b],x=T(M);return x===null||x.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:x,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let M=null,x=-1,w=!1,I="flat";for(let[C,R]of Object.entries(o?.providers??{})){if(ht.has(C))continue;let Y=R?.models??{},G=ne(a,Y,C,i,o);if(G===null)continue;let te=T(Y[G]);if(te===null)continue;let D=+(G===a||P(G)===P(a));D>x?(M=te,x=D,w=!1,I=mt(Y[G])):D===x&&(w=!0)}if(w)return{entry:null,billingMode:"flat",priced:!1};if(M!==null)return{entry:M,billingMode:I,priced:M.unpriced!==!0}}let k=mi(a,o),g=T(k);return g===null?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:"deepseek-peak",priced:g.unpriced!==!0}}let l=o?.providers?.[s]?.models??{},h=ne(a,l,s,i,o);if(h===null&&ht.has(s))return{entry:null,billingMode:"flat",priced:!1};if(h===null&&Object.hasOwn(Ce,s))return{entry:null,billingMode:"flat",priced:!1};if(h===null&&i==="auto"){let f=null,b=-1,k=!1,g="flat";for(let[M,x]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(M===s||ht.has(M))continue;let w=x?.models??{},I=ne(a,w,M,i,o);if(I===null)continue;let C=T(w[I]);if(C===null)continue;let R=+(I===a||P(I)===P(a));R>b?(f=C,b=R,k=!1,g=M==="deepseek"?"deepseek-peak":mt(w[I])):R===b&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(f!==null)return{entry:f,billingMode:g,priced:f.unpriced!==!0}}if(h===null)return{entry:null,billingMode:"flat",priced:!1};let A=T(l[h]);return A===null||A.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:A,billingMode:mt(l[h]),priced:!0}}function yi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?_e(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],a=T(r);return a===null||a.unpriced===!0?null:{entry:a,billingMode:"deepseek-peak",priced:!0}}var Ai=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),ki=["lmstudio:","lmstudio/","ollama:","ollama/","jan:","jan/","gpt4all:","gpt4all/","koboldcpp:","koboldcpp/","llamacpp:","llamacpp/","llama-cpp:","llama-cpp/","localai:","localai/","vllm:","vllm/","sglang:","sglang/","tabbyapi:","tabbyapi/","lmdeploy:","oobabooga/","text-generation-webui/","llama-server:","gguf:","local:"];function Nn(e,t){if(typeof e=="string"&&Ai.has(e))return!0;let o=typeof t=="string"?yt(t):"";return ki.some(n=>o.startsWith(n))}function Rn(e,t,o,n){let i=typeof e=="string"?e.trim().toLowerCase():"",r=i.startsWith("llm-")?i.slice(4):i;if(["our-free-model","our-free-model-region"].includes(r)&&n?.overrides?.[r+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let a=wi(r,t,o,n);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"?{...a,entry:{...a.entry,peakSchedule:"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?In.has(typeof t=="string"?t.trim().toLowerCase():""):_e(t,[...In])!==null)?{...a,entry:{...a.entry,peakSchedule:"ollama"}}:a}function wi(e,t,o,n){let i=bi(e,t,o,n);if(i.currency)return i;if(i.priced||e===""||e==="deepseek"||e.includes("deepseek"))return Oe(i,o);let a=(n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{})[e+":"+t];if(typeof a!="string"||a.length===0||a==="__local__"||a.includes(":"))return Oe(i,o);let s=n?.mode==="exact"?"exact":"auto";return Oe(yi(a,o,s)??i,o)}function Oe(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:kn(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(o=>typeof e[o]=="number"&&Number.isFinite(e[o])&&e[o]>=0)||["cacheWrite","reasoning"].some(o=>e[o]!==void 0&&(typeof e[o]!="number"||!Number.isFinite(e[o])||e[o]<0)))return null;let t={...F(e),...xe(e),currency:e.currency,billingMode:"flat"};return lt(t)?t:null}function Mi(e,t,o,n=ve){if(!Array.isArray(o)||o.length===0||di(e,n)!==null||Number.isFinite(t)&&e<t)return!1;let i=new Date(e).getUTCHours();return o.some(r=>{let a=Number(r?.start),s=Number(r?.end);return!Number.isFinite(a)||!Number.isFinite(s)?!1:a<s?i>=a&&i<s:i>=a||i<s})}function Ii(e,t,o){let n=Pn(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(s,c="base")=>ct(s,n,c),r=n.peakSchedule==="ollama";if(r||n.billingMode==="utc-peak"){if(o?.enabled!==!0||!Number.isFinite(t)||r&&t<Date.parse(ci))return i(n);let s=new Date(t),c=s.getUTCDay(),u=s.getUTCHours(),d=c>0&&c<6&&(r?u>=12&&u<18:u>=1&&u<4||u>=6&&u<10);return i((d?n.peak:n.offPeak)??n,(d?n.peak:n.offPeak)?d?"peak":"offPeak":"base")}if(Number.isFinite(t)&&t<Date.parse(pi)){let s=n.legacyBase;return s===void 0?i(n):i(s,"legacyBase")}if(o?.enabled!==!0)return i(n);let a=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(Mi(t,a,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let s=n.peak;return s===void 0?i(n):i(s,"peak")}if(a!==void 0&&t>=a){let s=n.offPeak;return s===void 0?i(n):i(s,"offPeak")}return i(n)}function Tn(e,t,o,n){let i=Ii(t,o,n),r=A=>{let f=Number(A);return Number.isFinite(f)&&f>0?f:0},a=r(e?.input),s=r(e?.output),c=r(e?.cacheRead),u=r(e?.cacheWrite),d=r(e?.reasoning);i.longContext&&a+c+u>i.longContext.aboveInputTokens&&(i=i.longContext);let l=typeof i.reasoning=="number"?i.reasoning:0,h=(a*i.cacheMiss+s*i.output+c*i.cacheHit+u*(i.cacheWrite??i.cacheHit)+d*l)/1e6;return Number.isFinite(h)&&h>0?h:0}function Un(e,t,o){let n=Math.max(0,Number(e)||0);if(t!=="CNY")return n;let i=Number(o);return n/(Number.isFinite(i)&&i>0?i:1)}var Si={opendesign:"opendesign|open[._-]?design",codex:"codex|chatgpt","baidu-coding":"baidu|qianfan|\u767E\u5EA6|\u5343\u5E06","tencent-coding":"tencent|tokenhub|\u817E\u8BAF",anthropic:"anthropic|claude",zai:"z[._-]?ai|zhipu|glm|\u667A\u8C31",minimax:"minimax|\u6D77\u87BA",kimi:"kimi|moonshot|moonshotai|\u6708\u4E4B\u6697\u9762",openrouter:"openrouter",siliconflow:"siliconflow|\u7845\u57FA",commandcode:"commandcode",clinepass:"cline[._-]?pass|clinepass",scnet:"scnet|sugon|\u8D85\u7B97",volcengine:"volcengine|volcano|volc|ark|\u706B\u5C71|\u65B9\u821F",qwen:"qwen|qianwen|\u5343\u95EE|\u901A\u4E49",mimo:"mimo|xiaomi|\u5C0F\u7C73",factory:"factory|droid",go:"opencode(?:[-_\\s]?go)?|zen|go"},xi=Object.entries(Si).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function Dn(e,t){for(let o of[e,t]){let n=String(o??"").normalize("NFKC").replace(/([a-zA-Z0-9\u3400-\u9fff])(?=(?:Coding|Token|Agent|Plan|Subscription))/g,"$1-").replace(/([a-z0-9])((?:coding|token|agent)?plan|subscription)$/i,"$1-$2").toLowerCase();if(!/(?:^|[^a-z0-9])(?:(?:coding|token|agent)[-_\s]*)?plan(?:$|[^a-z0-9])|(?:^|[^a-z0-9])subscription(?:$|[^a-z0-9])|套餐|订阅/.test(n))continue;let i=xi.filter(([,r])=>r.test(n));if(i.length){if(i.length!==1)return null;let r=i[0][0];if(r==="volcengine"&&/agent[-_\s]*plan|智能体.*套餐/.test(n))return"volcengine-agent";if(r==="tencent-coding"){let a=/token[-_\s]*plan|令牌.*套餐/.test(n),s=/coding[-_\s]*plan|编程.*套餐/.test(n);return a===s?null:a?"tencent-token":r}return r}}return null}var J=[...ce,"go","codex","volcengine-agent","tencent-coding","tencent-token","baidu-coding","antigravity","stepfun"],Ei={opendesign:["opendesign","open-design","open-design-api","amr-link.open-design.ai"],go:["go","zen","opencode","opencode-go","opencode-go-plus","dsh-opencode-go"],codex:["codex","openai-codex","dsh-openai-codex","codex-chatgpt"],anthropic:["anthropic","claude-subscription"],zai:["zai","glm-coding-plan"],minimax:["minimax","minimax-code"],kimi:["kimi","kimi-code"],commandcode:["commandcode","command-code"],clinepass:["clinepass","cline-pass"],workbuddy:["workbuddy","workbuddy-subscription","workbuddy-ai","workbuddy-global","xdpool","xdpool-global"],antigravity:["antigravity"],stepfun:["stepfun","step-code"],"volcengine-agent":["volcengine-agent","ark-agent-plan","volcengine-agent-plan"],"tencent-coding":["tencent-coding","tencent-coding-plan","tokenhub-coding-plan"],"tencent-token":["tencent-token","tencent-token-plan","tokenhub-token-plan"],"baidu-coding":["baidu-coding-plan","qianfan-coding-plan"],qwen:bn,scnet:gn,mimo:hn,factory:["factory","droid","factory-a","factory-g","factory-o"]},At={opendesign:"plan",anthropic:"auto",zai:"auto",minimax:"auto",kimi:"auto",openrouter:"api",siliconflow:"api",commandcode:"auto",clinepass:"auto",scnet:"auto",volcengine:"auto",qwen:"auto",mimo:"auto",factory:"auto",go:"auto",codex:"auto",workbuddy:"auto",antigravity:"auto",stepfun:"auto","volcengine-agent":"plan","tencent-coding":"plan","tencent-token":"plan","baidu-coding":"plan"},Hn=400,Ln=2160*36e5,ya=168*36e5;var Oi=840*36e5;function kt(e,t,o){let n=String(e??"").trim().toLowerCase();n.startsWith("llm-")&&(n=n.slice(4));let i=t?.modelPlans?.[`${e}:${o}`]??t?.modelPlans?.[`${n}:${o}`];if(J.includes(i))return i;if(n.length===0)return null;for(let[r,a]of Object.entries(Ei))if(a.includes(n))return r;return J.includes(n)?n:Dn(e,o)}var jn=new WeakMap;function Ci(e){let t=jn.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(P)),n=new Set,i=new Set(En.map(P));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(P(r))&&n.add(P(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},jn.set(e,t)}return t}function wt(e,t,o){if(o===null||typeof o!="object")return!1;let n=String(e??"").trim().toLowerCase();if(n.length>0&&n!=="deepseek"&&!n.includes("deepseek"))return!1;let i=P(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:a}=Ci(o);return!r.has(i)&&a.has(i)}function Bn(e,t,o,n,i){if(nn(e,t))return"api";let r=kt(e,o,t);r===null&&wt(e,t,i)&&(r="go");let a=o?.models;if(a!==null&&typeof a=="object"){let c=a[`${e}:${t}`];if(c==="plan"||c==="api")return c;if(r!==null){let u=a[`${r}:${t}`];if(u==="plan"||u==="api")return u}}let s=o?.providers;for(let c of[e,r]){if(c==null)continue;let u=s?.[c];if(u==="plan"||u==="api")return u}return r===null?"api":n instanceof Set&&n.has(r)?"plan":"api"}function Re(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>J.includes(n)));let t=new Set,o=e?.codingPlans;if(o!==null&&typeof o=="object")for(let n of ce)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function Fn(e){return JSON.stringify([e?.planBilling,[...Re(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function Mt(e,t,o,n,i){let r=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},a=r[t]!==null&&typeof r[t]=="object"&&!Array.isArray(r[t])?r[t]:{},s=Number(o);if(!Number.isFinite(s)||s<=0)return r;let c=Math.floor(s/36e5)*36e5,u=a[c]!==null&&typeof a[c]=="object"?a[c]:{tokens:0,cost:0};return u.tokens+=Math.max(0,Number(n)||0),u.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...a,[c]:u}}}function Wn(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Oi,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},a=!1;for(let[s,c]of Object.entries(i)){if(c===null||typeof c!="object"||Array.isArray(c)){a=!0;continue}let u={};for(let[d,l]of Object.entries(c)){let h=Number(d);if(!Number.isFinite(h)||h<n||h>o+36e5){a=!0;continue}u[h]={tokens:Math.max(0,Number(l?.tokens)||0),cost:Math.max(0,Number(l?.cost)||0)}}Object.keys(u).length>0&&(r[s]=u)}return a||Object.keys(r).length!==Object.keys(i).length?r:i}function It(e){let t={};for(let o of Array.isArray(e)?e:[]){if(o===null||typeof o!="object")continue;let n=String(o.provider??"");n.length!==0&&(t=Mt(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as Ue,readlinkSync as _i,statSync as vi}from"node:fs";import{execFileSync as zn}from"node:child_process";import{hostname as Pi}from"node:os";import{join as Ni}from"node:path";import{performance as Ri}from"node:perf_hooks";var $n=Pi(),De=process.platform==="win32"?Ri.timeOrigin:Date.now()-process.uptime()*1e3,Kn={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},St,xt,Te;function Et(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=Ue(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=Ue("/proc/sys/kernel/random/boot_id","utf8").trim(),a=_i(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!a)return null;let s=e===process.pid?De:null;if(t&&e!==process.pid){Te??=Number(zn("getconf",["CLK_TCK"],Kn).trim());let c=Ue("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(Te)&&Te>0&&c&&(s=(Number(c)+Number(i)/Te)*1e3)}return{platform:"linux",boot:r,namespace:a,start:i,startedAtMs:s}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(De)),unit:"ms",startedAtMs:De};let n=Ni(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=zn(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],Kn).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function Ot(){return St===void 0&&(St=Et(process.pid)),St}function qn(){let e=Ot();return JSON.stringify({version:e?.unit==="ms"?2:1,host:$n,identity:e})}function Yn(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=Ue(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==$n)return!1;let s=Ot();if(i?.identity?.platform==="linux"&&s?.platform==="linux"&&i.identity.boot===s.boot&&i.identity.namespace!==s.namespace)return!1}try{process.kill(t,0)}catch(s){return s.code==="ESRCH"}let r=(i?.version===1||i?.version===2)&&i.identity;if(n!==""&&(!r||typeof r.start!="string"||!/^\d+$/.test(r.start))||process.platform==="win32"&&n!==""&&!(i.version===1&&r.platform==="win32"&&r.unit===void 0||i.version===2&&r.platform==="win32"&&r.unit==="ms")||process.platform==="linux"&&n!==""&&i.version!==1)return!1;t!==process.pid&&!o.has(t)&&o.set(t,Et(t,n===""));let a=t===process.pid?Ot():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(xt===void 0&&(xt=Et(t,!1,!0)),a=xt),n===""){let s=t===process.pid?a?.startedAtMs??De:a?.startedAtMs;return Number.isFinite(s)&&vi(e).mtimeMs<s-2e3}if(!r||!a||r.platform!==a.platform||typeof r.start!="string"||!/^\d+$/.test(r.start))return!1;if(a.platform==="linux")return typeof r.boot!="string"||typeof r.namespace!="string"?!1:r.boot!==a.boot||r.start!==a.start;if(r.unit==="ms"||a.unit==="ms"){let s=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),c=s(r),u=s(a);return!Number.isSafeInteger(c)||c<=0||!Number.isSafeInteger(u)||u<=0?!1:c<u-2e3}return r.start!==a.start}import{createHash as Ui,randomUUID as vt}from"node:crypto";import{createHash as Ti}from"node:crypto";var U=new WeakMap,Gn=/^[a-f\d]{64}$/,de=e=>e&&typeof e=="object"&&!Array.isArray(e),Qn=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),Ct=e=>Ti("sha256").update(JSON.stringify(e)).digest("hex"),Vn=24;function He(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))He(t);return Object.freeze(e)}function Zn(e,t,o=[],n=[]){if(e===t)return n;if(de(e)&&de(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))Qn(i)&&(!Object.hasOwn(t,i)||t[i]===void 0?Object.hasOwn(e,i)&&e[i]!==void 0&&n.push([[...o,i]]):Object.hasOwn(e,i)?Zn(e[i],t[i],[...o,i],n):n.push([[...o,i],t[i]]));else JSON.stringify(e)!==JSON.stringify(t)&&n.push([o,t]);return n}function Jn(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=Jn(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function je(e,t,o,n){let i=o.get(n);if(i&&i.depth<Vn){let r={base:n,patch:Zn(t[n],e)};if(JSON.stringify(r).length<JSON.stringify(e).length)return{record:He(r),depth:i.depth+1,signature:Ct(r),baseValue:t[n]}}return{record:e,depth:0,signature:Ct(e)}}function Le(e,t,o,n){let i=U.get(e)??new Map;U.set(e,i),Object.hasOwn(e,t)||(e[t]=He(o)),i.has(t)||i.set(t,je(e[t],e,i,n))}function Xn(e={}){let t={...e};return U.set(t,new Map(U.get(e)??[])),t}function eo(e,t){let o={...t,...e};return U.set(o,new Map([...U.get(t)??[],...U.get(e)??[]])),o}function to(e){let t=U.get(e)??new Map;U.set(e,t);let o;for(let[n,i]of Object.entries(e)){let r=t.get(n);(!r||r.record.base&&r.baseValue!==e[r.record.base])&&t.set(n,je(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function no(e,t,o){let n={},i=new Map,r=U.get(o),a=new Set,s=c=>{if(i.has(c))return!0;if(!Gn.test(c)||a.has(c)||a.size>Vn||!de(e[c]))return!1;a.add(c);let u=e[c],d;if(!de(u.prices)){if(!Gn.test(u.base)||!Array.isArray(u.patch)||u.patch.length>1e5||u.patch.some(f=>!Array.isArray(f)||![1,2].includes(f.length)||!Array.isArray(f[0])||f[0].length>16||!f[0].every(Qn))||!s(u.base))return a.delete(c),!1;d=i.get(u.base)}let l=Ct(u),h=d?n[u.base]:void 0,A=r?.get(c);if(A&&o[c]&&(A.sourceSignature===l&&A.sourceBase===h||A.signature===l&&A.baseValue===h))n[c]=o[c],i.set(c,A);else{let f=d?n[u.base]:u;if(d)for(let k of u.patch)f=Jn(f,k[0],k);if(!de(f?.prices))return a.delete(c),!1;n[c]=He(t(f));let b=je(n[c],n,i,d?u.base:void 0);i.set(c,{...b,sourceSignature:l,sourceBase:h})}return a.delete(c),!0};for(let c of Object.keys(e))s(c);if(U.set(n,i),![...i.values()].some(c=>c.depth>0)){let c;for(let u of Object.keys(n)){let{sourceSignature:d,sourceBase:l}=i.get(u);i.set(u,{...je(n[u],n,i,c),sourceSignature:d,sourceBase:l}),c=u}}return n}var ro=new WeakMap,Fe=new WeakMap,pe=new WeakSet,Di=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],Nt=e=>Ui("sha256").update(JSON.stringify(e)).digest("hex"),oe=e=>!["__proto__","constructor","prototype"].includes(e),Be=e=>e&&typeof e=="object"&&!Array.isArray(e),ji=new Set(["cacheHit","cacheMiss","cacheWrite","input","cachedInput","output","reasoning","billingMode","unpriced","legacy","currency","aboveInputTokens","before","offPeak","peak","longContext","legacyBase","rateHistory","cny","multiplier","separateMultipliers","multipliers"]),fe=e=>Array.isArray(e)?e.map(fe):Be(e)?Object.fromEntries(Object.entries(e).filter(([t])=>ji.has(t)||at.test(t)).map(([t,o])=>[t,fe(o)])):e,_t=e=>Object.fromEntries(Object.entries(e??{}).filter(([t])=>oe(t)).map(([t,o])=>[t,fe(o)])),oo=["at","before","after","days","sessions","skipped"],Pt=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function so(e){let t=Fe.get(e);if(t)return t;let o=new Map;for(let n of Object.values(e.revisions)){let i=JSON.stringify([n.sessionId,n.date,n.model??""]),r=o.get(i);(!r||Pt(n,r)>=0)&&o.set(i,n)}return t={changes:Object.values(e.changes).sort(Pt),revisions:o,fingerprint:Nt([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((n,i)=>n.at-i.at||(n.sequence??0)-(i.sequence??0))},Fe.set(e,t),t}function Rt(e,t=!1){let o=structuredClone(Object.fromEntries(Di.filter(i=>i!=="prices"&&e?.[i]!==void 0).map(i=>[i,e[i]]))),n=e?.prices??{};return o.prices={...n.currency?{currency:n.currency}:{},ollamaPeak:!t||n.ollamaPeak===!0,ollamaTaggedPeak:!t||n.ollamaTaggedPeak===!0,snapshotTags:!t||n.snapshotTags===!0,shortSnapshotTags:!t||n.shortSnapshotTags===!0,volcenginePeak:!t||n.volcenginePeak===!0,default:fe(n.default),models:_t(n.models),...n.custom?{custom:_t(n.custom)}:{},providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([i])=>oe(i)).map(([i,r])=>[i,{...r.currency?{currency:r.currency}:{},...r.default?{default:fe(r.default)}:{},models:_t(r.models)}]))},o}function io(e,t=!1){let o=Rt(e,t),n=Nt(o),i={};Le(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:_(e)}}};return pe.add(r),r}function he(e,t,o,n=!1){if(pe.has(e))return e;if(!Be(e?.versions)||!Be(e?.changes))return io(t,n);let i=no(e.versions,d=>Rt(d,!0),o?.versions),r=Object.fromEntries(Object.entries(e.changes).filter(([d,l])=>oe(d)&&Number.isFinite(l?.at)&&l.at>=0&&i[l.version]));if(!Object.values(r).some(d=>d.at===0)){let d=Object.values(i),l={...t?.prices};for(let A of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])d.length&&(l[A]=d.every(f=>f.prices?.[A]===!0));let h=io({...t,prices:l},n);for(let[A,f]of Object.entries(h.versions))Le(i,A,f);r[vt()]=h.changes.initial}let a=Object.fromEntries(Object.entries(e.revisions??{}).filter(([d,l])=>oe(d)&&typeof l?.sessionId=="string"&&(l.model===void 0||typeof l.model=="string"&&l.model.includes(":")&&l.model.length<=2048)&&/^\d{4}-\d{2}-\d{2}$/.test(l.date)&&Number.isFinite(l.at)&&i[l.version])),s=Object.fromEntries(Object.entries(Be(e.runs)?e.runs:{}).filter(([d,l])=>oe(d)&&oo.every(h=>Number.isFinite(l?.[h])&&l[h]>=0)).map(([d,l])=>[d,{...Object.fromEntries([...oo,...["beforeCny","afterCny","beforeEur","afterEur"].filter(h=>Number.isFinite(l[h])&&l[h]>=0)].map(h=>[h,l[h]])),...typeof l.model=="string"?{model:l.model}:{}}])),c=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([d,l])=>oe(d)&&Number.isFinite(l?.at)&&l.at>=0&&["CNY","EUR"].every(h=>Number.isFinite(l.rates?.[h])&&l.rates[h]>0)));if(!Object.keys(c).length)for(let[d,l]of Object.entries(r))c[d]={at:l.at,sequence:l.sequence??0,rates:_({...i[l.version],currency:t.currency})};let u={versions:i,changes:r,revisions:a,runs:s,fxChanges:c};return pe.add(u),u}function We(e,t,o=Date.now()){let n=Rt(t),i=Nt(n),r=so(e),a=r.changes.at(-1),s=_(t),c=r.fx.at(-1),u=JSON.stringify(c?.rates)!==JSON.stringify(s);u&&(e.fxChanges??={},e.fxChanges[vt()]={at:Math.max(o,c?.at??0),sequence:(c?.sequence??0)+1,rates:s},Fe.delete(e));let d=l=>{let{exchangeRate:h,...A}=l??{};return A};return a?.version===i||JSON.stringify(d(e.versions[a?.version]))===JSON.stringify(d(n))?u:(Le(e.versions,i,n,a?.version),e.changes[vt()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,version:i},Fe.delete(e),!0)}function ao(e,t){return e&&t&&ro.set(e,t),e}function Tt(e,t,o="",n=""){if(e?._repriceFxConfig){let I=Tt(e._repriceFxConfig,t,o,n),C=_(I);return{...e,fxRates:C,exchangeRate:C[e.currency]??e.exchangeRate}}let i=ro.get(e);if(!i||!Number.isFinite(t))return e;let r=so(i),a=new Date(t),s=Number.isFinite(t)?`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`:"",c=0,u=r.changes.length;for(;c<u;){let I=c+u>>>1;r.changes[I].at<=t?c=I+1:u=I}let d=r.changes[c-1],l=I=>I&&t<=I.at?I:null,h=l(r.revisions.get(JSON.stringify([o,s,""]))),A=n?l(r.revisions.get(JSON.stringify([o,s,n]))):null,f=h&&A?Pt(h,A)>0?h:A:h??A,b=(f??d)?.version,k=b&&i.versions[b]?{...e,...i.versions[b]}:e,g=0,M=r.fx.length;for(;g<M;){let I=g+M>>>1;r.fx[I].at<=t?g=I+1:M=I}let x=r.fx[g-1]?.rates,w=f?.preserveFx?h?.fxRates??x??_(i.versions[d?.version]??e):f?f.fxRates??_(k):x??_(k);return{...k,fxRates:w,exchangeRate:w[k.currency]??k.exchangeRate}}function co(e,t){if(!e)return t;if(!t)return e;let o={...t.revisions};for(let[i,r]of Object.entries(e.revisions??{}))(!o[i]||r.at>=o[i].at)&&(o[i]=r);let n={versions:eo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return pe.add(n),n}function lo(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Xn(t)};return pe.add(n),n}function uo(e){return e&&{...e,format:2,versions:to(e.versions)}}var $=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...v],q=e=>!["__proto__","constructor","prototype"].includes(e),O=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ie=e=>e===void 0?void 0:structuredClone(e);function jt(e,t){if(O(e)){if(!O(t)){for(let o of v)delete e[o];return}for(let o of v)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))jt(n,t.byProviderModel?.[o]);if(Array.isArray(e.sessions)){let o=new Map((Array.isArray(t.sessions)?t.sessions:[]).filter(n=>O(n)&&typeof n.id=="string").map(n=>[n.id,n]));for(let n of e.sessions)O(n)&&o.has(n.id)&&jt(n,o.get(n.id))}}}function $i(e,t){if(!O(e)||!O(t))return e;for(let[o,n]of Object.entries(e))O(n)&&jt(n,t[o]);return e}function Ht(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,i)=>Ht(n,t[i]));if(!O(e)||!O(t))return!1;let o=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of o)if(!v.includes(n)&&!Ht(e[n],t[n]))return!1;return!0}function Lt(e,t,o){if(!O(e))return e;for(let n of v){let i=j(t?.[n],o?.[n],e[n],!0);i===void 0?delete e[n]:e[n]=i}for(let[n,i]of Object.entries(e.byProviderModel??{}))Lt(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=a=>new Map((Array.isArray(a)?a:[]).filter(s=>O(s)&&typeof s.id=="string").map(s=>[s.id,s])),i=n(t?.sessions),r=n(o?.sessions);for(let a of e.sessions)O(a)&&typeof a.id=="string"&&Lt(a,i.get(a.id),r.get(a.id))}return e}function ge(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:lo(t)}:{}}}var qi=new Int32Array(new SharedArrayBuffer(4)),go=e=>typeof e=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}:[a-f\d]{64}$/i.test(e),X=e=>Object.fromEntries(Object.entries(O(e)?e:{}).filter(([t,o])=>go(t)&&Number.isSafeInteger(o)&&o>=0)),H=e=>[...new Set((Array.isArray(e)?e:[]).filter(t=>typeof t=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i.test(t)))].slice(-128);function be(e,t,o=5e3,n=mo()){po(Ki(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,a=qn(),s=new Map,c=Date.now()+o;for(;;)try{po(i);try{ho(me(i,r),a,{flag:"wx"})}catch(u){try{Ke(me(i,r))}catch{}throw ze(i),u}break}catch(u){if(!["EEXIST","EPERM"].includes(u.code))throw u;try{let d=Hi(i),l=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(l){if(Yn(me(i,d[0]),Number(l[1]),s)){Ke(me(i,d[0])),ze(i);continue}}else if(d.length===0&&Date.now()-Fi(i).mtimeMs>3e4){ze(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=c)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait(qi,0,0,10)}try{return t()}finally{Ke(me(i,r)),ze(i)}}function bo(e){let t;try{t=Li(e,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!O(o)||o.version!==1)throw new Error("Unsupported ledger format");return o}function $e(e,t,o=!1){let n=`${e}.${process.pid}-${mo()}.tmp`;try{if(o)try{Wi(e,`${e}.pricing-history-v1.bak`,zi.COPYFILE_EXCL)}catch(i){if(!["EEXIST","ENOENT"].includes(i.code))throw i}ho(n,JSON.stringify({...t,pricingHistory:uo(t.pricingHistory)}),{encoding:"utf8",flag:"wx"}),Bi(n,e)}finally{try{Ke(n)}catch(i){if(i.code!=="ENOENT")throw i}}}var Ut=()=>Object.fromEntries($.map(e=>[e,0]));function fo(e,t){for(let o of $)e[o]=(Number(e[o])||0)+(t[o]??0)}function re(e,t){if(t.meter){let{source:d,seq:l}=t.meter;if(!go(d)||!Number.isSafeInteger(l)||l<1)throw Error("Invalid metered call identity");if((e.usageCursors?.[d]??0)>=l)return!1;if(e.usageCursors??={},e.usageCursors[d]=l,t.skip)return!0}let{date:o,sessionId:n,atMs:i,providerKey:r,values:a,planId:s}=t;O(e.days[o])||(e.days[o]={date:o,...Ut(),byProviderModel:{},sessions:[]});let c=e.days[o];Array.isArray(c.sessions)||(c.sessions=[]);let u=[c];if(typeof n=="string"&&n.length>0){let d=c.sessions.find(l=>l.id===n);d||(d={id:n,at:i,...Ut(),byProviderModel:{}},c.sessions.push(d)),u.push(d)}for(let d of u){fo(d,a),d.byProviderModel??={};let l=d.byProviderModel[r]??=Ut();fo(l,a)}return s!==null&&(e.planHourBuckets=Mt(e.planHourBuckets,s,i,Xe(a),a.cost)),!0}function j(e,t,o,n=!1){if(N(t,e))return ie(o);if(N(o,e)||N(t,o))return ie(t);if(O(t)&&O(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!q(r))continue;let a=j(e?.[r],t[r],o[r],n&&(O(t[r])||$.includes(r)||r==="tokens"));a!==void 0&&(i[r]=a)}return i}return n&&typeof t=="number"&&typeof o=="number"?Math.max(0,o+t-(Number(e)||0)):ie(t)}var Dt=e=>Object.fromEntries((e?.sessions??[]).filter(t=>q(t.id)).map(t=>[t.id,t]));function Yi(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!q(i))continue;let r=e[i],a=t[i],s=o[i];if(Ht(r,a)){s!==void 0&&(n[i]=Lt(ie(s),r,a));continue}if(!a||!s){a&&(n[i]=ie(a));continue}if(N(a,s)){n[i]=ie(s);continue}let c=j(r,a,s,!0),u=Dt(r),d=Dt(a),l=Dt(s),h=j(u,d,l,!0),A=(f,b,k)=>Object.fromEntries($.map(g=>[g,(k?.[g]??0)+(b?.[g]??0)-(f?.[g]??0)]));Object.assign(c,A(r,a,s)),c.byProviderModel={};for(let f of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(a.byProviderModel??{}),...Object.keys(s.byProviderModel??{})]))q(f)&&(c.byProviderModel[f]=A(r?.byProviderModel?.[f],a.byProviderModel?.[f],s.byProviderModel?.[f]));for(let f of Object.keys(d))if(!(!l[f]||N(u[f],d[f])||N(u[f],l[f]))){for(let b of $)c[b]-=(d[f][b]??0)-(u[f]?.[b]??0)-((h[f]?.[b]??0)-(l[f][b]??0));for(let[b,k]of Object.entries(d[f].byProviderModel??{}))if(!(!q(b)||!c.byProviderModel[b]))for(let g of $)c.byProviderModel[b][g]-=(k[g]??0)-(u[f]?.byProviderModel?.[b]?.[g]??0)-((h[f]?.byProviderModel?.[b]?.[g]??0)-(l[f].byProviderModel?.[b]?.[g]??0))}for(let f of[c,...Object.values(c.byProviderModel)])for(let b of $)f[b]=Math.max(0,f[b]);c.sessions=Object.values(h).sort((f,b)=>(f.at??0)-(b.at??0)),n[i]=c}return n}function Gi(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(q(r)){i[r]={};for(let a of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!q(a))continue;let s=u=>Object.fromEntries((Array.isArray(u)?u:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),c=j(s(e[r]?.[a]),s(t[r]?.[a]),s(o[r]?.[a]));i[r][a]=Object.values(c).filter(u=>u.t>=n-Ln).sort((u,d)=>u.t-d.t).slice(-Hn)}}return i}function se(e,t,o,n,i=Date.now(),r=[],a={}){let s=a.ownLocal===!0,c=o!==void 0&&o===e,u=ge(e),d=c?u:ge(o??e),l=s?t:ge(t);$i(u.days,d.days);let h=!N(l.historyReset,u.historyReset),A=!N(d.historyReset,u.historyReset),f=h?l.historyReset:d.historyReset;if(h||A)for(let w of[u,...h?[d]:[l]])w.days={},w.planSamples={},w.planHourBuckets={},w.balanceRef=null;for(let w of n)A&&!h&&w.recordedAt<=(f?.at??0)||(re(u,w),d!==u&&re(d,w),A&&!h&&re(l,w));let b={version:1,writeReceipts:H([...d.writeReceipts??[],...l.writeReceipts??[]]),config:j(u.config,l.config,d.config),days:Yi(u.days,l.days,d.days),balanceRef:N(u.balanceRef,l.balanceRef)?d.balanceRef:N(u.balanceRef,d.balanceRef)?l.balanceRef:l.balanceRef==null||d.balanceRef==null?null:(d.balanceRef?.at??0)>(l.balanceRef?.at??0)?d.balanceRef:l.balanceRef,migrations:[...new Set([...d.migrations??[],...l.migrations??[]])],planSamples:Gi(u.planSamples,l.planSamples,d.planSamples,i),planHourBuckets:Wn(j(u.planHourBuckets,l.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:j(u.openrouterPriceHashes,l.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:co(l.pricingHistory,d.pricingHistory),historyReset:f??null},k=X(l.usageCursors);for(let[w,I]of Object.entries(X(d.usageCursors)))k[w]=Math.max(k[w]??0,I);Object.keys(k).length&&(b.usageCursors=k);let g=j(u.providerPriceHashes,l.providerPriceHashes,d.providerPriceHashes);g&&Object.keys(g).length&&(b.providerPriceHashes=g);let M=Object.keys(b.days).sort(),x=Math.max(7,Math.min(3650,Number(b.config.historyDays)||180));for(;M.length>x;)delete b.days[M.shift()];return Q(b.days).includes(b.balanceRef?.date)&&(b.balanceRef=null),Qi(b,r),b}function Qi(e,t){let o=(n,i)=>$.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(Fn(e.config)!==n.fingerprint||!N(e.historyReset??null,n.historyReset))continue;let i=e.days?.[n.date],r=n.expected;if(!(!i||!o(i,r)||[...new Set([...Object.keys(i.byProviderModel??{}),...Object.keys(r.byProviderModel??{})])].some(s=>!o(i.byProviderModel?.[s],r.byProviderModel?.[s]))))for(let s of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!q(s))continue;let c=e.planHourBuckets?.[s]??{},u=Object.fromEntries(Object.entries(c).filter(([l])=>+l>=n.start&&+l<n.end)),d=n.buckets[s]??{};N(u,d)||(e.planHourBuckets[s]={...Object.fromEntries(Object.entries(c).filter(([l])=>+l<n.start||+l>=n.end)),...d},e.planSamples&&delete e.planSamples[s])}}}function yo(e,t,o){return j(e,t,o)}import{join as wo}from"node:path";var Mo=1,Oo=180;function ye(e){try{let t=Zi(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Bt=["antigravity","claude","codex","kimi","xai","workbuddy"],Ji=["sidebar","settings","both","off"],Xi=/^[a-z0-9][a-z0-9_-]{0,47}$/;function er(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function Io(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function tr(e){if(typeof e!="string")return!1;let t=e.trim().toLowerCase();if(t.length===0||t!==e.trim()||/[\s/?#@\\]/.test(t))return!1;if(t.startsWith("[")){let r=t.indexOf("]");if(r<0)return!1;let a=t.slice(1,r),s=t.slice(r+1);return!a.includes(":")||!/^[0-9a-f:.]+$/.test(a)?!1:s===""||s.startsWith(":")&&Io(s.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!Io(o[2]))return!1;let n=o[1],i=n.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);return i!==null?i.slice(1).every(r=>Number(r)>=0&&Number(r)<=255):/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))*$/.test(n)}function nr(e,t={}){let o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},n=typeof o.id=="string"?o.id.trim():typeof t.id=="string"?t.id:"",i=Array.isArray(o.includeProviders)?[...new Set(o.includeProviders.filter(s=>typeof s=="string").map(s=>er(s)).filter(s=>Bt.includes(s)))]:Bt.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(s=>tr(s)).map(s=>s.trim().toLowerCase()))].slice(0,16):[],a=Number(o.refreshMinutes);return{id:n,type:typeof o.type=="string"?o.type:"cliproxyapi",label:typeof o.label=="string"?o.label.slice(0,80):typeof t.label=="string"?t.label:n,baseURL:typeof o.baseURL=="string"?o.baseURL.trim().replace(/\/+$/,""):"",enabled:o.enabled!==!1,display:Ji.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(a)?Math.min(1440,Math.max(1,a)):15,includeProviders:i.length>0?i:Bt.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function or(e){try{let t=new URL(e);return["http:","https:"].includes(t.protocol)&&!t.username&&!t.password&&!t.search&&!t.hash&&t.pathname==="/"}catch{return!1}}function Kt(){return{locale:"auto",position:"dock",sidebar:!0,currency:"CNY",symbol:"\xA5",decimals:4,exchangeRateAuto:!0,fxRates:{USD:1,CNY:7.2,EUR:.92},exchangeRateCheckedAt:0,exchangeRateDate:"",exchangeRate:7.2,pricingCurrency:"USD",peakEnabled:!0,peakEffectiveAt:Sn,peakWindows:xn.map(e=>({...e})),peakHolidays:[...ve],peakNotice:!0,peakAlertEnabled:!0,peakAlertAhead:2,peakAlertTarget:"both",peakAlertPosition:"corner",peakAlertWebNotify:!1,showSessionId:!1,sessionListCosts:!1,sessionListCostPeriod:"total",hideOfficialBalance:!1,hideBudget:!1,hideTodayCost:!1,modelStatistics:{},hideSessionCostHeader:!1,hideSessionCostDock:!1,hideTurnCost:!1,sessionCostCompact:!1,followSkinTransparency:!1,contextCostsEnabled:!1,contextCostsPromptSeen:!1,statisticsBasis:"auto",sidebarTodayMetric:"cost",sidebarTodayBalanceInline:!1,sidebarOrder:[],showTotalWithPlan:!1,includeSubagentCost:!1,codexQuotaEnabled:!1,codexQuotaSidebar:!0,codexQuotaStrip:!0,codexQuotaSource:"auto",codexCompatPromptDismissed:!1,codexCompatHistoryAppliedAt:0,sidebarSimple:!1,sidebarSimplePromptSeen:!1,sidebarModels:{enabled:!1,period:"today",topN:5,summary:"total",position:"last",defaultOpen:!1,remember:!0,tokens:!1,shares:!0,refreshSeconds:60,dock:!1},sidebarSummaryPromptSeen:!1,billionContextNoticeEnabled:!0,billionContextNoticesSeen:[],billingStorageRetentionDays:7,sidebarStyle:"standard",legacyAutoImportedAt:0,peakStyle:"compact",peakTimeDisplay:"both",peakProgressPromptSeen:!1,priceMatch:"auto",priceMatchDismissed:[],priceOverrides:{},priceTableDisplay:{},prices:{models:Object.fromEntries(Object.entries(bt.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(bt.default),providers:Object.fromEntries(Object.entries(Z).map(([e,t])=>[e,{models:Object.fromEntries(Object.entries(t.models).map(([o,n])=>[o,structuredClone(n)]))}]))},budget:{enabled:!1,amount:100,period:"month",customStart:null,customEnd:null,detail:!0},codingPlans:{opendesign:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",workspaceId:""},factory:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",orgId:"",factoryPool:"standard"},anthropic:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},zai:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},minimax:{enabled:!1,display:"both",refreshMinutes:15,apiKey:"",baseUrl:""},kimi:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},openrouter:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},siliconflow:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},commandcode:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},clinepass:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:""},scnet:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",planCredits:24e4,planStart:""},qwen:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",quotaSource:"local",planCredits:5e5,planStart:"",rates:{}},volcengine:{enabled:!1,display:"settings",refreshMinutes:15,apiKey:"",accessKeyId:"",secretAccessKey:""}},balance:{display:"both",refreshMinutes:5,showProgressBar:!1,showSource:!1,budgetCap:null,reconcile:!0,clickHintSeen:!1},goQuota:{enabled:!0,display:"both",refreshMinutes:15,apiKey:"",main:"rolling",detail:!0},customBalance:{enabled:!1,label:"",labelEn:"",display:"both",unit:"USD",convertToDisplayCurrency:!1,refreshMinutes:15,request:{url:"",method:"GET",headers:{}},extract:{remaining:{op:"subtract",paths:["info.max_budget","info.spend"]},maxBudget:"info.max_budget",spend:"info.spend",unit:"USD"}},customBalances:[],gatewayQuotas:{sources:[]},corner:{enabled:!1,goRolling:!0,goWeekly:!0,goMonthly:!0,budget:!0},quotaStrip:{enabled:!1,budget:!0,go:!0,plans:!0,promptSeen:!1},barDirections:{balance:"remaining",budget:"used",go:"used",plan:"used"},usage:{position:"cost"},planBilling:{providers:{...At},models:{},modelPlans:{}},historyDays:Oo,fetchedAt:null,priceSource:"bundled"}}var fc=Object.keys(Kt());function Ft(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Wt(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function ir(e){if(e==null||typeof e!="object")return 0;let t=e.byProviderModel;if(t===null||typeof t!="object"||Object.keys(t).length===0)return Number(e.cost)||0;let o=0;for(let[n,i]of Object.entries(t)){let r=n.indexOf(":"),a=r>=0?n.slice(0,r):n;a.startsWith("llm-")&&(a=a.slice(4)),/^deepseek(?:-official|-account)?$/.test(a)&&(o+=Number(i?.cost)||0)}return o}function rr(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function qe(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=rr(e[o]);let t=Number(e.apiCost);return e.apiCost=Number.isFinite(t)&&t>=0?Math.min(t,Number(e.cost)||0):Number(e.cost)||0,e}function So(e){for(let t of Object.values(e))if(qe(t)!==null){t.byProviderModel=t.byProviderModel!==null&&typeof t.byProviderModel=="object"&&!Array.isArray(t.byProviderModel)?t.byProviderModel:{};for(let[o,n]of Object.entries(t.byProviderModel))qe(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>qe(o)!==null);for(let o of t.sessions){o.id=typeof o.id=="string"?o.id:"",(typeof o.title!="string"||o.title.length===0)&&delete o.title,(!Number.isFinite(Number(o.at))||Number(o.at)<=0)&&delete o.at,o.byProviderModel=o.byProviderModel!==null&&typeof o.byProviderModel=="object"&&!Array.isArray(o.byProviderModel)?o.byProviderModel:{};for(let[n,i]of Object.entries(o.byProviderModel))qe(i)===null&&delete o.byProviderModel[n]}}return e}function ke(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return t===void 0?e:t;let o={...e};for(let[n,i]of Object.entries(t)){if(n==="__proto__"||n==="constructor"||n==="prototype")continue;let r=o[n];o[n]=r!==null&&typeof r=="object"&&!Array.isArray(r)&&i!==null&&typeof i=="object"&&!Array.isArray(i)?ke(r,i):i}return o}function Ae(e){let t=Kt(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(vn),currency:"CNY"});let n=ke(t,o);o.prices?.custom!==void 0&&(n.prices.custom=Object.fromEntries(Object.entries(o.prices.custom&&typeof o.prices.custom=="object"&&!Array.isArray(o.prices.custom)?o.prices.custom:{}).filter(([p,m])=>p.includes(":")&&p.length<=512&&Ne(m)!==null).map(([p,m])=>[p,Ne(m)])));for(let[p,m]of Object.entries(o.prices?.providers??{}))!m?.models||typeof m.models!="object"||Array.isArray(m.models)||Object.hasOwn(n.prices?.providers??{},p)&&(n.prices.providers[p].models=ke({},m.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=ke({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:p,cacheMiss:m,output:y}=t.prices.default;n.prices.default=ke({cacheHit:p,cacheMiss:m,output:y},r)}let a=p=>typeof p=="number"&&Number.isFinite(p),s=(p,m,y)=>typeof p=="string"&&m.includes(p)?p:y;for(let[p,m]of Object.entries(t)){let y=n[p],E=typeof m;E==="boolean"&&typeof y!="boolean"||E==="number"&&!a(y)||E==="string"&&typeof y!="string"?n[p]=m:E==="object"&&m!==null&&y!==null&&typeof y=="object"&&p==="gatewayQuotas"&&Array.isArray(y)||E==="object"&&m!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(m))&&(n[p]=m)}n.locale=s(n.locale,["auto","zh","en"],"auto"),n.position=s(n.position,["dock","header","off"],"dock"),n.peakStyle=s(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=s(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=s(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=s(n.pricingCurrency,["USD","CNY"],"USD"),n.prices!==null&&typeof n.prices=="object"&&(delete n.prices.ollamaPeak,delete n.prices.ollamaTaggedPeak,delete n.prices.snapshotTags,delete n.prices.shortSnapshotTags,delete n.prices.volcenginePeak),n.prices!==null&&typeof n.prices=="object"&&!Array.isArray(n.prices)&&n.prices.currency!==void 0&&(n.prices.currency=s(n.prices.currency,["USD","CNY"],"USD")),n.decimals=Math.max(0,Math.min(10,Math.floor(Number(n.decimals)||0))),n.historyDays=Math.max(7,Math.min(3650,Math.floor(Number(n.historyDays)||180))),n.showSessionId=n.showSessionId===!0,n.sessionListCosts=n.sessionListCosts===!0,n.sessionListCostPeriod=s(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=en(n.modelStatistics);for(let p of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline"])n[p]=n[p]===!0;n.sessionCostCompact=n.sessionCostCompact===!0,n.contextCostsEnabled=n.contextCostsEnabled===!0,n.contextCostsPromptSeen=n.contextCostsPromptSeen===!0,n.sidebarTodayMetric=s(n.sidebarTodayMetric,["cost","tokens","both"],"cost"),n.sidebarOrder=Array.isArray(n.sidebarOrder)?[...new Set(n.sidebarOrder.filter(p=>typeof p=="string"&&/^(balance|customBalance|today|peak|models|go|budget|codex|(plan|gateway):[A-Za-z0-9_-]{1,100})$/.test(p)))].slice(0,64):[],n.statisticsBasis=["api","plan","total"].includes(n.statisticsBasis)?n.statisticsBasis:"auto",n.showTotalWithPlan=n.showTotalWithPlan===!0,n.includeSubagentCost=n.includeSubagentCost===!0,n.codexQuotaEnabled=n.codexQuotaEnabled===!0,n.codexQuotaSidebar=n.codexQuotaSidebar!==!1,n.codexQuotaStrip=n.codexQuotaStrip!==!1,n.codexQuotaSource=s(n.codexQuotaSource,["auto","connect","subscription","chatgpt","pi-ai","chatgpt-sub"],"auto"),n.codexCompatPromptDismissed=n.codexCompatPromptDismissed===!0,n.codexCompatHistoryAppliedAt=Number.isFinite(n.codexCompatHistoryAppliedAt)&&n.codexCompatHistoryAppliedAt>0?n.codexCompatHistoryAppliedAt:0,n.sidebarSimple=n.sidebarSimple===!0,n.sidebarSimplePromptSeen=n.sidebarSimplePromptSeen===!0,n.sidebarSummaryPromptSeen=n.sidebarSummaryPromptSeen===!0,n.billionContextNoticeEnabled=n.billionContextNoticeEnabled!==!1,n.billingStorageRetentionDays=[0,7,30].includes(n.billingStorageRetentionDays)?n.billingStorageRetentionDays:7,n.billionContextNoticesSeen=[...new Set((Array.isArray(n.billionContextNoticesSeen)?n.billionContextNoticesSeen:[]).filter(p=>typeof p=="string"&&p.length<=160))].slice(-32),n.sidebarModels=Object.fromEntries(Object.entries(t.sidebarModels).map(([p,m])=>{let y=n.sidebarModels?.[p],E={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[p];return[p,E?E.includes(y)?y:m:typeof m=="boolean"?typeof y=="boolean"?y:m:typeof y=="number"&&Number.isFinite(y)?Math.min(p==="topN"?10:60,Math.max(p==="topN"?1:10,Math.floor(y))):m]})),n.sidebarStyle=s(n.sidebarStyle,["standard","compact","summary"],"standard"),n.priceMatchDismissed=Array.isArray(n.priceMatchDismissed)?[...new Set(n.priceMatchDismissed.filter(p=>typeof p=="string"&&p.length>0&&p.length<=512))].slice(0,1e3):[],delete n.hideAmounts,n.peakAlertEnabled=n.peakAlertEnabled!==!1;let c=Number(n.peakAlertAhead);n.peakAlertAhead=Number.isInteger(c)&&c>=1&&c<=30?c:2,n.peakAlertTarget=s(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=s(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=a(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=_(n),n.exchangeRateCheckedAt=Number.isFinite(n.exchangeRateCheckedAt)&&n.exchangeRateCheckedAt>0?n.exchangeRateCheckedAt:0,n.exchangeRateDate=/^\d{4}-\d{2}-\d{2}$/.test(n.exchangeRateDate??"")?n.exchangeRateDate:"",(!a(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(p=>p!==null&&typeof p=="object"&&a(Number(p.start))&&a(Number(p.end))):n.peakWindows=t.peakWindows,Array.isArray(n.peakHolidays)?n.peakHolidays=[...new Set(n.peakHolidays.filter(p=>typeof p=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(p)&&!Number.isNaN(Date.parse(p+"T00:00:00Z"))&&new Date(p+"T00:00:00Z").toISOString().slice(0,10)===p))].slice(0,366).sort():n.peakHolidays=t.peakHolidays,Number.isNaN(Date.parse(n.peakEffectiveAt))&&(n.peakEffectiveAt=t.peakEffectiveAt);let u={};if(n.priceOverrides!==null&&typeof n.priceOverrides=="object")for(let[p,m]of Object.entries(n.priceOverrides))typeof p=="string"&&typeof m=="string"&&(u[p]=m);n.priceOverrides=u;let d={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[p,m]of Object.entries(n.priceTableDisplay))typeof p=="string"&&(d[p]=typeof m=="boolean"?m:t.priceTableDisplay[p]===!0);n.priceTableDisplay={...t.priceTableDisplay,...d};let l=n.budget;l.enabled=l.enabled===!0,l.amount=a(l.amount)&&l.amount>=0?l.amount:100,l.period=s(l.period,["day","month","all","custom"],"month"),l.customStart=typeof l.customStart=="string"?l.customStart:null,l.customEnd=typeof l.customEnd=="string"?l.customEnd:null,l.detail=l.detail!==!1;let h=n.balance;h.display=s(h.display,["sidebar","settings","both","off"],"both"),h.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(h.refreshMinutes)||5))),h.showProgressBar===void 0&&(h.showProgressBar=n.customBalance?.showProgressBar!==void 0?n.customBalance.showProgressBar===!0:t.balance.showProgressBar===!0),h.showProgressBar=h.showProgressBar===!0,h.showSource=h.showSource===!0,h.clickHintSeen=h.clickHintSeen===!0,h.reconcile=h.reconcile!==!1;let A=Number(h.budgetCap);h.budgetCap=Number.isFinite(A)&&A>0?A:null;let f=n.goQuota;f.enabled=f.enabled===!0,typeof f.showInComposer!="boolean"&&delete f.showInComposer,f.display=s(f.display,["sidebar","settings","both","off"],"both"),f.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(f.refreshMinutes)||15))),f.apiKey=typeof f.apiKey=="string"?f.apiKey:"",f.main=s(f.main,["rolling","weekly","monthly"],"rolling"),f.detail=f.detail!==!1;let b=n.customBalance??t.customBalance,k=(p,m)=>{let y=p??{},E={...["aliyun","tokenrhythm"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:s(y.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),label:typeof y.label=="string"?y.label:m.label,labelEn:typeof y.labelEn=="string"?y.labelEn:m.labelEn,unit:y.adapter==="tokenrhythm"?"CNY":s(y.unit,["USD","CNY","EUR","CREDITS"],m.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))E.request={...m.request};else{let W={};for(let[L,z]of Object.entries(y.request.headers??{}))typeof L=="string"&&typeof z=="string"&&(W[L]=z);E.request={...m.request,...y.request,url:typeof y.request.url=="string"?y.request.url:"",method:typeof y.request.method=="string"?y.request.method:"GET",headers:{...m.request?.headers??{},...W}}}if(y.extract===null||typeof y.extract!="object"||Array.isArray(y.extract)?E.extract={...m.extract}:E.extract={...m.extract,...y.extract},Array.isArray(y.allowedHosts)){let W=y.allowedHosts.filter(L=>typeof L=="string"&&L.length>0);W.length>0&&(E.allowedHosts=W)}return E},g=k(b,t.customBalance);n.customBalance=g;let M=n.gatewayQuotas,x=Array.isArray(M)?M:M!==null&&typeof M=="object"&&Array.isArray(M.sources)?M.sources:[],w=[],I=new Set;for(let p of x.slice(0,4)){let m=nr(p);!Xi.test(m.id)||I.has(m.id)||m.type!=="cliproxyapi"||!or(m.baseURL)||(I.add(m.id),w.push(m))}n.gatewayQuotas={sources:w};let C=n.customBalances;Array.isArray(C)||(C=[]);let R=t.customBalances?.[0]??t.customBalance,Y=C.slice(0,8).map(p=>k(p,R)),G=g.enabled===!0||typeof g.request?.url=="string"&&g.request.url.length>0;Y.length===0&&G&&Y.push(g),n.customBalances=Y;let te=n.corner;for(let p of["enabled","goRolling","goWeekly","goMonthly","budget"])te[p]=te[p]===!0||te[p]!==!1&&p!=="enabled";let D=n.quotaStrip;D.enabled=D.enabled===!0,D.promptSeen=D.promptSeen===!0;for(let p of["budget","go","plans"])D[p]=D[p]!==!1;let Me=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:Me.balance==="used"?"used":"remaining",budget:Me.budget==="remaining"?"remaining":"used",go:Me.go==="remaining"?"remaining":"used",plan:Me.plan==="remaining"?"remaining":"used"};let S={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[p,m]of Object.entries(n.codingPlans))if(!(!ce.includes(p)||m===null||typeof m!="object"||Array.isArray(m))){if(S[p]={enabled:m.enabled===!0,...typeof m.showInComposer=="boolean"?{showInComposer:m.showInComposer}:{},display:s(m.display,["sidebar","settings","both","off"],"settings"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(m.refreshMinutes)||15))),apiKey:typeof m.apiKey=="string"?m.apiKey:""},p==="minimax"){let y=yn(m.baseUrl);S[p].baseUrl=y??"",y===null&&(S[p].enabled=!1)}if(p==="workbuddy"&&(m.accountSource!==void 0&&(S[p].accountSource=s(m.accountSource,["auto","connect","xdpool"],"auto")),S[p].accountScope=s(m.accountScope,["current","all","selected"],"current"),S[p].accountIds=Array.isArray(m.accountIds)?[...new Set(m.accountIds.filter(it))].slice(0,400):[]),p==="opendesign"){let y=dn(m.workspaceId);S[p].workspaceId=y??"",y===null&&(S[p].enabled=!1)}if(p==="factory"){let y=un(m.orgId);S[p].orgId=y??"",y===null&&(S[p].enabled=!1),S[p].factoryPool=s(m.factoryPool,["standard","core","both"],"standard")}if(p==="scnet"){let y=Number(m.planCredits);S[p].planCredits=Number.isFinite(y)&&y>0?y:24e4,S[p].planStart=typeof m.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(m.planStart)?m.planStart:""}if(p==="qwen"){S[p].quotaSource=m.quotaSource==="cli"||m.quotaSource==="bailian"?m.quotaSource:"local";let y=Number(m.planCredits);S[p].planCredits=Number.isFinite(y)&&y>0?y:5e5,S[p].planStart=typeof m.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(m.planStart)?m.planStart:"";let E=m.rates!==null&&typeof m.rates=="object"&&!Array.isArray(m.rates)?m.rates:{},W={};for(let[L,z]of Object.entries(E)){if(typeof L!="string"||L.length===0||z===null||typeof z!="object")continue;let Qe=To=>{let Ve=Number(To);return Number.isFinite(Ve)&&Ve>0?Ve:null},Yt=Qe(z.input),Gt=Qe(z.cachedInput),Qt=Qe(z.output);Yt===null||Gt===null||Qt===null||(W[L]={input:Yt,cachedInput:Gt,output:Qt})}S[p].rates=W}if(p==="volcengine"){let y=typeof m.accessKeyId=="string"?m.accessKeyId.trim():"",E=typeof m.apiKey=="string"?m.apiKey.trim():"";S[p].accessKeyId=y.length>0?y:E,S[p].secretAccessKey=typeof m.secretAccessKey=="string"?m.secretAccessKey:"",S[p].accessKeyId.length>0&&S[p].apiKey!==S[p].accessKeyId&&(S[p].apiKey=S[p].accessKeyId)}}}n.codingPlans=S;let Ge={};for(let p of J){let m=n.planBilling?.providers?.[p];Ge[p]=["auto","plan","api"].includes(m)?m:At[p]??"auto"}if(n.planBilling?.providers&&typeof n.planBilling.providers=="object"&&!Array.isArray(n.planBilling.providers))for(let[p,m]of Object.entries(n.planBilling.providers))p.trim()&&!["__proto__","constructor","prototype"].includes(p)&&["auto","plan","api"].includes(m)&&(Ge[p]=m);let qt={};if(n.planBilling?.models!==null&&typeof n.planBilling?.models=="object"&&!Array.isArray(n.planBilling?.models))for(let[p,m]of Object.entries(n.planBilling.models))typeof p=="string"&&p.length>0&&(m==="plan"||m==="api")&&(qt[p]=m);let No=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([p,m])=>p.includes(":")&&J.includes(m))),Ro=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(p=>J.includes(p)):[...Re(n)])];return n.planBilling={providers:Ge,models:qt,modelPlans:No,autoProviders:Ro},n}var sr={balance:"DEEPSEEK_BALANCE_API_KEY",goQuota:"OPENCODE_GO_API_KEY","codingPlans.opendesign":"OPENDESIGN_CONTROL_KEY","codingPlans.anthropic":"ANTHROPIC_OAUTH_TOKEN","codingPlans.zai":"ZAI_API_KEY","codingPlans.minimax":"MINIMAX_API_KEY","codingPlans.kimi":"KIMI_CODING_API_KEY","codingPlans.openrouter":"OPENROUTER_API_KEY","codingPlans.siliconflow":"SILICONFLOW_API_KEY","codingPlans.commandcode":"COMMANDCODE_API_KEY","codingPlans.clinepass":"CLINE_PASS_API_KEY","codingPlans.volcengine.ak":"VOLC_ACCESSKEY","codingPlans.volcengine.sk":"VOLC_SECRETKEY","codingPlans.mimo":"MIMO_COOKIE","codingPlans.factory":"FACTORY_API_KEY"},hc=Object.keys(sr);function xo(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;let t=e.request;if(t===null||typeof t!="object"||Array.isArray(t))return e;let o=t.headers;if(o===null||typeof o!="object"||Array.isArray(o))return e;let n=!1,i={};for(let[r,a]of Object.entries(o))et(r,a)?(i[r]="",n=!0):i[r]=a;return n?{...e,request:{...t,headers:i}}:e}function Eo(e){if(e===null||typeof e!="object"||Array.isArray(e))return e;let t={...e};if(t.goQuota!==null&&typeof t.goQuota=="object"&&!Array.isArray(t.goQuota)){let o={...t.goQuota};"apiKey"in o&&(o.apiKey=""),t.goQuota=o}if(t.codingPlans!==null&&typeof t.codingPlans=="object"&&!Array.isArray(t.codingPlans)){let o={};for(let[n,i]of Object.entries(t.codingPlans)){if(i===null||typeof i!="object"||Array.isArray(i)){o[n]=i;continue}let r={...i};"apiKey"in r&&(r.apiKey=""),"accessKeyId"in r&&(r.accessKeyId=""),"secretAccessKey"in r&&(r.secretAccessKey=""),o[n]=r}t.codingPlans=o}if(t.customBalance!==null&&typeof t.customBalance=="object"&&!Array.isArray(t.customBalance)&&(t.customBalance=xo(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(xo)),Array.isArray(t.gatewayQuotas))t.gatewayQuotas=t.gatewayQuotas.map(o=>{if(o===null||typeof o!="object"||Array.isArray(o))return o;let n={...o};for(let i of["managementKey","apiKey","key","token"])delete n[i];return n});else if(t.gatewayQuotas!==null&&typeof t.gatewayQuotas=="object"){let o={...t.gatewayQuotas};Array.isArray(o.sources)&&(o.sources=o.sources.map(n=>{if(n===null||typeof n!="object"||Array.isArray(n))return n;let i={...n};for(let r of["managementKey","apiKey","key","token"])delete i[r];return i})),t.gatewayQuotas=o}return t}var zt=[{id:"provider-catalog-2026-10-03",apply:Pe},{id:"provider-catalog-2026-10-15",apply:On},{id:"stepfun-catalog-2026-10-16",apply:Cn},{id:"v1.5.26-coding-plan-sidebar-display",apply(e){let t=e?.codingPlans?.minimax;t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.enabled===!0&&(t.display="both")}}],Ye=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=he(r.pricingHistory,t),this.config=t,Zt(o,t),this.days=o,this.path=n,this.writeTimer=null,this.closed=!1,this.pendingWrite=!1,this.backgroundWrite=null,this.backgroundWriteDisabled=!1,this.writeGeneration=0,this.startWrite=r.backgroundWriter??an,this.writeReceipts=H(r.writeReceipts),this.diskRevision=null,this.balanceRef=r.balanceRef??null,this.historyReset=r.historyReset??null,this.usageCursors=X(r.usageCursors),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.migrations=Array.isArray(i)?i.filter(a=>typeof a=="string"):[],this.secretMigration={ran:!1,pending:[]},this.planSamples=r.planSamples??{},this.planHourBuckets=r.planHourBuckets??{},this.openrouterPriceHashes=Object.fromEntries(Object.entries(r.openrouterPriceHashes??{}).filter(([a,s])=>!["__proto__","constructor","prototype"].includes(a)&&typeof s=="string"&&/^[a-f0-9]{64}$/.test(s))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([a,s])=>a.startsWith("opendesign:")&&typeof s=="string"&&/^[a-f0-9]{64}$/.test(s))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&We(this.pricingHistory,t),this._config=ao(t,this.pricingHistory)}static open(){let t=wo(ot(),"storages","cost-meter"),o=wo(t,"ledger.json");return be(o,()=>e.load(o))}static load(t){let o=Kt(),n={},i=null,r=[...zt.map(g=>g.id),"quota-token-window-v2"],a={},s={},c={},u={},d=null,l={},h=[],A,f=!1;try{let g=JSON.parse(Vi(t,"utf8"));if(g===null||typeof g!="object"||Array.isArray(g))throw new Error("Unsupported ledger format");if(g!==null&&typeof g=="object")if(g.version!==Mo){try{Ao(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(g.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=g.historyReset??null,l=X(g.usageCursors),h=H(g.writeReceipts);let M=typeof g.config=="object"&&g.config!==null?g.config:{};A=he(g.pricingHistory,Ae(M),void 0,!0),f=!!g.pricingHistory&&g.pricingHistory.format!==2,r=Array.isArray(g.migrations)?g.migrations.filter(I=>typeof I=="string"):[];let x=new Set(r);for(let I of zt)x.has(I.id)||(I.apply(M),r.push(I.id));o=Ae(M),g.openrouterPriceHashes&&typeof g.openrouterPriceHashes=="object"&&!Array.isArray(g.openrouterPriceHashes)&&(c=g.openrouterPriceHashes),g.providerPriceHashes&&typeof g.providerPriceHashes=="object"&&!Array.isArray(g.providerPriceHashes)&&(u=g.providerPriceHashes),g.days!==null&&typeof g.days=="object"&&!Array.isArray(g.days)&&(n=So(g.days));let w=g.balanceRef;w!==null&&typeof w=="object"&&typeof w.date=="string"&&Number.isFinite(w.total)&&Number.isFinite(w.granted)&&Number.isFinite(w.topped)&&(i={date:w.date,total:w.total,granted:w.granted,topped:w.topped,currency:typeof w.currency=="string"?w.currency:void 0,at:Number(w.at)||0,ledgerCost:Number.isFinite(w.ledgerCost)&&w.ledgerCost>=0?w.ledgerCost:void 0}),g.planSamples!==null&&typeof g.planSamples=="object"&&!Array.isArray(g.planSamples)&&(a=g.planSamples),g.planHourBuckets!==null&&typeof g.planHourBuckets=="object"&&!Array.isArray(g.planHourBuckets)?s=g.planHourBuckets:Array.isArray(g.planRecentCalls)&&(s=It(g.planRecentCalls))}}catch(g){if(g?.code!=="ENOENT"){try{Ao(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(g?.message??g)}`)}}let b=new e(o,n,t,r,{planSamples:a,planHourBuckets:s,openrouterPriceHashes:c,providerPriceHashes:u,balanceRef:i,historyReset:d,usageCursors:l,writeReceipts:h,pricingHistory:A});b.legacyPricingHistory=f,b.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),b.quotaStatsNeedRepair&&(b.planSamples={}),f&&b.scheduleWrite();let k=Q(b.days);return k.length&&(k.includes(b.balanceRef?.date)&&(b.balanceRef=null),b.scheduleWrite()),b}account(t,o,n,i,r,a,s){if(this.closed)return;if(s!==void 0&&(!rn(s,i)||r!=="deepseek-official"||!on(o,s)))throw new Error("Invalid official web request fee");let c=Tt(this.config,i,n,`${r||"deepseek"}:${o}`),u=Rn(r,o,c.prices,{mode:c.priceMatch==="exact"?"exact":"auto",overrides:c.priceOverrides}),d=u.entry??{cacheHit:0,cacheMiss:0,output:0},l={enabled:["deepseek-peak","utc-peak"].includes(u.billingMode)&&c.peakEnabled===!0,effectiveAtMs:Date.parse(c.peakEffectiveAt),windows:c.peakWindows,holidays:c.peakHolidays},h=s?s.requests*s.rateCny:u.priced?Tn(t,d,i,l):0,A=Un(h,s?"CNY":u.currency,_(c).CNY),f=this.config.planBilling,b=Re(this.config),k=s?"api":Bn(r,o,f,b,this.config.prices),g=k==="api"?A:0,M=C=>{let R=Number(C);return Number.isFinite(R)&&R>0?R:0},x={input:M(t?.input),output:M(t?.output),cacheRead:M(t?.cacheRead),cacheWrite:M(t?.cacheWrite),reasoning:M(t?.reasoning)},w=k==="plan"?kt(r,f,o)??(wt(r,o,this.config.prices)?"go":null):null,I={...a?{meter:a}:{},date:Ft(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:w,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...x,calls:1,cost:A,apiCost:g,...Ze(A,g,c)}};return re(this,I)?(this.pendingAccounts.push(I),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};re(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||Oo)),o=Object.keys(this.days).sort();for(;o.length>t;)delete this.days[o.shift()]}scheduleWrite(){this.writeGeneration++,this.pendingWrite=!0,this.writeTimer===null&&(this.writeTimer=setTimeout(()=>{this.writeTimer=null,this.flushAsync()},2e3))}snapshot(){return ge({version:Mo,config:Eo(this.config),days:this.days,writeReceipts:this.writeReceipts,balanceRef:this.balanceRef??null,migrations:this.migrations,planSamples:this.planSamples??{},planHourBuckets:this.planHourBuckets??{},openrouterPriceHashes:this.openrouterPriceHashes??{},historyReset:this.historyReset??null,...Object.keys(this.usageCursors).length?{usageCursors:this.usageCursors}:{},...Object.keys(this.providerPriceHashes).length?{providerPriceHashes:this.providerPriceHashes}:{},pricingHistory:this.pricingHistory})}resetHistory(){this.days={},this.planSamples={},this.planHourBuckets={},this.balanceRef=null,this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.historyReset={id:ko(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=ye(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=bo(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=he(o.pricingHistory,Ae(o.config),this.pricingHistory,!0);for(let i of zt)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:Eo(Ae(o.config)),days:So(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??It(o.planRecentCalls??[]),openrouterPriceHashes:o.openrouterPriceHashes??{},historyReset:o.historyReset??null,usageCursors:X(o.usageCursors),writeReceipts:H(o.writeReceipts),providerPriceHashes:o.providerPriceHashes??{},pricingHistory:n}}adoptSnapshot(t){this.pricingHistory=he(t.pricingHistory,t.config),this.config=Ae(yo(this.writeBase.config,this.config,t.config));for(let o of["days","balanceRef","migrations","planSamples","planHourBuckets","openrouterPriceHashes","historyReset"])this[o]=t[o];this.usageCursors=X(t.usageCursors),this.writeReceipts=H(t.writeReceipts),this.providerPriceHashes=t.providerPriceHashes??{}}refresh(){if(!this.closed){if(this.pendingWrite){ye(this.path)!==this.diskRevision?this.flush():this.flushAsync();return}try{let t=ye(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(se(this.writeBase,this.snapshot(),o,[],Date.now(),[],{ownLocal:!0})),this.writeBase=this.snapshot(),this.diskRevision=t}catch(t){t?.code!=="ENOENT"&&console.warn(`[dsh-cost-meter] \u8D26\u672C\u5237\u65B0\u5931\u8D25,\u4FDD\u7559\u5F53\u524D\u8BB0\u5F55: ${String(t?.message??t)}`)}}}repairPlanHours(t){this.closed||!t.length||(this.pendingPlanHourRepairs.push(...t),this.writeGeneration++,this.pendingWrite=!0,this.flush())}flush(t=0){if(!(this.backgroundWrite&&!this.backgroundWrite.wait(Math.max(8e3,t)))&&!(!this.pendingWrite||this.closed))try{be(this.path,()=>{We(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=Q(n.days);i.includes(n.balanceRef?.date)&&(n.balanceRef=null);let r=(o===null||o===this.writeBase)&&!this.pendingPlanHourRepairs.length&&!i.length,a=r?n:se(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});$e(this.path,a,this.legacyPricingHistory),this.legacyPricingHistory=!1,r||this.adoptSnapshot(a),this.writeBase=r?a:this.snapshot(),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.pendingWrite=!1,this.diskRevision=ye(this.path)},t)}catch(o){(o?.code!=="EBUSY"||t>0)&&console.warn(`[dsh-cost-meter] \u8D26\u672C\u5199\u5165\u5931\u8D25,\u7A0D\u540E\u91CD\u8BD5: ${String(o?.message??o)}`),this.closed||this.scheduleWrite()}}fallbackWrite(t){this.backgroundWriteDisabled||(this.backgroundWriteDisabled=!0,console.warn(`[dsh-cost-meter] \u540E\u53F0\u8D26\u672C\u4FDD\u5B58\u4E0D\u53EF\u7528\uFF0C\u5DF2\u5207\u6362\u4E3A\u540C\u6B65\u63D0\u4EA4\uFF0C\u672C\u6B21\u8FD0\u884C\u4E0D\u518D\u542F\u52A8\u540E\u53F0\u7EBF\u7A0B: ${String(t?.message??t)}`)),this.flush()}flushAsync(){if(this.backgroundWrite)return this.backgroundWrite.promise;if(this.closed||!this.pendingWrite)return Promise.resolve();if(this.backgroundWriteDisabled)return this.flush(),Promise.resolve();We(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,a=this.writeGeneration,s=ko();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:s,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},c=>{if(this.backgroundWrite=null,c.error){let l;try{l=this.readDiskSnapshot()}catch{}if(H(l?.writeReceipts).includes(s))c={merged:l,revision:ye(this.path)};else{c.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(c.error);return}}let u=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(c.ownDisk)this.writeReceipts=H(c.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let l=se(t,this.snapshot(),c.merged,u,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(l),this.writeBase=c.merged}this.pendingAccounts=u,this.pendingPlanHourRepairs=d,this.pendingWrite=a!==this.writeGeneration||u.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=c.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(c){return this.fallbackWrite(c),Promise.resolve()}}close(){if(this.backgroundWrite)return this.backgroundWrite.promise.then(()=>this.close());this.flush(5e3),this.closed=!0,this.writeTimer!==null&&(clearTimeout(this.writeTimer),this.writeTimer=null)}sumDays(t){let o=Wt(t===void 0?"total":t);for(let[n,i]of Object.entries(this.days))if(!(t!==void 0&&!n.startsWith(t))){o.input+=i.input??0,o.output+=i.output??0,o.cacheRead+=i.cacheRead??0,o.cacheWrite+=i.cacheWrite??0,o.reasoning+=i.reasoning??0,o.calls+=i.calls??0,ae(o,i),o.cost+=i.cost??0,o.apiCost=(o.apiCost??0)+(i.apiCost??i.cost??0);for(let[r,a]of Object.entries(i.byProviderModel??{})){let s=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={...ae({...Ie(s)},a),input:s.input+(a.input??0),output:s.output+(a.output??0),cacheRead:s.cacheRead+(a.cacheRead??0),cacheWrite:s.cacheWrite+(a.cacheWrite??0),reasoning:s.reasoning+(a.reasoning??0),calls:s.calls+(a.calls??0),cost:s.cost+(a.cost??0),apiCost:(s.apiCost??0)+(a.apiCost??a.cost??0)}}}return o.date=t===void 0?"total":t,o}sumRange(t,o){let n=Wt(`${t}..${o}`);if(typeof t!="string"||typeof o!="string")return n;for(let[i,r]of Object.entries(this.days))if(!(i<t||i>o)){n.input+=r.input??0,n.output+=r.output??0,n.cacheRead+=r.cacheRead??0,n.cacheWrite+=r.cacheWrite??0,n.reasoning+=r.reasoning??0,n.calls+=r.calls??0,ae(n,r),n.cost+=r.cost??0,n.apiCost=(n.apiCost??0)+(r.apiCost??r.cost??0);for(let[a,s]of Object.entries(r.byProviderModel??{})){let c=n.byProviderModel[a]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[a]={...ae({...Ie(c)},s),input:c.input+(s.input??0),output:c.output+(s.output??0),cacheRead:c.cacheRead+(s.cacheRead??0),cacheWrite:c.cacheWrite+(s.cacheWrite??0),reasoning:c.reasoning+(s.reasoning??0),calls:c.calls+(s.calls??0),cost:c.cost+(s.cost??0),apiCost:(c.apiCost??0)+(s.apiCost??s.cost??0)}}}return n}today(){let t=Ft(Date.now()),o=this.days[t];return o===void 0?Wt(t):this.copyDay(o)}todayOfficialCost(){return ir(this.days[Ft(Date.now())])}history(t=60){return Object.keys(this.days).sort().reverse().slice(0,t).map(o=>this.copyDay(this.days[o],!0))}copyDay(t,o=!1){let n=o||!Array.isArray(t.sessions)?[]:t.sessions.slice().sort((i,r)=>r.cost-i.cost).map(i=>({...i}));return{...Ie(t),date:String(t.date),input:t.input??0,output:t.output??0,cacheRead:t.cacheRead??0,cacheWrite:t.cacheWrite??0,reasoning:t.reasoning??0,calls:t.calls??0,cost:t.cost??0,apiCost:t.apiCost??t.cost??0,byProviderModel:t.byProviderModel??{},sessions:n}}};var Co=e=>{try{let t=cr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:we,base:_o,local:ee,pending:lr,repairs:vo,revision:ur,backupHistory:dr,transactionId:pr,now:fr,port:$t,signal:Po,lockId:hr}=ar;try{let e=be(we,()=>{let t=Co(we)===ur,o=Q(ee.days);o.includes(ee.balanceRef?.date)&&(ee.balanceRef=null);let n=t&&!vo.length&&!o.length,i=ee;if(!n){let r=new Ye(ee.config,{},we,[],{pricingHistory:ee.pricingHistory});r.writeBase=_o,i=se(_o,ee,r.readDiskSnapshot(),lr,fr,vo,{ownLocal:!0})}return i.writeReceipts=H([...i.writeReceipts??[],pr]),$e(we,i,dr),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Co(we)}},5e3,hr);$t.postMessage(e)}catch(e){$t.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Po,0,1),Atomics.notify(Po,0),$t.close()}