dsh-cost-meter 1.9.48 → 1.9.49

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 vr}from"node:worker_threads";import{statSync as Pr}from"node:fs";var nt=["peakWindows","peakHolidays","peakSchedule"];function V(e){return Object.fromEntries(nt.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Oe(e){return!(!e||typeof e!="object"||e.peakWindows!==void 0&&(!Array.isArray(e.peakWindows)||e.peakWindows.length>24||e.peakWindows.some(t=>!t||!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<0||t.start>=24||t.end<0||t.end>24||t.start===t.end))||e.peakSchedule!==void 0&&!["deepseek","volcengine","ollama","daily","utc-weekdays"].includes(e.peakSchedule)||e.peakHolidays!==void 0&&e.peakHolidays!==null&&(!Array.isArray(e.peakHolidays)||e.peakHolidays.length>366||e.peakHolidays.some(t=>typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t)||!Number.isFinite(Date.parse(t+"T00:00:00Z"))||new Date(t+"T00:00:00Z").toISOString().slice(0,10)!==t)))}function sn(e,t,o){if(!e?.entry)return e;let n=o?.providers?.[t]??(["deepseek-official","deepseek-account",""].includes(t)?o?.providers?.deepseek:void 0),i={...V(n),...e.entry};return{...e,entry:i,billingMode:(i.peak||i.offPeak)&&Object.keys(V(i)).length&&i.billingMode!=="flat"?"deepseek-peak":e.billingMode}}function cn(e,t,o){if(!(e.peakWindows!==void 0||e.peakHolidays!==void 0||["daily","utc-weekdays","deepseek"].includes(e.peakSchedule)))return null;if(o?.enabled!==!0||!Number.isFinite(t)||Number.isFinite(o.effectiveAtMs)&&t<o.effectiveAtMs)return"base";let i=e.peakSchedule??(e.billingMode==="utc-peak"?"utc-weekdays":"deepseek"),r=e.peakWindows??(i==="ollama"?[{start:12,end:18}]:o.windows??[]),s=e.peakHolidays===null?[]:e.peakHolidays??(["ollama","volcengine","utc-weekdays","daily"].includes(i)?[]:o.holidays??[]),c=new Date(t+8*36e5),a=new Date(t),l=["ollama","utc-weekdays"].includes(i)?a.getUTCDay():c.getUTCDay();if(i!=="daily"&&(l===0||l===6)||s.includes(c.toISOString().slice(0,10)))return"offPeak";let d=a.getUTCHours()+a.getUTCMinutes()/60+a.getUTCSeconds()/3600+a.getUTCMilliseconds()/36e5;return r.some(u=>u.start<u.end?d>=u.start&&d<u.end:d>=u.start||d<u.end)?"peak":"offPeak"}var R=["costCny","apiCostCny","costEur","apiCostEur"],an=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function v(e={}){let t={USD:1,CNY:7.2,EUR:.92};for(let o of["CNY","EUR"])an(e.fxRates?.[o])&&(t[o]=e.fxRates[o]);return["CNY","EUR"].includes(e.currency)&&an(e.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function ot(e,t,o){let n=v(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Ee(e){return Object.fromEntries(R.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function de(e,t,o=1){for(let n of R)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function ln(e,t){let o=n=>{let i=ot(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of R)(!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 ni=["balance","goQuota",...["opendesign","anthropic","zai","minimax","kimi","openrouter","siliconflow","commandcode","clinepass","volcengine","mimo","baidu-coding","factory"].map(e=>"codingPlans."+e)],it=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),oi=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",ii=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function un(e){let t={};if(!it(e))return t;for(let o of ni){let n=e[o];if(!it(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!it(s)||!oi(s.id)||!ii(s.label)||i.has(s.id)?!1:(i.add(s.id),!0)).slice(0,10).map(({id:s,label:c})=>({id:s,label:c.trim()}));t[o]={selected:r.some(s=>s.id===n.selected)?n.selected:"default",accounts:r}}return t}var dn=["today","summary","budget"],pn=e=>e&&typeof e=="object"&&!Array.isArray(e);function fn(e){return pn(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&pn(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(dn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>dn.some(o=>!t[o]))):{}}import{readFileSync as yr,renameSync as Fo,statSync as kr}from"node:fs";import{randomUUID as Wo}from"node:crypto";var hn=5/1e3,ri=Date.parse("2026-11-01T00:00:00+08:00"),mn=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function gn(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 bn(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<ri?0:hn):e.source===void 0&&e.rateCny===hn}var rt=["input","output","cacheRead","cacheWrite","reasoning","calls"],L=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Z(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,s=R.filter(u=>i.every(m=>L(m?.[u]))),c=Object.fromEntries([...rt,"cost","apiCost",...s].map(u=>[u,0])),a=new Map,l=!0;for(let u of i){if(!u?.id||r.has(u.id)){l=!1;break}r.add(u.id);for(let m of Object.keys(c)){let g=m==="apiCost"?u.apiCost??u.cost:u[m]??0;if(!L(g)){l=!1;break}c[m]+=g}if(!l||c.apiCost>c.cost+1e-8){l=!1;break}for(let[m,g]of Object.entries(u.byProviderModel??{})){if(a.has(m)&&a.get(m)===null)continue;let f=a.get(m)??Object.fromEntries(Object.keys(c).map(A=>[A,0])),y=g!==null&&typeof g=="object";for(let A of Object.keys(f)){if(R.includes(A)&&!L(g?.[A])){delete f[A];continue}let w=A==="apiCost"?g?.apiCost??g?.cost:g?.[A]??0;if(!L(w)){y=!1;break}f[A]+=w}a.set(m,y?f:null)}}if(!l||!Object.values(c).every(L)||!rt.every(u=>L(n[u]??0)&&c[u]===(n[u]??0)))continue;let d=Math.abs(c.cost-(n.cost??0))>1e-8||Math.abs(c.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=c.cost,n.apiCost=c.apiCost);for(let u of s)Math.abs(c[u]-(n[u]??0))>1e-8&&(n[u]=c[u],d=!0);for(let[u,m]of a){let g=n.byProviderModel?.[u];if(!(!m||!g||!m.calls||!Object.values(m).every(L)||!rt.every(f=>m[f]===(g[f]??0)))&&!(Math.abs(m.cost-(g.cost??0))<=1e-8&&Math.abs(m.apiCost-(g.apiCost??g.cost??0))<=1e-8&&s.every(f=>!L(m[f])||Math.abs(m[f]-(g[f]??0))<=1e-8))){for(let f of s)L(m[f])&&(g[f]=m[f]);g.cost=m.cost,g.apiCost=m.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as si,MessageChannel as ci,receiveMessageOnPort as yn}from"node:worker_threads";import{randomUUID as ai}from"node:crypto";import{unlinkSync as li,rmdirSync as ui}from"node:fs";import{join as di}from"node:path";function kn(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new ci,s=new Int32Array(new SharedArrayBuffer(4)),c=!1,a,l,d,u=ai(),m=new Promise(A=>{a=A}),g=new si(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),f=A=>{if(!c){c=!0,clearTimeout(y);try{t(A)}finally{i.close(),g.terminate(),a()}}},y=setTimeout(()=>{l={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},g.terminate().then(()=>f(l))},o);return y.unref?.(),i.on("message",f),g.on("error",A=>{d={error:{message:A.message,code:A.code}}}),g.on("exit",A=>{if(!c){try{li(di(`${e.path}.lock`,`${process.pid}-${u}`)),ui(`${e.path}.lock`)}catch{}f(yn(i)?.message??l??d??{error:{message:`Ledger worker exited (${A})`}})}}),{promise:m,wait(A=8e3){let w=Date.now()+A;for(;!c;){let M=yn(i);if(M){f(M.message);break}if(Date.now()>=w)return!1;Atomics.wait(s,0,0,Math.min(50,w-Date.now()))}return!0}}}function st(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 Eo,readdirSync as ar,writeFileSync as Ro,readFileSync as To,renameSync as lr,unlinkSync as Ge,rmdirSync as Ye,statSync as ur,copyFileSync as dr,openSync as _o,fsyncSync as vo,closeSync as Po,constants as pr}from"node:fs";import{dirname as Uo,join as ke}from"node:path";import{randomUUID as Do}from"node:crypto";import{isDeepStrictEqual as N}from"node:util";var An=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,pi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,fi=/^(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 ct(e,t){if(typeof t!="string"||t.length===0)return!1;if(An.test(t)){let n=t.replace(new RegExp(An.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(pi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||fi.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var wn="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var Mn="https://api.factory.ai/api/billing/limits";var In=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 _e="https://amr-api.open-design.ai/api/v1",is=_e+"/public/model-prices",at=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],rs=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var hi=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function Sn(e){return e===void 0||e===""?"":typeof e=="string"&&hi(e.trim())?e.trim():null}import{homedir as lt}from"node:os";import{basename as ls,dirname as us,join as xn,resolve as mi}from"node:path";var Cn=".dsh",ds=`~/${Cn}`,gi="DSH_HOME",bi=".agents",ps=`~/${bi}`;function yi(){return xn(lt(),Cn)}function ki(e){return e==="~"?lt():e.startsWith("~/")||e.startsWith("~\\")?xn(lt(),e.slice(2)):e}function Ai(e,t,o,n){let i=t[o];return mi(ki(e??(i!==void 0&&i.trim().length>0?i:n())))}function ut(e,t=process.env){return Ai(e,t,gi,yi)}var dt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var Ii=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var Us=672*60*60,Ds=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"}),Gs=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 Si={opendesign:{label:"OpenDesign",credentialEnvs:["OPENDESIGN_CONTROL_KEY","VELA_CONTROL_KEY","OPENDESIGN_COOKIE"],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 M Plan / Token Plan",credentialEnvs:["MINIMAX_API_KEY"],keyHint:"MiniMax API Key(sk-* / sk-cp-*)"},kimi:{label:"Kimi Code / 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"},"baidu-coding":{label:"\u767E\u5EA6\u5343\u5E06 Token Plan",credentialEnvs:["BAIDU_QIANFAN_COOKIE"],keyHint:"\u767E\u5EA6\u667A\u80FD\u4E91\u63A7\u5236\u53F0 Cookie (console.bce.baidu.com)"},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"}},pe=Object.keys(Si);var ft="https://platform.xiaomimimo.com/api/v1",xi={usage:`${ft}/tokenPlan/usage`,detail:`${ft}/tokenPlan/detail`,balance:`${ft}/balance`},En=["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"];var Ci="open.volcengineapi.com";var Oi="2024-01-01",Ei=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var _i={"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 _n(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var vc=Object.fromEntries(Object.entries(_i).map(([e,t])=>[_n(e),t]));var vn=["scnet","scnet-tokenplan","scnet-token-plan"];var vi={"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}},Pc=Object.fromEntries(Object.entries(vi).map(([e,t])=>[_n(e),t])),Pn=["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"];var Nc={opendesign:[_e+"/workspaces/{workspaceId}/billing/preflight",_e+"/workspaces/{workspaceId}/wallet/balance"],factory:[Mn],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:Ei.map(e=>`https://${Ci}/?Action=${e}&Version=${Oi}`),mimo:[xi.usage],"baidu-coding":[wn],workbuddy:[]};function Nn(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 ht=/^(base|offPeak|peak|legacyBase|longContext|cny)\.(cacheHit|cacheMiss|cacheWrite|output|reasoning)$/;function ve(e){return Object.fromEntries(["multiplier","separateMultipliers","multipliers"].filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Rn(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function mt(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*Rn(t,o+"."+i));return e.longContext&&(n.longContext={...mt(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function Tn(e){let t=ve(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 gt(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])=>!ht.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]*Rn(e,n+"."+r)))return!1}}return!0}var bt={"opencode-zen":{models:{"glm-5.3-flash-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"beam-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"flint-40b-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"nemotron-3.5-super-vl-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28",input:3,output:15,cachedInput:.3,cacheWrite:3},"muse-wonder-1.0":{billingMode:"flat",input:4,output:20,cachedInput:.2,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"gpt-6.1-sol":{input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"}}},"opencode-go":{models:{"kimi-k3.1-pro":{billingMode:"flat",input:2,output:10,cachedInput:.2,cacheWrite:2,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28",input:3,output:15,cachedInput:.3,cacheWrite:3},"step-5-preview":{billingMode:"flat",input:1,output:2.7,cachedInput:.1,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"beam-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"iceman-contributor-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"minimax-m3.1-flash":{billingMode:"flat",input:.15,output:.6,cachedInput:.015,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"gemini-4-argon":{billingMode:"flat",input:2,output:10,cachedInput:.1,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28",notes:"OpenCode Go promotional price through 2026-11-30. USD 2/10/0.1 per MTok; independent of the direct API."}}},moonshot:{models:{"kimi-k3.1-pro":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:2,cny:{cacheMiss:13,cacheHit:1.3,cacheWrite:13,output:68},notes:"Kimi API official USD quote and China CNY quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing. Default 5m cache writes; 1h cache write is USD 4 / CNY 26 per MTok. 1M context uses the same rate."},"kimi-k3.1-pro-highspeed":{input:4,cachedInput:.2,output:20,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:4,cny:{cacheMiss:26,cacheHit:1.3,cacheWrite:26,output:136},notes:"Kimi API Highspeed. Default 5m cache writes; 1h cache write is USD 8 / CNY 52 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:3,cny:{cacheMiss:20,cacheHit:2,cacheWrite:20,output:100},notes:"Default 5m cache writes. 1h cache write is USD 6 / CNY 40 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"k3.1-pro":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:2,cny:{cacheMiss:13,cacheHit:1.3,cacheWrite:13,output:68},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Kimi API official USD quote and China CNY quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing. Default 5m cache writes; 1h cache write is USD 4 / CNY 26 per MTok. 1M context uses the same rate."},"k3.1-pro-highspeed":{input:4,cachedInput:.2,output:20,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:4,cny:{cacheMiss:26,cacheHit:1.3,cacheWrite:26,output:136},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Kimi API Highspeed. Default 5m cache writes; 1h cache write is USD 8 / CNY 52 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},k3:{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:3,cny:{cacheMiss:20,cacheHit:2,cacheWrite:20,output:100},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Default 5m cache writes. 1h cache write is USD 6 / CNY 40 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"k3-256k":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code 256K subscription model. No separate direct API token-equivalent quote."},"kimi-for-coding":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code currently routes this ID to K2.8 Preview. No published direct API quote."},"kimi-for-coding-highspeed":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code K2.7 Code Highspeed subscription ID. Quota usage is queried separately."}}},minimax:{models:{"minimax-m3.1-flash":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://platform.minimax.io/docs/pricing/overview",checkedAt:"2026-10-28",cny:{cacheMiss:1,cacheHit:.1,output:4},notes:"MiniMax M3.1 Flash Standard API. China CNY quote: https://platform.minimax.cn/docs/pricing/overview . M3.1 Flash Preview is retired and requests are served by M3.1 Flash."},"minimax-m3.1-flash-preview":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://platform.minimax.io/docs/pricing/overview",checkedAt:"2026-10-28",cny:{cacheMiss:1,cacheHit:.1,output:4},notes:"MiniMax M3.1 Flash Standard API. China CNY quote: https://platform.minimax.cn/docs/pricing/overview . M3.1 Flash Preview is retired and requests are served by M3.1 Flash."}}},tencent:{models:{"hy4-preview":{input:.834,cachedInput:.042,output:2.501,billingMode:"flat",sourceUrl:"https://intl.cloud.tencent.com/document/product/1300/78937",checkedAt:"2026-10-28",notes:"TokenHub Singapore published USD rate. Regional rates and Token Plan credits are separate."}}},alibaba:{models:{"qwen3.8-flash":{input:.15,cachedInput:.016,output:.47,cacheWrite:.2,billingMode:"flat",sourceUrl:"https://www.alibabacloud.com/help/en/model-studio/model-pricing",checkedAt:"2026-10-28",notes:"Singapore International USD quote, including explicit and implicit cache prices: https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash . Mainland and global deployment rates differ."}}}};bt.openrouter={models:{"moonshotai/kimi-k3.1-pro":{input:2,output:10,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.2,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"minimax/minimax-m3.1-flash":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.015,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"nvidia/nemotron-3.5-super-vl":{input:.15,output:.5,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.02,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"nvidia/nemotron-3.5-super-vl:free":{input:0,output:0,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"meta/muse-wonder":{input:4,output:20,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.2,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."}}};var yt={"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 Pi="https://platform.stepfun.ai/docs/en/guides/pricing/details",fe=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:Pi,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."}),Un={models:{"step-5-preview":fe(1,.1,2.7),"step-3.7-flash":fe(.2,.04,1.15),"step-3.5-flash":fe(.1,.02,.3),"step-3.5-flash-2603":fe(.1,.02,.3),"step-1o-turbo-vision":fe(.36,.07,1.15)}};var Pe={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}}}}},ne=Object.fromEntries([...new Set([...Object.keys(Pe),...Object.keys(yt)])].map(e=>[e,{models:{...Pe[e]?.models,...yt[e]?.models}}]));ne.stepfun=Un;var Dn=structuredClone(ne);for(let[e,t]of Object.entries(bt))ne[e]={models:{...ne[e]?.models,...t.models}};var Hn={"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 Bn="2026-08-01T00:00:00Z",It="2026-08-22T16:00:00Z",Ue=["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"],kt="2026-09-10T04:00:00Z",Ni="2026-08-31T00:00:00Z",jn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Ri(e){if(!Number.isFinite(e)||e<Date.parse(It))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(It)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ti(e,t=Ue){if(!Number.isFinite(e)||e<Date.parse(It)||!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 Ui=(e,t)=>Ti(e,t)??Ri(e),Di="2026-08-16T16:00:00Z";var Ln=[{start:1,end:4},{start:6,end:10}],ie={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"}}}},Fn=Object.freeze(Object.keys(ie["opencode-go"].models)),q={...ie};q.opendesign={models:Hn};for(let[e,t]of Object.entries(ne)){let o=ie[e]?.models??{};q[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function he(e,t=ie){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(q)){if(["__proto__","constructor","prototype"].includes(n))continue;let r=t[n]?.models??{},s=Object.hasOwn(o,n)?o[n]?.models:null;if(!s||typeof s!="object"||Array.isArray(s)){Object.hasOwn(o,n)||(o[n]=structuredClone(i));continue}for(let[c,a]of Object.entries(i.models)){if(!Object.hasOwn(s,c)){Object.hasOwn(r,c)||(s[c]=structuredClone(a));continue}let l=new Set(["input","cacheMiss","cachedInput","cacheHit","cacheRead","cacheWrite","output","reasoning","cny","longContext","legacy","billingMode","sourceUrl","checkedAt","notes","offPeak","peak","legacyBase","rateHistory","unpriced"]);if(s[c]&&Object.keys(s[c]).some(m=>!l.has(m)))continue;let d=P(r[c]),u=P(s[c]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[c]=structuredClone(a))}}}function Wn(e){let t=Object.fromEntries(Object.keys(q).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ie[o]?.models,...Pe[o]?.models}}]));he(e,t)}function zn(e){let t=Object.fromEntries(Object.keys(q).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ie[o]?.models,...Dn[o]?.models}}]));he(e,t)}function Kn(e){he(e,Object.fromEntries(Object.entries(q).filter(([t])=>t!=="stepfun")))}var Hi={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}}},ji={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 At(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,s])=>[r,s*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"?ji:Hi,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):At(i,e,kt)]));return o["deepseek-v4.1-flash"]=At(t.models["deepseek-v4-flash-vision-exp"],e,kt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:At(t.default,e,kt)}}var St=$n("USD"),qn=$n("CNY");function Yn(e,t=Date.now()){if(!e||!Number.isFinite(t)||!Array.isArray(e.rateHistory))return e;let o=null,n=1/0;for(let s of e.rateHistory){let c=Date.parse(s.before);t<c&&c<n&&(o=s,n=c)}if(!o)return e;let{before:i,...r}=o;return{...e,...r}}function $(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=c=>{let a=e[c];return typeof a=="number"&&Number.isFinite(a)&&a>=0?a:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),s=t("cacheWrite");return{cacheHit:n,cacheMiss:o,output:i,...r===void 0?{}:{reasoning:r},...s===void 0?{}:{cacheWrite:s}}}function P(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e.unpriced===!0){let s={unpriced:!0};for(let c of["billingMode","sourceUrl","checkedAt","notes"])typeof e[c]=="string"&&(s[c]=e[c]);return s}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e)||!Oe(e))return null;let t={...$(e),...V(e)},o=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0;if(e.cacheWrite!==void 0&&!o(e.cacheWrite))return null;if(e.longContext!==void 0){let s=e.longContext;if(!s||typeof s!="object"||Array.isArray(s)||!o(s.aboveInputTokens)||s.aboveInputTokens===0||!["cacheMiss","cacheHit","output"].every(c=>o(s[c]))||s.cacheWrite!==void 0&&!o(s.cacheWrite))return null;t.longContext={aboveInputTokens:s.aboveInputTokens,...$(s)}}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 s of["sourceUrl","checkedAt","notes"])typeof e[s]=="string"&&(t[s]=e[s]);if(e.cny!==void 0){if(!e.cny||typeof e.cny!="object"||Array.isArray(e.cny)||!["cacheHit","cacheMiss","output"].every(s=>o(e.cny[s])))return null;t.cny=$(e.cny)}let n=$(e.offPeak);n!==void 0&&(t.offPeak=n);let i=$(e.peak);i!==void 0&&(t.peak=i);let r=$(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 s=new Set;t.rateHistory=[];for(let c of e.rateHistory){if(!c||typeof c.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(c.before)||!Number.isFinite(Date.parse(c.before))||s.has(Date.parse(c.before))||!["cacheHit","cacheMiss","output"].every(l=>typeof c[l]=="number"&&Number.isFinite(c[l])&&c[l]>=0))return null;s.add(Date.parse(c.before));let a={before:c.before,...$(c)};for(let l of["offPeak","peak"])if(c[l]!==void 0){if(!c[l]||!["cacheHit","cacheMiss","output"].every(d=>typeof c[l][d]=="number"&&Number.isFinite(c[l][d])&&c[l][d]>=0))return null;a[l]=$(c[l])}t.rateHistory.push(a)}t.rateHistory.sort((c,a)=>Date.parse(c.before)-Date.parse(a.before))}return Object.assign(t,ve(e)),gt(t)?t:null}function Bi(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 xt(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function T(e){return xt(e).replace(/[^\p{L}\p{N}]+/gu,"")}function Li(e,t=!0,o=!0){let n=xt(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 Te(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(a=>typeof a=="string"&&a.length>0):[],s=r.find(a=>a===o);if(s!==void 0)return s;let c=e.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(c))return null;for(;;){let a=T(c);if(a.length===0)return null;let l=r.filter(u=>T(u)===a);if(l.length>0)return l.length===1?l[0]:null;let d=Li(c,n,i);if(d===c.toLowerCase())return null;c=d}}var wt=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...at]),Re={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 oe(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/"),s=r.search(/[/:]/);if(s>0){let c=r.slice(0,s).trim().toLowerCase(),a=r.slice(s+1).trim();if(Object.hasOwn(Re,c)&&(c===o||(o==="opencode-zen"||o==="opencode-go")&&(Re[c].test(a)||Te(a,Object.keys(c==="deepseek"?i?.models??{}:i?.providers?.[c]?.models??{}),a,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=a;else if(Object.hasOwn(Re,c))return null}return Te(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Fi(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},s=t,c=e,a=(e===""?"deepseek":e)+":"+t,l=r[a];if(l==="__custom__"){let f=De(o?.custom?.[a]);return{entry:f,billingMode:f?.billingMode??"flat",priced:f!==null,currency:f?.currency??"USD"}}if(l==="__local__")return{entry:null,billingMode:"flat",priced:!1};if(typeof l=="string"&&l.length>0){let f=l.indexOf(":");if(f>0&&l.slice(f+1).length>0?(c=l.slice(0,f).trim().toLowerCase(),s=l.slice(f+1)):s=l,c==="deepseek"&&s==="__default__"){let y=o?.default??{cacheHit:0,cacheMiss:0,output:0},A=P(y);return A===null?{entry:null,billingMode:"flat",priced:!1}:{entry:A,billingMode:"deepseek-peak",priced:A.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(c)){let f=oe(s,o?.providers?.[c]?.models??{},"opencode-go",i,o);f===null?c="opencode-go":s=f}if(at.includes(c)&&c!=="opendesign"&&oe(s,o?.providers?.[c]?.models??{},c,i,o)===null&&(c="opendesign"),Gn(c,s))return{entry:null,billingMode:"flat",priced:!1};if(c==="openrouter"){let f=o?.providers?.openrouter?.models??{},y=Object.hasOwn(f,s)?P(f[s]):null;return{entry:y,billingMode:"flat",priced:y!==null&&y.unpriced!==!0}}if(c===""||c==="deepseek"||c.includes("deepseek")){let f=o?.models??{},y=oe(s,f,"deepseek",i,o);if(y!=null){let M=f[y],b=P(M);return b===null||b.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:b,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let M=null,b=-1,S=!1,I="flat";for(let[x,E]of Object.entries(o?.providers??{})){if(wt.has(x))continue;let ue=E?.models??{},j=oe(s,ue,x,i,o);if(j===null)continue;let xe=P(ue[j]);if(xe===null)continue;let Q=+(j===s||T(j)===T(s));Q>b?(M=xe,b=Q,S=!1,I=Mt(ue[j])):Q===b&&(S=!0)}if(S)return{entry:null,billingMode:"flat",priced:!1};if(M!==null)return{entry:M,billingMode:I,priced:M.unpriced!==!0}}let A=Bi(s,o),w=P(A);return w===null?{entry:null,billingMode:"flat",priced:!1}:{entry:w,billingMode:"deepseek-peak",priced:w.unpriced!==!0}}let u=o?.providers?.[c]?.models??{},m=oe(s,u,c,i,o);if(m===null&&wt.has(c))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&Object.hasOwn(Re,c))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&i==="auto"){let f=null,y=-1,A=!1,w="flat";for(let[M,b]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(M===c||wt.has(M))continue;let S=b?.models??{},I=oe(s,S,M,i,o);if(I===null)continue;let x=P(S[I]);if(x===null)continue;let E=+(I===s||T(I)===T(s));E>y?(f=x,y=E,A=!1,w=M==="deepseek"?"deepseek-peak":Mt(S[I])):E===y&&(A=!0)}if(A)return{entry:null,billingMode:"flat",priced:!1};if(f!==null)return{entry:f,billingMode:w,priced:f.unpriced!==!0}}if(m===null)return{entry:null,billingMode:"flat",priced:!1};let g=P(u[m]);return g===null||g.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:Mt(u[m]),priced:!0}}function Wi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Te(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],s=P(r);return s===null||s.unpriced===!0?null:{entry:s,billingMode:"deepseek-peak",priced:!0}}var zi=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 Gn(e,t){if(typeof e=="string"&&zi.has(e))return!0;let o=typeof t=="string"?xt(t):"";return Ki.some(n=>o.startsWith(n))}function Qn(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 s=sn($i(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&s.entry&&s.billingMode==="deepseek-peak"?{...s,entry:{...s.entry,peakSchedule:s.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&s.entry&&s.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?jn.has(typeof t=="string"?t.trim().toLowerCase():""):Te(t,[...jn])!==null)?{...s,entry:{...s.entry,peakSchedule:s.entry.peakSchedule??"ollama"}}:s}function $i(e,t,o,n){let i=Fi(e,t,o,n);if(i.currency)return i;if(i.priced||e===""||e==="deepseek"||e.includes("deepseek"))return Ne(i,o);let s=(n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{})[e+":"+t];if(typeof s!="string"||s.length===0||s==="__local__"||s.includes(":"))return Ne(i,o);let c=n?.mode==="exact"?"exact":"auto";return Ne(Wi(s,o,c)??i,o)}function Ne(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:Tn(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function De(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(n=>typeof e[n]=="number"&&Number.isFinite(e[n])&&e[n]>=0)||["cacheWrite","reasoning"].some(n=>e[n]!==void 0&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)))return null;let t=P(e);if(!t)return null;let o={...t,currency:e.currency,billingMode:e.billingMode==="deepseek-peak"?"deepseek-peak":"flat"};return gt(o)?o:null}function qi(e,t,o,n=Ue){if(!Array.isArray(o)||o.length===0||Ui(e,n)!==null||Number.isFinite(t)&&e<t)return!1;let i=new Date(e).getUTCHours();return o.some(r=>{let s=Number(r?.start),c=Number(r?.end);return!Number.isFinite(s)||!Number.isFinite(c)?!1:s<c?i>=s&&i<c:i>=s||i<c})}function Yi(e,t,o){let n=Yn(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(a,l="base")=>mt(a,n,l),r=cn(n,t,o);if(r!==null)return r==="base"||!n[r]?i(n):i(n[r],r);let s=n.peakSchedule==="ollama";if(s||n.billingMode==="utc-peak"){if(o?.enabled!==!0||!Number.isFinite(t)||s&&t<Date.parse(Ni))return i(n);let a=new Date(t),l=a.getUTCDay(),d=a.getUTCHours(),u=l>0&&l<6&&(s?d>=12&&d<18:d>=1&&d<4||d>=6&&d<10);return i((u?n.peak:n.offPeak)??n,(u?n.peak:n.offPeak)?u?"peak":"offPeak":"base")}if(Number.isFinite(t)&&t<Date.parse(Di)){let a=n.legacyBase;return a===void 0?i(n):i(a,"legacyBase")}if(o?.enabled!==!0)return i(n);let c=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(qi(t,c,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let a=n.peak;return a===void 0?i(n):i(a,"peak")}if(c!==void 0&&t>=c){let a=n.offPeak;return a===void 0?i(n):i(a,"offPeak")}return i(n)}function Vn(e,t,o,n){let i=Yi(t,o,n),r=g=>{let f=Number(g);return Number.isFinite(f)&&f>0?f:0},s=r(e?.input),c=r(e?.output),a=r(e?.cacheRead),l=r(e?.cacheWrite),d=r(e?.reasoning);i.longContext&&s+a+l>i.longContext.aboveInputTokens&&(i=i.longContext);let u=typeof i.reasoning=="number"?i.reasoning:0,m=(s*i.cacheMiss+c*i.output+a*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(m)&&m>0?m:0}function Zn(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 Gi={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"},Qi=Object.entries(Gi).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function Jn(e,t){for(let o of[e,t]){let n=String(o??"").normalize("NFKC").replace(/([a-zA-Z0-9\u3400-\u9fff])(?=(?:MPlan|Coding|Token|Agent|Plan|Subscription))/g,"$1-").replace(/([a-z0-9])((?:coding|token|agent|m)?plan|subscription)$/i,"$1-$2").toLowerCase();if(!/(?:^|[^a-z0-9])(?:(?:coding|token|agent|m)[-_\s]*)?plan(?:$|[^a-z0-9])|(?:^|[^a-z0-9])subscription(?:$|[^a-z0-9])|套餐|订阅/.test(n))continue;let i=Qi.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 s=/token[-_\s]*plan|令牌.*套餐/.test(n),c=/coding[-_\s]*plan|编程.*套餐/.test(n);return s===c?null:s?"tencent-token":r}return r}}return null}var J=[...pe,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Vi={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","minimax-m-plan","minimax-mplan","minimax-token-plan"],kimi:["kimi","kimi-code","kimi-coding","kimi-coding-plan"],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","tencent-hy-token-plan","tokenhub-hy-token-plan"],"baidu-coding":["baidu-coding-plan","qianfan-coding-plan","baidu-token-plan","qianfan-token-plan","baidu-tokenplan","qianfan-tokenplan"],qwen:Pn,scnet:vn,mimo:En,factory:["factory","droid","factory-a","factory-g","factory-o"]},Ct={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"},eo=400,to=2160*36e5,na=168*36e5;var Zi=840*36e5;function Ot(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,s]of Object.entries(Vi))if(s.includes(n))return r;return J.includes(n)?n:Jn(e,o)}var Xn=new WeakMap;function Ji(e){let t=Xn.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(T)),n=new Set,i=new Set(Fn.map(T));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(T(r))&&n.add(T(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},Xn.set(e,t)}return t}function Et(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=T(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:s}=Ji(o);return!r.has(i)&&s.has(i)}function no(e,t,o,n,i){if(mn(e,t))return"api";let r=Ot(e,o,t);r===null&&Et(e,t,i)&&(r="go");let s=o?.models;if(s!==null&&typeof s=="object"){let a=s[`${e}:${t}`];if(a==="plan"||a==="api")return a;if(r!==null){let l=s[`${r}:${t}`];if(l==="plan"||l==="api")return l}}let c=o?.providers;for(let a of[e,r]){if(a==null)continue;let l=c?.[a];if(l==="plan"||l==="api")return l}return r===null?"api":r==="go"&&/^(?:llm-)?(?:dsh-opencode-go|opencode-go(?:-plus)?)$/i.test(String(e).trim())||r==="kimi"&&/^(?:llm-)?kimi-coding(?:-plan)?$/i.test(String(e).trim())||r==="minimax"&&/^(?:llm-)?minimax-(?:m-?plan|token-plan)$/i.test(String(e).trim())||n instanceof Set&&n.has(r)?"plan":"api"}function He(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 pe)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function oo(e){return JSON.stringify([e?.planBilling,[...He(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function _t(e,t,o,n,i){let r=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},s=r[t]!==null&&typeof r[t]=="object"&&!Array.isArray(r[t])?r[t]:{},c=Number(o);if(!Number.isFinite(c)||c<=0)return r;let a=Math.floor(c/36e5)*36e5,l=s[a]!==null&&typeof s[a]=="object"?s[a]:{tokens:0,cost:0};return l.tokens+=Math.max(0,Number(n)||0),l.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...s,[a]:l}}}function io(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Zi,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},s=!1;for(let[c,a]of Object.entries(i)){if(a===null||typeof a!="object"||Array.isArray(a)){s=!0;continue}let l={};for(let[d,u]of Object.entries(a)){let m=Number(d);if(!Number.isFinite(m)||m<n||m>o+36e5){s=!0;continue}l[m]={tokens:Math.max(0,Number(u?.tokens)||0),cost:Math.max(0,Number(u?.cost)||0)}}Object.keys(l).length>0&&(r[c]=l)}return s||Object.keys(r).length!==Object.keys(i).length?r:i}function vt(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=_t(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as Be,readlinkSync as Xi,statSync as er}from"node:fs";import{execFileSync as ro}from"node:child_process";import{hostname as tr}from"node:os";import{join as nr}from"node:path";import{performance as or}from"node:perf_hooks";var co=tr(),Le=process.platform==="win32"?or.timeOrigin:Date.now()-process.uptime()*1e3,so={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},Pt,Nt,je;function Rt(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=Be(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=Be("/proc/sys/kernel/random/boot_id","utf8").trim(),s=Xi(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let c=e===process.pid?Le:null;if(t&&e!==process.pid){je??=Number(ro("getconf",["CLK_TCK"],so).trim());let a=Be("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(je)&&je>0&&a&&(c=(Number(a)+Number(i)/je)*1e3)}return{platform:"linux",boot:r,namespace:s,start:i,startedAtMs:c}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(Le)),unit:"ms",startedAtMs:Le};let n=nr(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=ro(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],so).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function Tt(){return Pt===void 0&&(Pt=Rt(process.pid)),Pt}function ao(){let e=Tt();return JSON.stringify({version:e?.unit==="ms"?2:1,host:co,identity:e})}function lo(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=Be(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==co)return!1;let c=Tt();if(i?.identity?.platform==="linux"&&c?.platform==="linux"&&i.identity.boot===c.boot&&i.identity.namespace!==c.namespace)return!1}try{process.kill(t,0)}catch(c){return c.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,Rt(t,n===""));let s=t===process.pid?Tt():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(Nt===void 0&&(Nt=Rt(t,!1,!0)),s=Nt),n===""){let c=t===process.pid?s?.startedAtMs??Le:s?.startedAtMs;return Number.isFinite(c)&&er(e).mtimeMs<c-2e3}if(!r||!s||r.platform!==s.platform||typeof r.start!="string"||!/^\d+$/.test(r.start))return!1;if(s.platform==="linux")return typeof r.boot!="string"||typeof r.namespace!="string"?!1:r.boot!==s.boot||r.start!==s.start;if(r.unit==="ms"||s.unit==="ms"){let c=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),a=c(r),l=c(s);return!Number.isSafeInteger(a)||a<=0||!Number.isSafeInteger(l)||l<=0?!1:a<l-2e3}return r.start!==s.start}import{createHash as rr,randomUUID as Ht}from"node:crypto";import{createHash as ir}from"node:crypto";var U=new WeakMap,uo=/^[a-f\d]{64}$/,me=e=>e&&typeof e=="object"&&!Array.isArray(e),po=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),Ut=e=>ir("sha256").update(JSON.stringify(e)).digest("hex"),fo=24;function We(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))We(t);return Object.freeze(e)}function ho(e,t,o=[],n=[]){if(e===t)return n;if(me(e)&&me(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))po(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)?ho(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 mo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=mo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function Fe(e,t,o,n){let i=o.get(n);if(i&&i.depth<fo){let r={base:n,patch:ho(t[n],e)};if(JSON.stringify(r).length<JSON.stringify(e).length)return{record:We(r),depth:i.depth+1,signature:Ut(r),baseValue:t[n]}}return{record:e,depth:0,signature:Ut(e)}}function ze(e,t,o,n){let i=U.get(e)??new Map;U.set(e,i),Object.hasOwn(e,t)||(e[t]=We(o)),i.has(t)||i.set(t,Fe(e[t],e,i,n))}function go(e={}){let t={...e};return U.set(t,new Map(U.get(e)??[])),t}function bo(e,t){let o={...t,...e};return U.set(o,new Map([...U.get(t)??[],...U.get(e)??[]])),o}function yo(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,Fe(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function ko(e,t,o){let n={},i=new Map,r=U.get(o),s=new Set,c=a=>{if(i.has(a))return!0;if(!uo.test(a)||s.has(a)||s.size>fo||!me(e[a]))return!1;s.add(a);let l=e[a],d;if(!me(l.prices)){if(!uo.test(l.base)||!Array.isArray(l.patch)||l.patch.length>1e5||l.patch.some(f=>!Array.isArray(f)||![1,2].includes(f.length)||!Array.isArray(f[0])||f[0].length>16||!f[0].every(po))||!c(l.base))return s.delete(a),!1;d=i.get(l.base)}let u=Ut(l),m=d?n[l.base]:void 0,g=r?.get(a);if(g&&o[a]&&(g.sourceSignature===u&&g.sourceBase===m||g.signature===u&&g.baseValue===m))n[a]=o[a],i.set(a,g);else{let f=d?n[l.base]:l;if(d)for(let A of l.patch)f=mo(f,A[0],A);if(!me(f?.prices))return s.delete(a),!1;n[a]=We(t(f));let y=Fe(n[a],n,i,d?l.base:void 0);i.set(a,{...y,sourceSignature:u,sourceBase:m})}return s.delete(a),!0};for(let a of Object.keys(e))c(a);if(U.set(n,i),![...i.values()].some(a=>a.depth>0)){let a;for(let l of Object.keys(n)){let{sourceSignature:d,sourceBase:u}=i.get(l);i.set(l,{...Fe(n[l],n,i,a),sourceSignature:d,sourceBase:u}),a=l}}return n}var Mo=new WeakMap,$e=new WeakMap,ge=new WeakSet,sr=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],Bt=e=>rr("sha256").update(JSON.stringify(e)).digest("hex"),re=e=>!["__proto__","constructor","prototype"].includes(e),Ke=e=>e&&typeof e=="object"&&!Array.isArray(e),cr=new Set(["peakWindows","peakHolidays","peakSchedule","start","end","cacheHit","cacheMiss","cacheWrite","input","cachedInput","output","reasoning","billingMode","unpriced","legacy","currency","aboveInputTokens","before","offPeak","peak","longContext","legacyBase","rateHistory","cny","multiplier","separateMultipliers","multipliers"]),be=e=>Array.isArray(e)?e.map(be):Ke(e)?Object.fromEntries(Object.entries(e).filter(([t])=>cr.has(t)||ht.test(t)).map(([t,o])=>[t,be(o)])):e,Dt=e=>Object.fromEntries(Object.entries(e??{}).filter(([t])=>re(t)).map(([t,o])=>[t,be(o)])),Ao=["at","before","after","days","sessions","skipped"],jt=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function Io(e){let t=$e.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||jt(n,r)>=0)&&o.set(i,n)}return t={changes:Object.values(e.changes).sort(jt),revisions:o,fingerprint:Bt([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((n,i)=>n.at-i.at||(n.sequence??0)-(i.sequence??0))},$e.set(e,t),t}function Lt(e,t=!1){let o=structuredClone(Object.fromEntries(sr.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:be(n.default),models:Dt(n.models),...n.custom?{custom:Dt(n.custom)}:{},providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([i])=>re(i)).map(([i,r])=>[i,{...V(r),...r.currency?{currency:r.currency}:{},...r.default?{default:be(r.default)}:{},models:Dt(r.models)}]))},o}function wo(e,t=!1){let o=Lt(e,t),n=Bt(o),i={};ze(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:v(e)}}};return ge.add(r),r}function ye(e,t,o,n=!1){if(ge.has(e))return e;if(!Ke(e?.versions)||!Ke(e?.changes))return wo(t,n);let i=ko(e.versions,d=>Lt(d,!0),o?.versions),r=Object.fromEntries(Object.entries(e.changes).filter(([d,u])=>re(d)&&Number.isFinite(u?.at)&&u.at>=0&&i[u.version]));if(!Object.values(r).some(d=>d.at===0)){let d=Object.values(i),u={...t?.prices};for(let g of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])d.length&&(u[g]=d.every(f=>f.prices?.[g]===!0));let m=wo({...t,prices:u},n);for(let[g,f]of Object.entries(m.versions))ze(i,g,f);r[Ht()]=m.changes.initial}let s=Object.fromEntries(Object.entries(e.revisions??{}).filter(([d,u])=>re(d)&&typeof u?.sessionId=="string"&&(u.model===void 0||typeof u.model=="string"&&u.model.includes(":")&&u.model.length<=2048)&&/^\d{4}-\d{2}-\d{2}$/.test(u.date)&&Number.isFinite(u.at)&&i[u.version])),c=Object.fromEntries(Object.entries(Ke(e.runs)?e.runs:{}).filter(([d,u])=>re(d)&&Ao.every(m=>Number.isFinite(u?.[m])&&u[m]>=0)).map(([d,u])=>[d,{...Object.fromEntries([...Ao,...["beforeCny","afterCny","beforeEur","afterEur"].filter(m=>Number.isFinite(u[m])&&u[m]>=0)].map(m=>[m,u[m]])),...typeof u.model=="string"?{model:u.model}:{}}])),a=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([d,u])=>re(d)&&Number.isFinite(u?.at)&&u.at>=0&&["CNY","EUR"].every(m=>Number.isFinite(u.rates?.[m])&&u.rates[m]>0)));if(!Object.keys(a).length)for(let[d,u]of Object.entries(r))a[d]={at:u.at,sequence:u.sequence??0,rates:v({...i[u.version],currency:t.currency})};let l={versions:i,changes:r,revisions:s,runs:c,fxChanges:a};return ge.add(l),l}function qe(e,t,o=Date.now()){let n=Lt(t),i=Bt(n),r=Io(e),s=r.changes.at(-1),c=v(t),a=r.fx.at(-1),l=JSON.stringify(a?.rates)!==JSON.stringify(c);l&&(e.fxChanges??={},e.fxChanges[Ht()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,rates:c},$e.delete(e));let d=u=>{let{exchangeRate:m,...g}=u??{};return g};return s?.version===i||JSON.stringify(d(e.versions[s?.version]))===JSON.stringify(d(n))?l:(ze(e.versions,i,n,s?.version),e.changes[Ht()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},$e.delete(e),!0)}function So(e,t){return e&&t&&Mo.set(e,t),e}function Ft(e,t,o="",n=""){if(e?._repriceFxConfig){let I=Ft(e._repriceFxConfig,t,o,n),x=v(I);return{...e,fxRates:x,exchangeRate:x[e.currency]??e.exchangeRate}}let i=Mo.get(e);if(!i||!Number.isFinite(t))return e;let r=Io(i),s=new Date(t),c=Number.isFinite(t)?`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`:"",a=0,l=r.changes.length;for(;a<l;){let I=a+l>>>1;r.changes[I].at<=t?a=I+1:l=I}let d=r.changes[a-1],u=I=>I&&t<=I.at?I:null,m=u(r.revisions.get(JSON.stringify([o,c,""]))),g=n?u(r.revisions.get(JSON.stringify([o,c,n]))):null,f=m&&g?jt(m,g)>0?m:g:m??g,y=(f??d)?.version,A=y&&i.versions[y]?{...e,...i.versions[y]}:e,w=0,M=r.fx.length;for(;w<M;){let I=w+M>>>1;r.fx[I].at<=t?w=I+1:M=I}let b=r.fx[w-1]?.rates,S=f?.preserveFx?m?.fxRates??b??v(i.versions[d?.version]??e):f?f.fxRates??v(A):b??v(A);return{...A,fxRates:S,exchangeRate:S[A.currency]??A.exchangeRate}}function xo(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:bo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return ge.add(n),n}function Co(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:go(t)};return ge.add(n),n}function Oo(e){return e&&{...e,format:2,versions:yo(e.versions)}}var Y=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...R],G=e=>!["__proto__","constructor","prototype"].includes(e),O=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),se=e=>e===void 0?void 0:structuredClone(e);function Kt(e,t){if(O(e)){if(!O(t)){for(let o of R)delete e[o];return}for(let o of R)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))Kt(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)&&Kt(n,o.get(n.id))}}}function fr(e,t){if(!O(e)||!O(t))return e;for(let[o,n]of Object.entries(e))O(n)&&Kt(n,t[o]);return e}function $t(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)=>$t(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(!R.includes(n)&&!$t(e[n],t[n]))return!1;return!0}function qt(e,t,o){if(!O(e))return e;for(let n of R){let i=D(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??{}))qt(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(c=>O(c)&&typeof c.id=="string").map(c=>[c.id,c])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)O(s)&&typeof s.id=="string"&&qt(s,i.get(s.id),r.get(s.id))}return e}function Ae(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Co(t)}:{}}}var hr=new Int32Array(new SharedArrayBuffer(4)),Ho=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])=>Ho(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 we(e,t,o=5e3,n=Do()){Eo(Uo(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=ao(),c=new Map,a=Date.now()+o;for(;;)try{Eo(i);try{Ro(ke(i,r),s,{flag:"wx"})}catch(l){try{Ge(ke(i,r))}catch{}throw Ye(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=ar(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(lo(ke(i,d[0]),Number(u[1]),c)){Ge(ke(i,d[0])),Ye(i);continue}}else if(d.length===0&&Date.now()-ur(i).mtimeMs>3e4){Ye(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=a)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait(hr,0,0,10)}try{return t()}finally{Ge(ke(i,r)),Ye(i)}}function jo(e){let t;try{t=To(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 Bo(e,t){let o=`${e}.${process.pid}-${Do()}.tmp`;try{let n=_o(o,"wx",384);try{Ro(n,JSON.stringify(t),"utf8"),vo(n)}finally{Po(n)}if(lr(o,e),process.platform!=="win32"){let i=_o(Uo(e),"r");try{vo(i)}finally{Po(i)}}}finally{try{Ge(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function Yt(e){let t;try{t=To(`${e}.config-bak`,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!O(o)||o.version!==1||!O(o.config)||!Array.isArray(o.migrations))throw new Error("Unsupported ledger config backup format");return{version:1,config:o.config,migrations:o.migrations.filter(n=>typeof n=="string")}}function Gt(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=Yt(e)}catch(i){if(i.code)throw i}N(n,o)||Bo(`${e}.config-bak`,o)}function Qe(e,t,o=!1){if(o)try{dr(e,`${e}.pricing-history-v1.bak`,pr.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}Gt(e,t),Bo(e,{...t,pricingHistory:Oo(t.pricingHistory)})}var Wt=()=>Object.fromEntries(Y.map(e=>[e,0]));function No(e,t){for(let o of Y)e[o]=(Number(e[o])||0)+(t[o]??0)}function ce(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!Ho(d)||!Number.isSafeInteger(u)||u<1)throw Error("Invalid metered call identity");if((e.usageCursors?.[d]??0)>=u)return!1;if(e.usageCursors??={},e.usageCursors[d]=u,t.skip)return!0}let{date:o,sessionId:n,atMs:i,providerKey:r,values:s,planId:c}=t;O(e.days[o])||(e.days[o]={date:o,...Wt(),byProviderModel:{},sessions:[]});let a=e.days[o];Array.isArray(a.sessions)||(a.sessions=[]);let l=[a];if(typeof n=="string"&&n.length>0){let d=a.sessions.find(u=>u.id===n);d||(d={id:n,at:i,...Wt(),byProviderModel:{}},a.sessions.push(d)),l.push(d)}for(let d of l){No(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=Wt();No(u,s)}return c!==null&&(e.planHourBuckets=_t(e.planHourBuckets,c,i,st(s),s.cost)),!0}function D(e,t,o,n=!1){if(N(t,e))return se(o);if(N(o,e)||N(t,o))return se(t);if(O(t)&&O(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!G(r))continue;let s=D(e?.[r],t[r],o[r],n&&(O(t[r])||Y.includes(r)||r==="tokens"));s!==void 0&&(i[r]=s)}return i}return n&&typeof t=="number"&&typeof o=="number"?Math.max(0,o+t-(Number(e)||0)):se(t)}var zt=e=>Object.fromEntries((e?.sessions??[]).filter(t=>G(t.id)).map(t=>[t.id,t]));function mr(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!G(i))continue;let r=e[i],s=t[i],c=o[i];if($t(r,s)){c!==void 0&&(n[i]=qt(se(c),r,s));continue}if(!s||!c){s&&(n[i]=se(s));continue}if(N(s,c)){n[i]=se(c);continue}let a=D(r,s,c,!0),l=zt(r),d=zt(s),u=zt(c),m=D(l,d,u,!0),g=(f,y,A)=>Object.fromEntries(Y.map(w=>[w,(A?.[w]??0)+(y?.[w]??0)-(f?.[w]??0)]));Object.assign(a,g(r,s,c)),a.byProviderModel={};for(let f of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(c.byProviderModel??{})]))G(f)&&(a.byProviderModel[f]=g(r?.byProviderModel?.[f],s.byProviderModel?.[f],c.byProviderModel?.[f]));for(let f of Object.keys(d))if(!(!u[f]||N(l[f],d[f])||N(l[f],u[f]))){for(let y of Y)a[y]-=(d[f][y]??0)-(l[f]?.[y]??0)-((m[f]?.[y]??0)-(u[f][y]??0));for(let[y,A]of Object.entries(d[f].byProviderModel??{}))if(!(!G(y)||!a.byProviderModel[y]))for(let w of Y)a.byProviderModel[y][w]-=(A[w]??0)-(l[f]?.byProviderModel?.[y]?.[w]??0)-((m[f]?.byProviderModel?.[y]?.[w]??0)-(u[f].byProviderModel?.[y]?.[w]??0))}for(let f of[a,...Object.values(a.byProviderModel)])for(let y of Y)f[y]=Math.max(0,f[y]);a.sessions=Object.values(m).sort((f,y)=>(f.at??0)-(y.at??0)),n[i]=a}return n}function gr(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(G(r)){i[r]={};for(let s of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!G(s))continue;let c=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),a=D(c(e[r]?.[s]),c(t[r]?.[s]),c(o[r]?.[s]));i[r][s]=Object.values(a).filter(l=>l.t>=n-to).sort((l,d)=>l.t-d.t).slice(-eo)}}return i}function ae(e,t,o,n,i=Date.now(),r=[],s={}){let c=s.ownLocal===!0,a=o!==void 0&&o===e,l=Ae(e),d=a?l:Ae(o??e),u=c?t:Ae(t);fr(l.days,d.days);let m=!N(u.historyReset,l.historyReset),g=!N(d.historyReset,l.historyReset),f=m?u.historyReset:d.historyReset;if(m||g)for(let S of[l,...m?[d]:[u]])S.days={},S.planSamples={},S.planHourBuckets={},S.balanceRef=null;for(let S of n)g&&!m&&S.recordedAt<=(f?.at??0)||(ce(l,S),d!==l&&ce(d,S),g&&!m&&ce(u,S));let y={version:1,writeReceipts:H([...d.writeReceipts??[],...u.writeReceipts??[]]),config:D(l.config,u.config,d.config),days:mr(l.days,u.days,d.days),balanceRef:N(l.balanceRef,u.balanceRef)?d.balanceRef:N(l.balanceRef,d.balanceRef)?u.balanceRef:u.balanceRef==null||d.balanceRef==null?null:(d.balanceRef?.at??0)>(u.balanceRef?.at??0)?d.balanceRef:u.balanceRef,migrations:[...new Set([...d.migrations??[],...u.migrations??[]])],planSamples:gr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:io(D(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:D(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:xo(u.pricingHistory,d.pricingHistory),historyReset:f??null},A=X(u.usageCursors);for(let[S,I]of Object.entries(X(d.usageCursors)))A[S]=Math.max(A[S]??0,I);Object.keys(A).length&&(y.usageCursors=A);let w=D(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);w&&Object.keys(w).length&&(y.providerPriceHashes=w);let M=Object.keys(y.days).sort(),b=Math.max(7,Math.min(3650,Number(y.config.historyDays)||180));for(;M.length>b;)delete y.days[M.shift()];return Z(y.days).includes(y.balanceRef?.date)&&(y.balanceRef=null),br(y,r),y}function br(e,t){let o=(n,i)=>Y.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(oo(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(c=>!o(i.byProviderModel?.[c],r.byProviderModel?.[c]))))for(let c of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!G(c))continue;let a=e.planHourBuckets?.[c]??{},l=Object.fromEntries(Object.entries(a).filter(([u])=>+u>=n.start&&+u<n.end)),d=n.buckets[c]??{};N(l,d)||(e.planHourBuckets[c]={...Object.fromEntries(Object.entries(a).filter(([u])=>+u<n.start||+u>=n.end)),...d},e.planSamples&&delete e.planSamples[c])}}}function Lo(e,t,o){return D(e,t,o)}import{join as zo}from"node:path";var Ko=1,Go=180;function Ar(e){if(typeof e!="string"||e.length>2048||!/^https?:\/\//i.test(e.trim()))return"";try{let t=new URL(e.trim());return t.username||t.password?"":t.href}catch{return""}}function Me(e){try{let t=kr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Qt=["antigravity","claude","codex","kimi","xai","workbuddy"],wr=["sidebar","settings","both","off"],Mr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Ir(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function $o(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function Sr(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 s=t.slice(1,r),c=t.slice(r+1);return!s.includes(":")||!/^[0-9a-f:.]+$/.test(s)?!1:c===""||c.startsWith(":")&&$o(c.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!$o(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 xr(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(c=>typeof c=="string").map(c=>Ir(c)).filter(c=>Qt.includes(c)))]:Qt.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(c=>Sr(c)).map(c=>c.trim().toLowerCase()))].slice(0,16):[],s=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:wr.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:Qt.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function Cr(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 Xt(){return{queryAccounts:{},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:Bn,peakWindows:Ln.map(e=>({...e})),peakHolidays:[...Ue],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,sidebarTextOnly:!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(St.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(St.default),providers:Object.fromEntries(Object.entries(q).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,officialChannelOnly:!1,quickHide:!1,budgetCap:null,reconcile:!0,clickHintSeen:!1},goQuota:{enabled:!0,display:"both",refreshMinutes:15,apiKey:"",main:"rolling",detail:!0},customBalance:{dashboardUrl:"",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:{...Ct},models:{},modelPlans:{}},historyDays:Go,fetchedAt:null,priceSource:"bundled"}}var cl=Object.keys(Xt());function Vt(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Zt(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function Or(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(":"),s=r>=0?n.slice(0,r):n;s.startsWith("llm-")&&(s=s.slice(4)),/^deepseek(?:-official|-account)?$/.test(s)&&(o+=Number(i?.cost)||0)}return o}function Er(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Ve(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=Er(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 qo(e){for(let t of Object.values(e))if(Ve(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))Ve(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>Ve(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))Ve(i)===null&&delete o.byProviderModel[n]}}return e}function Ie(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)?Ie(r,i):i}return o}function le(e){let t=Xt(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(qn),currency:"CNY"});let n=Ie(t,o);n.queryAccounts=un(o.queryAccounts),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&&De(h)!==null).map(([p,h])=>[p,De(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=Ie({},h.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=Ie({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:p,cacheMiss:h,output:k}=t.prices.default;n.prices.default=Ie({cacheHit:p,cacheMiss:h,output:k},r)}let s=p=>{if(p&&typeof p=="object"&&!Oe(p))for(let h of nt)delete p[h]};for(let p of Object.values(n.prices?.providers??{})){s(p);for(let h of Object.values(p?.models??{}))s(h)}for(let p of[...Object.values(n.prices?.models??{}),n.prices?.default])s(p);let c=p=>typeof p=="number"&&Number.isFinite(p),a=(p,h,k)=>typeof p=="string"&&h.includes(p)?p:k;for(let[p,h]of Object.entries(t)){let k=n[p],_=typeof h;_==="boolean"&&typeof k!="boolean"||_==="number"&&!c(k)||_==="string"&&typeof k!="string"?n[p]=h:_==="object"&&h!==null&&k!==null&&typeof k=="object"&&p==="gatewayQuotas"&&Array.isArray(k)||_==="object"&&h!==null&&(k===null||typeof k!="object"||Array.isArray(k)!==Array.isArray(h))&&(n[p]=h)}n.locale=a(n.locale,["auto","zh","en"],"auto"),n.position=a(n.position,["dock","header","off"],"dock"),n.peakStyle=a(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=a(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=a(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=a(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=a(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=a(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=fn(n.modelStatistics);for(let p of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline","sidebarTextOnly"])n[p]=n[p]===!0;n.sessionCostCompact=n.sessionCostCompact===!0,n.contextCostsEnabled=n.contextCostsEnabled===!0,n.contextCostsPromptSeen=n.contextCostsPromptSeen===!0,n.sidebarTodayMetric=a(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=a(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 k=n.sidebarModels?.[p],_={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[p];return[p,_?_.includes(k)?k:h:typeof h=="boolean"?typeof k=="boolean"?k:h:typeof k=="number"&&Number.isFinite(k)?Math.min(p==="topN"?10:60,Math.max(p==="topN"?1:10,Math.floor(k))):h]})),n.sidebarStyle=a(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 l=Number(n.peakAlertAhead);n.peakAlertAhead=Number.isInteger(l)&&l>=1&&l<=30?l:2,n.peakAlertTarget=a(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=a(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=c(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=v(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:"",(!c(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(p=>p!==null&&typeof p=="object"&&c(Number(p.start))&&c(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 d={};if(n.priceOverrides!==null&&typeof n.priceOverrides=="object")for(let[p,h]of Object.entries(n.priceOverrides))typeof p=="string"&&typeof h=="string"&&(d[p]=h);n.priceOverrides=d;let u={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[p,h]of Object.entries(n.priceTableDisplay))typeof p=="string"&&(u[p]=typeof h=="boolean"?h:t.priceTableDisplay[p]===!0);n.priceTableDisplay={...t.priceTableDisplay,...u};let m=n.budget;m.enabled=m.enabled===!0,m.amount=c(m.amount)&&m.amount>=0?m.amount:100,m.period=a(m.period,["day","month","all","custom"],"month"),m.customStart=typeof m.customStart=="string"?m.customStart:null,m.customEnd=typeof m.customEnd=="string"?m.customEnd:null,m.detail=m.detail!==!1;let g=n.balance;g.display=a(g.display,["sidebar","settings","both","off"],"both"),g.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(g.refreshMinutes)||5))),g.showProgressBar===void 0&&(g.showProgressBar=n.customBalance?.showProgressBar!==void 0?n.customBalance.showProgressBar===!0:t.balance.showProgressBar===!0),g.showProgressBar=g.showProgressBar===!0,g.showSource=g.showSource===!0,g.officialChannelOnly=g.officialChannelOnly===!0,g.quickHide=g.quickHide===!0,g.clickHintSeen=g.clickHintSeen===!0,g.reconcile=g.reconcile!==!1;let f=Number(g.budgetCap);g.budgetCap=Number.isFinite(f)&&f>0?f:null;let y=n.goQuota;y.enabled=y.enabled===!0,typeof y.showInComposer!="boolean"&&delete y.showInComposer,y.display=a(y.display,["sidebar","settings","both","off"],"both"),y.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),y.apiKey=typeof y.apiKey=="string"?y.apiKey:"",y.main=a(y.main,["rolling","weekly","monthly"],"rolling"),y.detail=y.detail!==!1;let A=n.customBalance??t.customBalance,w=(p,h)=>{let k=p??{},_={...["aliyun","tokenrhythm"].includes(k.adapter)?{adapter:k.adapter}:{},enabled:k.enabled===!0,display:a(k.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(k.refreshMinutes)||15))),label:typeof k.label=="string"?k.label:h.label,labelEn:typeof k.labelEn=="string"?k.labelEn:h.labelEn,dashboardUrl:Ar(k.dashboardUrl),unit:k.adapter==="tokenrhythm"?"CNY":a(k.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:k.convertToDisplayCurrency===!0,allowInsecureHttp:k.allowInsecureHttp===!0};if(k.request===null||typeof k.request!="object"||Array.isArray(k.request))_.request={...h.request};else{let W={};for(let[B,z]of Object.entries(k.request.headers??{}))typeof B=="string"&&typeof z=="string"&&(W[B]=z);_.request={...h.request,...k.request,url:typeof k.request.url=="string"?k.request.url:"",method:typeof k.request.method=="string"?k.request.method:"GET",headers:{...h.request?.headers??{},...W}}}if(k.extract===null||typeof k.extract!="object"||Array.isArray(k.extract)?_.extract={...h.extract}:_.extract={...h.extract,...k.extract},Array.isArray(k.allowedHosts)){let W=k.allowedHosts.filter(B=>typeof B=="string"&&B.length>0);W.length>0&&(_.allowedHosts=W)}return _},M=w(A,t.customBalance);n.customBalance=M;let b=n.gatewayQuotas,S=Array.isArray(b)?b:b!==null&&typeof b=="object"&&Array.isArray(b.sources)?b.sources:[],I=[],x=new Set;for(let p of S.slice(0,4)){let h=xr(p);!Mr.test(h.id)||x.has(h.id)||h.type!=="cliproxyapi"||!Cr(h.baseURL)||(x.add(h.id),I.push(h))}n.gatewayQuotas={sources:I};let E=n.customBalances;Array.isArray(E)||(E=[]);let ue=t.customBalances?.[0]??t.customBalance,j=E.slice(0,8).map(p=>w(p,ue)),xe=M.enabled===!0||typeof M.request?.url=="string"&&M.request.url.length>0;j.length===0&&xe&&j.push(M),n.customBalances=j;let Q=n.corner;for(let p of["enabled","goRolling","goWeekly","goMonthly","budget"])Q[p]=Q[p]===!0||Q[p]!==!1&&p!=="enabled";let te=n.quotaStrip;te.enabled=te.enabled===!0,te.promptSeen=te.promptSeen===!0;for(let p of["budget","go","plans"])te[p]=te[p]!==!1;let Ce=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:Ce.balance==="used"?"used":"remaining",budget:Ce.budget==="remaining"?"remaining":"used",go:Ce.go==="remaining"?"remaining":"used",plan:Ce.plan==="remaining"?"remaining":"used"};let C={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[p,h]of Object.entries(n.codingPlans))if(!(!pe.includes(p)||h===null||typeof h!="object"||Array.isArray(h))){if(C[p]={enabled:h.enabled===!0,...typeof h.showInComposer=="boolean"?{showInComposer:h.showInComposer}:{},display:a(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 k=Nn(h.baseUrl);C[p].baseUrl=k??"",k===null&&(C[p].enabled=!1)}if(p==="workbuddy"&&(h.accountSource!==void 0&&(C[p].accountSource=a(h.accountSource,["auto","connect","xdpool"],"auto")),C[p].accountScope=a(h.accountScope,["current","all","selected"],"current"),C[p].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(dt))].slice(0,400):[]),p==="opendesign"){let k=Sn(h.workspaceId);C[p].workspaceId=k??"",k===null&&(C[p].enabled=!1)}if(p==="factory"){let k=In(h.orgId);C[p].orgId=k??"",k===null&&(C[p].enabled=!1),C[p].factoryPool=a(h.factoryPool,["standard","core","both"],"standard")}if(p==="scnet"){let k=Number(h.planCredits);C[p].planCredits=Number.isFinite(k)&&k>0?k:24e4,C[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:""}if(p==="qwen"){C[p].quotaSource=h.quotaSource==="cli"||h.quotaSource==="bailian"?h.quotaSource:"local";let k=Number(h.planCredits);C[p].planCredits=Number.isFinite(k)&&k>0?k:5e5,C[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:"";let _=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},W={};for(let[B,z]of Object.entries(_)){if(typeof B!="string"||B.length===0||z===null||typeof z!="object")continue;let et=ti=>{let tt=Number(ti);return Number.isFinite(tt)&&tt>0?tt:null},nn=et(z.input),on=et(z.cachedInput),rn=et(z.output);nn===null||on===null||rn===null||(W[B]={input:nn,cachedInput:on,output:rn})}C[p].rates=W}if(p==="volcengine"){let k=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",_=typeof h.apiKey=="string"?h.apiKey.trim():"";C[p].accessKeyId=k.length>0?k:_,C[p].secretAccessKey=typeof h.secretAccessKey=="string"?h.secretAccessKey:"",C[p].accessKeyId.length>0&&C[p].apiKey!==C[p].accessKeyId&&(C[p].apiKey=C[p].accessKeyId)}}}n.codingPlans=C;let Xe={};for(let p of J){let h=n.planBilling?.providers?.[p];Xe[p]=["auto","plan","api"].includes(h)?h:Ct[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)&&(Xe[p]=h);let tn={};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")&&(tn[p]=h);let Xo=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([p,h])=>p.includes(":")&&J.includes(h))),ei=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(p=>J.includes(p)):[...He(n)])];return n.planBilling={providers:Xe,models:tn,modelPlans:Xo,autoProviders:ei},n}var _r={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.baidu-coding":"BAIDU_QIANFAN_COOKIE","codingPlans.factory":"FACTORY_API_KEY"},al=Object.keys(_r);function Yo(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,s]of Object.entries(o))ct(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function Jt(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=Yo(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(Yo)),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 Ze=[{id:"provider-catalog-2026-10-03",apply:he},{id:"provider-catalog-2026-10-15",apply:Wn},{id:"provider-catalog-2026-10-28",apply:zn},{id:"stepfun-catalog-2026-10-16",apply:Kn},{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")}}],Je=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=ye(r.pricingHistory,t),this.config=t,ln(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??kn,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(s=>typeof s=="string"):[],this.secretMigration={ran:!1,pending:[]},this.planSamples=r.planSamples??{},this.planHourBuckets=r.planHourBuckets??{},this.openrouterPriceHashes=Object.fromEntries(Object.entries(r.openrouterPriceHashes??{}).filter(([s,c])=>!["__proto__","constructor","prototype"].includes(s)&&typeof c=="string"&&/^[a-f0-9]{64}$/.test(c))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([s,c])=>s.startsWith("opendesign:")&&typeof c=="string"&&/^[a-f0-9]{64}$/.test(c))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&qe(this.pricingHistory,t),this._config=So(t,this.pricingHistory)}static open(){let t=zo(ut(),"storages","cost-meter"),o=zo(t,"ledger.json");return we(o,()=>e.load(o))}static load(t){let o=Xt(),n={},i=null,r=[...Ze.map(b=>b.id),"quota-token-window-v2"],s={},c={},a={},l={},d=null,u={},m=[],g,f=!1,y=!1,A=!1;try{let b=JSON.parse(yr(t,"utf8"));if(b===null||typeof b!="object"||Array.isArray(b))throw new Error("Unsupported ledger format");if(b!==null&&typeof b=="object")if(b.version!==Ko){try{Fo(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(b.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=b.historyReset??null,u=X(b.usageCursors),m=H(b.writeReceipts);let S=typeof b.config=="object"&&b.config!==null?b.config:{};g=ye(b.pricingHistory,le(S),void 0,!0),f=!!b.pricingHistory&&b.pricingHistory.format!==2,r=Array.isArray(b.migrations)?b.migrations.filter(E=>typeof E=="string"):[];let I=new Set(r);for(let E of Ze)I.has(E.id)||(E.apply(S),r.push(E.id));o=le(S),b.openrouterPriceHashes&&typeof b.openrouterPriceHashes=="object"&&!Array.isArray(b.openrouterPriceHashes)&&(a=b.openrouterPriceHashes),b.providerPriceHashes&&typeof b.providerPriceHashes=="object"&&!Array.isArray(b.providerPriceHashes)&&(l=b.providerPriceHashes),b.days!==null&&typeof b.days=="object"&&!Array.isArray(b.days)&&(n=qo(b.days));let x=b.balanceRef;x!==null&&typeof x=="object"&&typeof x.date=="string"&&Number.isFinite(x.total)&&Number.isFinite(x.granted)&&Number.isFinite(x.topped)&&(i={date:x.date,total:x.total,granted:x.granted,topped:x.topped,currency:typeof x.currency=="string"?x.currency:void 0,at:Number(x.at)||0,ledgerCost:Number.isFinite(x.ledgerCost)&&x.ledgerCost>=0?x.ledgerCost:void 0}),b.planSamples!==null&&typeof b.planSamples=="object"&&!Array.isArray(b.planSamples)&&(s=b.planSamples),b.planHourBuckets!==null&&typeof b.planHourBuckets=="object"&&!Array.isArray(b.planHourBuckets)?c=b.planHourBuckets:Array.isArray(b.planRecentCalls)&&(c=vt(b.planRecentCalls)),y=!0}}catch(b){if(b?.code!=="ENOENT"){try{Fo(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(b?.message??b)}`)}}if(y)try{Gt(t,{config:Jt(o),migrations:r})}catch(b){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u5199\u5165\u5931\u8D25\uFF08${b?.code??"write error"}\uFF09`)}else try{let b=Yt(t);if(b){let S=b.config;r=b.migrations;for(let I of Ze)r.includes(I.id)||(I.apply(S),r.push(I.id));o=le(S),A=!0,console.warn(`[dsh-cost-meter] \u5DF2\u4ECE\u72EC\u7ACB\u5907\u4EFD\u6062\u590D\u914D\u7F6E\uFF0C\u81EA\u5B9A\u4E49\u4F59\u989D\u6E90 ${o.customBalances.length} \u6761`)}}catch(b){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u4E0D\u53EF\u7528\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\uFF08${b?.code??"invalid format"}\uFF09`)}let w=new e(o,n,t,r,{planSamples:s,planHourBuckets:c,openrouterPriceHashes:a,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:m,pricingHistory:g});w.legacyPricingHistory=f,w.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),w.quotaStatsNeedRepair&&(w.planSamples={}),(f||A)&&w.scheduleWrite();let M=Z(w.days);return M.length&&(M.includes(w.balanceRef?.date)&&(w.balanceRef=null),w.scheduleWrite()),w}account(t,o,n,i,r,s,c){if(this.closed)return;if(c!==void 0&&(!bn(c,i)||r!=="deepseek-official"||!gn(o,c)))throw new Error("Invalid official web request fee");let a=Ft(this.config,i,n,`${r||"deepseek"}:${o}`),l=Qn(r,o,a.prices,{mode:a.priceMatch==="exact"?"exact":"auto",overrides:a.priceOverrides}),d=l.entry??{cacheHit:0,cacheMiss:0,output:0},u={enabled:["deepseek-peak","utc-peak"].includes(l.billingMode)&&a.peakEnabled===!0,effectiveAtMs:Date.parse(a.peakEffectiveAt),windows:a.peakWindows,holidays:a.peakHolidays},m=c?c.requests*c.rateCny:l.priced?Vn(t,d,i,u):0,g=Zn(m,c?"CNY":l.currency,v(a).CNY),f=this.config.planBilling,y=He(this.config),A=c?"api":no(r,o,f,y,this.config.prices),w=A==="api"?g:0,M=x=>{let E=Number(x);return Number.isFinite(E)&&E>0?E:0},b={input:M(t?.input),output:M(t?.output),cacheRead:M(t?.cacheRead),cacheWrite:M(t?.cacheWrite),reasoning:M(t?.reasoning)},S=A==="plan"?Ot(r,f,o)??(Et(r,o,this.config.prices)?"go":null):null,I={...s?{meter:s}:{},date:Vt(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:S,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...b,calls:1,cost:g,apiCost:w,...ot(g,w,a)}};return ce(this,I)?(this.pendingAccounts.push(I),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};ce(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||Go)),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 Ae({version:Ko,config:Jt(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:Wo(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Me(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=jo(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=ye(o.pricingHistory,le(o.config),this.pricingHistory,!0);for(let i of Ze)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:Jt(le(o.config)),days:qo(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??vt(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=ye(t.pricingHistory,t.config),this.config=le(Lo(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){Me(this.path)!==this.diskRevision?this.flush():this.flushAsync();return}try{let t=Me(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(ae(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{we(this.path,()=>{qe(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=Z(n.days);i.includes(n.balanceRef?.date)&&(n.balanceRef=null);let r=(o===null||o===this.writeBase)&&!this.pendingPlanHourRepairs.length&&!i.length,s=r?n:ae(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});Qe(this.path,s,this.legacyPricingHistory),this.legacyPricingHistory=!1,r||this.adoptSnapshot(s),this.writeBase=r?s:this.snapshot(),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.pendingWrite=!1,this.diskRevision=Me(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();qe(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,c=Wo();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:c,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},a=>{if(this.backgroundWrite=null,a.error){let u;try{u=this.readDiskSnapshot()}catch{}if(H(u?.writeReceipts).includes(c))a={merged:u,revision:Me(this.path)};else{a.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(a.error);return}}let l=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(a.ownDisk)this.writeReceipts=H(a.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=ae(t,this.snapshot(),a.merged,l,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(u),this.writeBase=a.merged}this.pendingAccounts=l,this.pendingPlanHourRepairs=d,this.pendingWrite=s!==this.writeGeneration||l.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=a.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(a){return this.fallbackWrite(a),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=Zt(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,de(o,i),o.cost+=i.cost??0,o.apiCost=(o.apiCost??0)+(i.apiCost??i.cost??0);for(let[r,s]of Object.entries(i.byProviderModel??{})){let c=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={...de({...Ee(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 o.date=t===void 0?"total":t,o}sumRange(t,o){let n=Zt(`${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,de(n,r),n.cost+=r.cost??0,n.apiCost=(n.apiCost??0)+(r.apiCost??r.cost??0);for(let[s,c]of Object.entries(r.byProviderModel??{})){let a=n.byProviderModel[s]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[s]={...de({...Ee(a)},c),input:a.input+(c.input??0),output:a.output+(c.output??0),cacheRead:a.cacheRead+(c.cacheRead??0),cacheWrite:a.cacheWrite+(c.cacheWrite??0),reasoning:a.reasoning+(c.reasoning??0),calls:a.calls+(c.calls??0),cost:a.cost+(c.cost??0),apiCost:(a.apiCost??0)+(c.apiCost??c.cost??0)}}}return n}today(){let t=Vt(Date.now()),o=this.days[t];return o===void 0?Zt(t):this.copyDay(o)}todayOfficialCost(){return Or(this.days[Vt(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{...Ee(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 Qo=e=>{try{let t=Pr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:Se,base:Vo,local:ee,pending:Nr,repairs:Zo,revision:Rr,backupHistory:Tr,transactionId:Ur,now:Dr,port:en,signal:Jo,lockId:Hr}=vr;try{let e=we(Se,()=>{let t=Qo(Se)===Rr,o=Z(ee.days);o.includes(ee.balanceRef?.date)&&(ee.balanceRef=null);let n=t&&!Zo.length&&!o.length,i=ee;if(!n){let r=new Je(ee.config,{},Se,[],{pricingHistory:ee.pricingHistory});r.writeBase=Vo,i=ae(Vo,ee,r.readDiskSnapshot(),Nr,Dr,Zo,{ownLocal:!0})}return i.writeReceipts=H([...i.writeReceipts??[],Ur]),Qe(Se,i,Tr),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Qo(Se)}},5e3,Hr);en.postMessage(e)}catch(e){en.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Jo,0,1),Atomics.notify(Jo,0),en.close()}
2
+ import{workerData as vr}from"node:worker_threads";import{statSync as Pr}from"node:fs";var nt=["peakWindows","peakHolidays","peakSchedule"];function V(e){return Object.fromEntries(nt.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Oe(e){return!(!e||typeof e!="object"||e.peakWindows!==void 0&&(!Array.isArray(e.peakWindows)||e.peakWindows.length>24||e.peakWindows.some(t=>!t||!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<0||t.start>=24||t.end<0||t.end>24||t.start===t.end))||e.peakSchedule!==void 0&&!["deepseek","volcengine","ollama","daily","utc-weekdays"].includes(e.peakSchedule)||e.peakHolidays!==void 0&&e.peakHolidays!==null&&(!Array.isArray(e.peakHolidays)||e.peakHolidays.length>366||e.peakHolidays.some(t=>typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t)||!Number.isFinite(Date.parse(t+"T00:00:00Z"))||new Date(t+"T00:00:00Z").toISOString().slice(0,10)!==t)))}function sn(e,t,o){if(!e?.entry)return e;let n=o?.providers?.[t]??(["deepseek-official","deepseek-account",""].includes(t)?o?.providers?.deepseek:void 0),i={...V(n),...e.entry};return{...e,entry:i,billingMode:(i.peak||i.offPeak)&&Object.keys(V(i)).length&&i.billingMode!=="flat"?"deepseek-peak":e.billingMode}}function cn(e,t,o){if(!(e.peakWindows!==void 0||e.peakHolidays!==void 0||["daily","utc-weekdays","deepseek"].includes(e.peakSchedule)))return null;if(o?.enabled!==!0||!Number.isFinite(t)||Number.isFinite(o.effectiveAtMs)&&t<o.effectiveAtMs)return"base";let i=e.peakSchedule??(e.billingMode==="utc-peak"?"utc-weekdays":"deepseek"),r=e.peakWindows??(i==="ollama"?[{start:12,end:18}]:o.windows??[]),s=e.peakHolidays===null?[]:e.peakHolidays??(["ollama","volcengine","utc-weekdays","daily"].includes(i)?[]:o.holidays??[]),c=new Date(t+8*36e5),a=new Date(t),l=["ollama","utc-weekdays"].includes(i)?a.getUTCDay():c.getUTCDay();if(i!=="daily"&&(l===0||l===6)||s.includes(c.toISOString().slice(0,10)))return"offPeak";let d=a.getUTCHours()+a.getUTCMinutes()/60+a.getUTCSeconds()/3600+a.getUTCMilliseconds()/36e5;return r.some(u=>u.start<u.end?d>=u.start&&d<u.end:d>=u.start||d<u.end)?"peak":"offPeak"}var R=["costCny","apiCostCny","costEur","apiCostEur"],an=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function v(e={}){let t={USD:1,CNY:7.2,EUR:.92};for(let o of["CNY","EUR"])an(e.fxRates?.[o])&&(t[o]=e.fxRates[o]);return["CNY","EUR"].includes(e.currency)&&an(e.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function ot(e,t,o){let n=v(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Ee(e){return Object.fromEntries(R.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function de(e,t,o=1){for(let n of R)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function ln(e,t){let o=n=>{let i=ot(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of R)(!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 ni=["balance","goQuota",...["opendesign","anthropic","zai","minimax","kimi","openrouter","siliconflow","commandcode","clinepass","volcengine","mimo","baidu-coding","factory"].map(e=>"codingPlans."+e)],it=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),oi=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",ii=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function un(e){let t={};if(!it(e))return t;for(let o of ni){let n=e[o];if(!it(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!it(s)||!oi(s.id)||!ii(s.label)||i.has(s.id)?!1:(i.add(s.id),!0)).slice(0,10).map(({id:s,label:c})=>({id:s,label:c.trim()}));t[o]={selected:r.some(s=>s.id===n.selected)?n.selected:"default",accounts:r}}return t}var dn=["today","summary","budget"],pn=e=>e&&typeof e=="object"&&!Array.isArray(e);function fn(e){return pn(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&pn(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(dn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>dn.some(o=>!t[o]))):{}}import{readFileSync as yr,renameSync as Fo,statSync as kr}from"node:fs";import{randomUUID as Wo}from"node:crypto";var hn=5/1e3,ri=Date.parse("2026-11-01T00:00:00+08:00"),mn=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function gn(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 bn(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<ri?0:hn):e.source===void 0&&e.rateCny===hn}var rt=["input","output","cacheRead","cacheWrite","reasoning","calls"],L=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function Z(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,s=R.filter(u=>i.every(m=>L(m?.[u]))),c=Object.fromEntries([...rt,"cost","apiCost",...s].map(u=>[u,0])),a=new Map,l=!0;for(let u of i){if(!u?.id||r.has(u.id)){l=!1;break}r.add(u.id);for(let m of Object.keys(c)){let g=m==="apiCost"?u.apiCost??u.cost:u[m]??0;if(!L(g)){l=!1;break}c[m]+=g}if(!l||c.apiCost>c.cost+1e-8){l=!1;break}for(let[m,g]of Object.entries(u.byProviderModel??{})){if(a.has(m)&&a.get(m)===null)continue;let f=a.get(m)??Object.fromEntries(Object.keys(c).map(A=>[A,0])),y=g!==null&&typeof g=="object";for(let A of Object.keys(f)){if(R.includes(A)&&!L(g?.[A])){delete f[A];continue}let w=A==="apiCost"?g?.apiCost??g?.cost:g?.[A]??0;if(!L(w)){y=!1;break}f[A]+=w}a.set(m,y?f:null)}}if(!l||!Object.values(c).every(L)||!rt.every(u=>L(n[u]??0)&&c[u]===(n[u]??0)))continue;let d=Math.abs(c.cost-(n.cost??0))>1e-8||Math.abs(c.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=c.cost,n.apiCost=c.apiCost);for(let u of s)Math.abs(c[u]-(n[u]??0))>1e-8&&(n[u]=c[u],d=!0);for(let[u,m]of a){let g=n.byProviderModel?.[u];if(!(!m||!g||!m.calls||!Object.values(m).every(L)||!rt.every(f=>m[f]===(g[f]??0)))&&!(Math.abs(m.cost-(g.cost??0))<=1e-8&&Math.abs(m.apiCost-(g.apiCost??g.cost??0))<=1e-8&&s.every(f=>!L(m[f])||Math.abs(m[f]-(g[f]??0))<=1e-8))){for(let f of s)L(m[f])&&(g[f]=m[f]);g.cost=m.cost,g.apiCost=m.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as si,MessageChannel as ci,receiveMessageOnPort as yn}from"node:worker_threads";import{randomUUID as ai}from"node:crypto";import{unlinkSync as li,rmdirSync as ui}from"node:fs";import{join as di}from"node:path";function kn(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new ci,s=new Int32Array(new SharedArrayBuffer(4)),c=!1,a,l,d,u=ai(),m=new Promise(A=>{a=A}),g=new si(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),f=A=>{if(!c){c=!0,clearTimeout(y);try{t(A)}finally{i.close(),g.terminate(),a()}}},y=setTimeout(()=>{l={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},g.terminate().then(()=>f(l))},o);return y.unref?.(),i.on("message",f),g.on("error",A=>{d={error:{message:A.message,code:A.code}}}),g.on("exit",A=>{if(!c){try{li(di(`${e.path}.lock`,`${process.pid}-${u}`)),ui(`${e.path}.lock`)}catch{}f(yn(i)?.message??l??d??{error:{message:`Ledger worker exited (${A})`}})}}),{promise:m,wait(A=8e3){let w=Date.now()+A;for(;!c;){let M=yn(i);if(M){f(M.message);break}if(Date.now()>=w)return!1;Atomics.wait(s,0,0,Math.min(50,w-Date.now()))}return!0}}}function st(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 Eo,readdirSync as ar,writeFileSync as Ro,readFileSync as To,renameSync as lr,unlinkSync as Ge,rmdirSync as Ye,statSync as ur,copyFileSync as dr,openSync as _o,fsyncSync as vo,closeSync as Po,constants as pr}from"node:fs";import{dirname as Uo,join as ke}from"node:path";import{randomUUID as Do}from"node:crypto";import{isDeepStrictEqual as N}from"node:util";var An=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,pi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,fi=/^(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 ct(e,t){if(typeof t!="string"||t.length===0)return!1;if(An.test(t)){let n=t.replace(new RegExp(An.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(pi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||fi.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var wn="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var Mn="https://api.factory.ai/api/billing/limits";var In=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 _e="https://amr-api.open-design.ai/api/v1",is=_e+"/public/model-prices",at=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],rs=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var hi=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function Sn(e){return e===void 0||e===""?"":typeof e=="string"&&hi(e.trim())?e.trim():null}import{homedir as lt}from"node:os";import{basename as ls,dirname as us,join as xn,resolve as mi}from"node:path";var Cn=".dsh",ds=`~/${Cn}`,gi="DSH_HOME",bi=".agents",ps=`~/${bi}`;function yi(){return xn(lt(),Cn)}function ki(e){return e==="~"?lt():e.startsWith("~/")||e.startsWith("~\\")?xn(lt(),e.slice(2)):e}function Ai(e,t,o,n){let i=t[o];return mi(ki(e??(i!==void 0&&i.trim().length>0?i:n())))}function ut(e,t=process.env){return Ai(e,t,gi,yi)}var dt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var Ii=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var Us=672*60*60,Ds=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"}),Gs=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 Si={opendesign:{label:"OpenDesign",credentialEnvs:["OPENDESIGN_CONTROL_KEY","VELA_CONTROL_KEY","OPENDESIGN_COOKIE"],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 M Plan / Token Plan",credentialEnvs:["MINIMAX_API_KEY"],keyHint:"MiniMax API Key(sk-* / sk-cp-*)"},kimi:{label:"Kimi Code / 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"},"baidu-coding":{label:"\u767E\u5EA6\u5343\u5E06 Token Plan",credentialEnvs:["BAIDU_QIANFAN_COOKIE"],keyHint:"\u767E\u5EA6\u667A\u80FD\u4E91\u63A7\u5236\u53F0 Cookie (console.bce.baidu.com)"},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"}},pe=Object.keys(Si);var ft="https://platform.xiaomimimo.com/api/v1",xi={usage:`${ft}/tokenPlan/usage`,detail:`${ft}/tokenPlan/detail`,balance:`${ft}/balance`},En=["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"];var Ci="open.volcengineapi.com";var Oi="2024-01-01",Ei=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var _i={"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 _n(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var vc=Object.fromEntries(Object.entries(_i).map(([e,t])=>[_n(e),t]));var vn=["scnet","scnet-tokenplan","scnet-token-plan"];var vi={"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}},Pc=Object.fromEntries(Object.entries(vi).map(([e,t])=>[_n(e),t])),Pn=["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"];var Nc={opendesign:[_e+"/workspaces/{workspaceId}/billing/preflight",_e+"/workspaces/{workspaceId}/wallet/balance"],factory:[Mn],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:Ei.map(e=>`https://${Ci}/?Action=${e}&Version=${Oi}`),mimo:[xi.usage],"baidu-coding":[wn],workbuddy:[]};function Nn(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 ht=/^(base|offPeak|peak|legacyBase|longContext|cny)\.(cacheHit|cacheMiss|cacheWrite|output|reasoning)$/;function ve(e){return Object.fromEntries(["multiplier","separateMultipliers","multipliers"].filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Rn(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function mt(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*Rn(t,o+"."+i));return e.longContext&&(n.longContext={...mt(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function Tn(e){let t=ve(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 gt(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])=>!ht.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]*Rn(e,n+"."+r)))return!1}}return!0}var bt={"opencode-zen":{models:{"glm-5.3-flash-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"beam-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"flint-40b-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"nemotron-3.5-super-vl-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28",input:3,output:15,cachedInput:.3,cacheWrite:3},"muse-wonder-1.0":{billingMode:"flat",input:4,output:20,cachedInput:.2,sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"},"gpt-6.1-sol":{input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5},billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/models/",checkedAt:"2026-10-28"}}},"opencode-go":{models:{"kimi-k3.1-pro":{billingMode:"flat",input:2,output:10,cachedInput:.2,cacheWrite:2,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28",input:3,output:15,cachedInput:.3,cacheWrite:3},"step-5-preview":{billingMode:"flat",input:1,output:2.7,cachedInput:.1,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"beam-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"iceman-contributor-free":{billingMode:"flat",input:0,output:0,cachedInput:0,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"minimax-m3.1-flash":{billingMode:"flat",input:.15,output:.6,cachedInput:.015,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28"},"gemini-4-argon":{billingMode:"flat",input:2,output:10,cachedInput:.1,sourceUrl:"https://opencode.ai/v2/docs/console/go/",checkedAt:"2026-10-28",notes:"OpenCode Go promotional price through 2026-11-30. USD 2/10/0.1 per MTok; independent of the direct API."}}},moonshot:{models:{"kimi-k3.1-pro":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:2,cny:{cacheMiss:13,cacheHit:1.3,cacheWrite:13,output:68},notes:"Kimi API official USD quote and China CNY quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing. Default 5m cache writes; 1h cache write is USD 4 / CNY 26 per MTok. 1M context uses the same rate."},"kimi-k3.1-pro-highspeed":{input:4,cachedInput:.2,output:20,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:4,cny:{cacheMiss:26,cacheHit:1.3,cacheWrite:26,output:136},notes:"Kimi API Highspeed. Default 5m cache writes; 1h cache write is USD 8 / CNY 52 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"kimi-k3":{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://platform.kimi.ai/docs/pricing/chat",checkedAt:"2026-10-28",cacheWrite:3,cny:{cacheMiss:20,cacheHit:2,cacheWrite:20,output:100},notes:"Default 5m cache writes. 1h cache write is USD 6 / CNY 40 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"k3.1-pro":{input:2,cachedInput:.2,output:10,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:2,cny:{cacheMiss:13,cacheHit:1.3,cacheWrite:13,output:68},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Kimi API official USD quote and China CNY quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing. Default 5m cache writes; 1h cache write is USD 4 / CNY 26 per MTok. 1M context uses the same rate."},"k3.1-pro-highspeed":{input:4,cachedInput:.2,output:20,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:4,cny:{cacheMiss:26,cacheHit:1.3,cacheWrite:26,output:136},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Kimi API Highspeed. Default 5m cache writes; 1h cache write is USD 8 / CNY 52 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},k3:{input:3,cachedInput:.3,output:15,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",cacheWrite:3,cny:{cacheMiss:20,cacheHit:2,cacheWrite:20,output:100},notes:"Kimi Code model ID; direct Kimi API price is a token-equivalent reference. Subscription quota comes from the usage API. Default 5m cache writes. 1h cache write is USD 6 / CNY 40 per MTok. China quote: https://www.kimi.com/resources/kimi-k3-1-pro-pricing"},"k3-256k":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code 256K subscription model. No separate direct API token-equivalent quote."},"kimi-for-coding":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code currently routes this ID to K2.8 Preview. No published direct API quote."},"kimi-for-coding-highspeed":{unpriced:!0,billingMode:"flat",sourceUrl:"https://www.kimi.com/code/docs/kimi-code/models.html",checkedAt:"2026-10-28",notes:"Kimi Code K2.7 Code Highspeed subscription ID. Quota usage is queried separately."}}},minimax:{models:{"minimax-m3.1-flash":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://platform.minimax.io/docs/pricing/overview",checkedAt:"2026-10-28",cny:{cacheMiss:1,cacheHit:.1,output:4},notes:"MiniMax M3.1 Flash Standard API. China CNY quote: https://platform.minimax.cn/docs/pricing/overview . M3.1 Flash Preview is retired and requests are served by M3.1 Flash."},"minimax-m3.1-flash-preview":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://platform.minimax.io/docs/pricing/overview",checkedAt:"2026-10-28",cny:{cacheMiss:1,cacheHit:.1,output:4},notes:"MiniMax M3.1 Flash Standard API. China CNY quote: https://platform.minimax.cn/docs/pricing/overview . M3.1 Flash Preview is retired and requests are served by M3.1 Flash."}}},tencent:{models:{"hy4-preview":{input:.834,cachedInput:.042,output:2.501,billingMode:"flat",sourceUrl:"https://intl.cloud.tencent.com/document/product/1300/78937",checkedAt:"2026-10-28",notes:"TokenHub Singapore published USD rate. Regional rates and Token Plan credits are separate."}}},alibaba:{models:{"qwen3.8-flash":{input:.15,cachedInput:.016,output:.47,cacheWrite:.2,billingMode:"flat",sourceUrl:"https://www.alibabacloud.com/help/en/model-studio/model-pricing",checkedAt:"2026-10-28",notes:"Singapore International USD quote, including explicit and implicit cache prices: https://www.alibabacloud.com/help/en/model-studio/qwen3-8-flash . Mainland and global deployment rates differ."}}}};bt.openrouter={models:{"moonshotai/kimi-k3.1-pro":{input:2,output:10,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.2,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"minimax/minimax-m3.1-flash":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.015,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"nvidia/nemotron-3.5-super-vl":{input:.15,output:.5,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.02,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"nvidia/nemotron-3.5-super-vl:free":{input:0,output:0,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."},"meta/muse-wonder":{input:4,output:20,billingMode:"flat",sourceUrl:"https://openrouter.ai/api/v1/models",checkedAt:"2026-10-28",cachedInput:.2,notes:"OpenRouter public model-list token quote checked 2026-10-28. Endpoint-specific tool fees are separate."}}};var yt={"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 Pi="https://platform.stepfun.ai/docs/en/guides/pricing/details",fe=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:Pi,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."}),Un={models:{"step-5-preview":fe(1,.1,2.7),"step-3.7-flash":fe(.2,.04,1.15),"step-3.5-flash":fe(.1,.02,.3),"step-3.5-flash-2603":fe(.1,.02,.3),"step-1o-turbo-vision":fe(.36,.07,1.15)}};var Pe={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}}}}},ne=Object.fromEntries([...new Set([...Object.keys(Pe),...Object.keys(yt)])].map(e=>[e,{models:{...Pe[e]?.models,...yt[e]?.models}}]));ne.stepfun=Un;var Dn=structuredClone(ne);for(let[e,t]of Object.entries(bt))ne[e]={models:{...ne[e]?.models,...t.models}};var Hn={"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 Bn="2026-08-01T00:00:00Z",It="2026-08-22T16:00:00Z",Ue=["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"],kt="2026-09-10T04:00:00Z",Ni="2026-08-31T00:00:00Z",jn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Ri(e){if(!Number.isFinite(e)||e<Date.parse(It))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(It)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ti(e,t=Ue){if(!Number.isFinite(e)||e<Date.parse(It)||!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 Ui=(e,t)=>Ti(e,t)??Ri(e),Di="2026-08-16T16:00:00Z";var Ln=[{start:1,end:4},{start:6,end:10}],ie={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"}}}},Fn=Object.freeze(Object.keys(ie["opencode-go"].models)),q={...ie};q.opendesign={models:Hn};for(let[e,t]of Object.entries(ne)){let o=ie[e]?.models??{};q[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function he(e,t=ie){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(q)){if(["__proto__","constructor","prototype"].includes(n))continue;let r=t[n]?.models??{},s=Object.hasOwn(o,n)?o[n]?.models:null;if(!s||typeof s!="object"||Array.isArray(s)){Object.hasOwn(o,n)||(o[n]=structuredClone(i));continue}for(let[c,a]of Object.entries(i.models)){if(!Object.hasOwn(s,c)){Object.hasOwn(r,c)||(s[c]=structuredClone(a));continue}let l=new Set(["input","cacheMiss","cachedInput","cacheHit","cacheRead","cacheWrite","output","reasoning","cny","longContext","legacy","billingMode","sourceUrl","checkedAt","notes","offPeak","peak","legacyBase","rateHistory","unpriced"]);if(s[c]&&Object.keys(s[c]).some(m=>!l.has(m)))continue;let d=P(r[c]),u=P(s[c]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[c]=structuredClone(a))}}}function Wn(e){let t=Object.fromEntries(Object.keys(q).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ie[o]?.models,...Pe[o]?.models}}]));he(e,t)}function zn(e){let t=Object.fromEntries(Object.keys(q).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:ie[o]?.models,...Dn[o]?.models}}]));he(e,t)}function Kn(e){he(e,Object.fromEntries(Object.entries(q).filter(([t])=>t!=="stepfun")))}var Hi={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}}},ji={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 At(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,s])=>[r,s*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"?ji:Hi,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):At(i,e,kt)]));return o["deepseek-v4.1-flash"]=At(t.models["deepseek-v4-flash-vision-exp"],e,kt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:At(t.default,e,kt)}}var St=$n("USD"),qn=$n("CNY");function Yn(e,t=Date.now()){if(!e||!Number.isFinite(t)||!Array.isArray(e.rateHistory))return e;let o=null,n=1/0;for(let s of e.rateHistory){let c=Date.parse(s.before);t<c&&c<n&&(o=s,n=c)}if(!o)return e;let{before:i,...r}=o;return{...e,...r}}function $(e){if(e===null||typeof e!="object"||Array.isArray(e))return;let t=c=>{let a=e[c];return typeof a=="number"&&Number.isFinite(a)&&a>=0?a:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),s=t("cacheWrite");return{cacheHit:n,cacheMiss:o,output:i,...r===void 0?{}:{reasoning:r},...s===void 0?{}:{cacheWrite:s}}}function P(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e.unpriced===!0){let s={unpriced:!0};for(let c of["billingMode","sourceUrl","checkedAt","notes"])typeof e[c]=="string"&&(s[c]=e[c]);return s}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e)||!Oe(e))return null;let t={...$(e),...V(e)},o=s=>typeof s=="number"&&Number.isFinite(s)&&s>=0;if(e.cacheWrite!==void 0&&!o(e.cacheWrite))return null;if(e.longContext!==void 0){let s=e.longContext;if(!s||typeof s!="object"||Array.isArray(s)||!o(s.aboveInputTokens)||s.aboveInputTokens===0||!["cacheMiss","cacheHit","output"].every(c=>o(s[c]))||s.cacheWrite!==void 0&&!o(s.cacheWrite))return null;t.longContext={aboveInputTokens:s.aboveInputTokens,...$(s)}}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 s of["sourceUrl","checkedAt","notes"])typeof e[s]=="string"&&(t[s]=e[s]);if(e.cny!==void 0){if(!e.cny||typeof e.cny!="object"||Array.isArray(e.cny)||!["cacheHit","cacheMiss","output"].every(s=>o(e.cny[s])))return null;t.cny=$(e.cny)}let n=$(e.offPeak);n!==void 0&&(t.offPeak=n);let i=$(e.peak);i!==void 0&&(t.peak=i);let r=$(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 s=new Set;t.rateHistory=[];for(let c of e.rateHistory){if(!c||typeof c.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(c.before)||!Number.isFinite(Date.parse(c.before))||s.has(Date.parse(c.before))||!["cacheHit","cacheMiss","output"].every(l=>typeof c[l]=="number"&&Number.isFinite(c[l])&&c[l]>=0))return null;s.add(Date.parse(c.before));let a={before:c.before,...$(c)};for(let l of["offPeak","peak"])if(c[l]!==void 0){if(!c[l]||!["cacheHit","cacheMiss","output"].every(d=>typeof c[l][d]=="number"&&Number.isFinite(c[l][d])&&c[l][d]>=0))return null;a[l]=$(c[l])}t.rateHistory.push(a)}t.rateHistory.sort((c,a)=>Date.parse(c.before)-Date.parse(a.before))}return Object.assign(t,ve(e)),gt(t)?t:null}function Bi(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 xt(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function T(e){return xt(e).replace(/[^\p{L}\p{N}]+/gu,"")}function Li(e,t=!0,o=!0){let n=xt(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 Te(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(a=>typeof a=="string"&&a.length>0):[],s=r.find(a=>a===o);if(s!==void 0)return s;let c=e.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(c))return null;for(;;){let a=T(c);if(a.length===0)return null;let l=r.filter(u=>T(u)===a);if(l.length>0)return l.length===1?l[0]:null;let d=Li(c,n,i);if(d===c.toLowerCase())return null;c=d}}var wt=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...at]),Re={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 oe(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/"),s=r.search(/[/:]/);if(s>0){let c=r.slice(0,s).trim().toLowerCase(),a=r.slice(s+1).trim();if(Object.hasOwn(Re,c)&&(c===o||(o==="opencode-zen"||o==="opencode-go")&&(Re[c].test(a)||Te(a,Object.keys(c==="deepseek"?i?.models??{}:i?.providers?.[c]?.models??{}),a,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=a;else if(Object.hasOwn(Re,c))return null}return Te(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Fi(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},s=t,c=e,a=(e===""?"deepseek":e)+":"+t,l=r[a];if(l==="__custom__"){let f=De(o?.custom?.[a]);return{entry:f,billingMode:f?.billingMode??"flat",priced:f!==null,currency:f?.currency??"USD"}}if(l==="__local__")return{entry:null,billingMode:"flat",priced:!1};if(typeof l=="string"&&l.length>0){let f=l.indexOf(":");if(f>0&&l.slice(f+1).length>0?(c=l.slice(0,f).trim().toLowerCase(),s=l.slice(f+1)):s=l,c==="deepseek"&&s==="__default__"){let y=o?.default??{cacheHit:0,cacheMiss:0,output:0},A=P(y);return A===null?{entry:null,billingMode:"flat",priced:!1}:{entry:A,billingMode:"deepseek-peak",priced:A.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(c)){let f=oe(s,o?.providers?.[c]?.models??{},"opencode-go",i,o);f===null?c="opencode-go":s=f}if(at.includes(c)&&c!=="opendesign"&&oe(s,o?.providers?.[c]?.models??{},c,i,o)===null&&(c="opendesign"),Gn(c,s))return{entry:null,billingMode:"flat",priced:!1};if(c==="openrouter"){let f=o?.providers?.openrouter?.models??{},y=Object.hasOwn(f,s)?P(f[s]):null;return{entry:y,billingMode:"flat",priced:y!==null&&y.unpriced!==!0}}if(c===""||c==="deepseek"||c.includes("deepseek")){let f=o?.models??{},y=oe(s,f,"deepseek",i,o);if(y!=null){let M=f[y],b=P(M);return b===null||b.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:b,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let M=null,b=-1,S=!1,I="flat";for(let[x,E]of Object.entries(o?.providers??{})){if(wt.has(x))continue;let ue=E?.models??{},j=oe(s,ue,x,i,o);if(j===null)continue;let xe=P(ue[j]);if(xe===null)continue;let Q=+(j===s||T(j)===T(s));Q>b?(M=xe,b=Q,S=!1,I=Mt(ue[j])):Q===b&&(S=!0)}if(S)return{entry:null,billingMode:"flat",priced:!1};if(M!==null)return{entry:M,billingMode:I,priced:M.unpriced!==!0}}let A=Bi(s,o),w=P(A);return w===null?{entry:null,billingMode:"flat",priced:!1}:{entry:w,billingMode:"deepseek-peak",priced:w.unpriced!==!0}}let u=o?.providers?.[c]?.models??{},m=oe(s,u,c,i,o);if(m===null&&wt.has(c))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&Object.hasOwn(Re,c))return{entry:null,billingMode:"flat",priced:!1};if(m===null&&i==="auto"){let f=null,y=-1,A=!1,w="flat";for(let[M,b]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(M===c||wt.has(M))continue;let S=b?.models??{},I=oe(s,S,M,i,o);if(I===null)continue;let x=P(S[I]);if(x===null)continue;let E=+(I===s||T(I)===T(s));E>y?(f=x,y=E,A=!1,w=M==="deepseek"?"deepseek-peak":Mt(S[I])):E===y&&(A=!0)}if(A)return{entry:null,billingMode:"flat",priced:!1};if(f!==null)return{entry:f,billingMode:w,priced:f.unpriced!==!0}}if(m===null)return{entry:null,billingMode:"flat",priced:!1};let g=P(u[m]);return g===null||g.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:Mt(u[m]),priced:!0}}function Wi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Te(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],s=P(r);return s===null||s.unpriced===!0?null:{entry:s,billingMode:"deepseek-peak",priced:!0}}var zi=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 Gn(e,t){if(typeof e=="string"&&zi.has(e))return!0;let o=typeof t=="string"?xt(t):"";return Ki.some(n=>o.startsWith(n))}function Qn(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 s=sn($i(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&s.entry&&s.billingMode==="deepseek-peak"?{...s,entry:{...s.entry,peakSchedule:s.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&s.entry&&s.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?jn.has(typeof t=="string"?t.trim().toLowerCase():""):Te(t,[...jn])!==null)?{...s,entry:{...s.entry,peakSchedule:s.entry.peakSchedule??"ollama"}}:s}function $i(e,t,o,n){let i=Fi(e,t,o,n);if(i.currency)return i;if(i.priced||e===""||e==="deepseek"||e.includes("deepseek"))return Ne(i,o);let s=(n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{})[e+":"+t];if(typeof s!="string"||s.length===0||s==="__local__"||s.includes(":"))return Ne(i,o);let c=n?.mode==="exact"?"exact":"auto";return Ne(Wi(s,o,c)??i,o)}function Ne(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:Tn(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function De(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(n=>typeof e[n]=="number"&&Number.isFinite(e[n])&&e[n]>=0)||["cacheWrite","reasoning"].some(n=>e[n]!==void 0&&(typeof e[n]!="number"||!Number.isFinite(e[n])||e[n]<0)))return null;let t=P(e);if(!t)return null;let o={...t,currency:e.currency,billingMode:e.billingMode==="deepseek-peak"?"deepseek-peak":"flat"};return gt(o)?o:null}function qi(e,t,o,n=Ue){if(!Array.isArray(o)||o.length===0||Ui(e,n)!==null||Number.isFinite(t)&&e<t)return!1;let i=new Date(e).getUTCHours();return o.some(r=>{let s=Number(r?.start),c=Number(r?.end);return!Number.isFinite(s)||!Number.isFinite(c)?!1:s<c?i>=s&&i<c:i>=s||i<c})}function Yi(e,t,o){let n=Yn(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(a,l="base")=>mt(a,n,l),r=cn(n,t,o);if(r!==null)return r==="base"||!n[r]?i(n):i(n[r],r);let s=n.peakSchedule==="ollama";if(s||n.billingMode==="utc-peak"){if(o?.enabled!==!0||!Number.isFinite(t)||s&&t<Date.parse(Ni))return i(n);let a=new Date(t),l=a.getUTCDay(),d=a.getUTCHours(),u=l>0&&l<6&&(s?d>=12&&d<18:d>=1&&d<4||d>=6&&d<10);return i((u?n.peak:n.offPeak)??n,(u?n.peak:n.offPeak)?u?"peak":"offPeak":"base")}if(Number.isFinite(t)&&t<Date.parse(Di)){let a=n.legacyBase;return a===void 0?i(n):i(a,"legacyBase")}if(o?.enabled!==!0)return i(n);let c=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(qi(t,c,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let a=n.peak;return a===void 0?i(n):i(a,"peak")}if(c!==void 0&&t>=c){let a=n.offPeak;return a===void 0?i(n):i(a,"offPeak")}return i(n)}function Vn(e,t,o,n){let i=Yi(t,o,n),r=g=>{let f=Number(g);return Number.isFinite(f)&&f>0?f:0},s=r(e?.input),c=r(e?.output),a=r(e?.cacheRead),l=r(e?.cacheWrite),d=r(e?.reasoning);i.longContext&&s+a+l>i.longContext.aboveInputTokens&&(i=i.longContext);let u=typeof i.reasoning=="number"?i.reasoning:0,m=(s*i.cacheMiss+c*i.output+a*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(m)&&m>0?m:0}function Zn(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 Gi={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"},Qi=Object.entries(Gi).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function Jn(e,t){for(let o of[e,t]){let n=String(o??"").normalize("NFKC").replace(/([a-zA-Z0-9\u3400-\u9fff])(?=(?:MPlan|Coding|Token|Agent|Plan|Subscription))/g,"$1-").replace(/([a-z0-9])((?:coding|token|agent|m)?plan|subscription)$/i,"$1-$2").toLowerCase();if(!/(?:^|[^a-z0-9])(?:(?:coding|token|agent|m)[-_\s]*)?plan(?:$|[^a-z0-9])|(?:^|[^a-z0-9])subscription(?:$|[^a-z0-9])|套餐|订阅/.test(n))continue;let i=Qi.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 s=/token[-_\s]*plan|令牌.*套餐/.test(n),c=/coding[-_\s]*plan|编程.*套餐/.test(n);return s===c?null:s?"tencent-token":r}return r}}return null}var J=[...pe,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Vi={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","minimax-m-plan","minimax-mplan","minimax-token-plan"],kimi:["kimi","kimi-code","kimi-coding","kimi-coding-plan"],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","tencent-hy-token-plan","tokenhub-hy-token-plan"],"baidu-coding":["baidu-coding-plan","qianfan-coding-plan","baidu-token-plan","qianfan-token-plan","baidu-tokenplan","qianfan-tokenplan"],qwen:Pn,scnet:vn,mimo:En,factory:["factory","droid","factory-a","factory-g","factory-o"]},Ct={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"},eo=400,to=2160*36e5,na=168*36e5;var Zi=840*36e5;function Ot(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,s]of Object.entries(Vi))if(s.includes(n))return r;return J.includes(n)?n:Jn(e,o)}var Xn=new WeakMap;function Ji(e){let t=Xn.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(T)),n=new Set,i=new Set(Fn.map(T));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(T(r))&&n.add(T(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},Xn.set(e,t)}return t}function Et(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=T(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:s}=Ji(o);return!r.has(i)&&s.has(i)}function no(e,t,o,n,i){if(mn(e,t))return"api";let r=Ot(e,o,t);r===null&&Et(e,t,i)&&(r="go");let s=o?.models;if(s!==null&&typeof s=="object"){let a=s[`${e}:${t}`];if(a==="plan"||a==="api")return a;if(r!==null){let l=s[`${r}:${t}`];if(l==="plan"||l==="api")return l}}let c=o?.providers;for(let a of[e,r]){if(a==null)continue;let l=c?.[a];if(l==="plan"||l==="api")return l}return r===null?"api":r==="go"&&/^(?:llm-)?(?:dsh-opencode-go|opencode-go(?:-plus)?)$/i.test(String(e).trim())||r==="kimi"&&/^(?:llm-)?kimi-coding(?:-plan)?$/i.test(String(e).trim())||r==="minimax"&&/^(?:llm-)?minimax-(?:m-?plan|token-plan)$/i.test(String(e).trim())||n instanceof Set&&n.has(r)?"plan":"api"}function He(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 pe)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function oo(e){return JSON.stringify([e?.planBilling,[...He(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function _t(e,t,o,n,i){let r=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},s=r[t]!==null&&typeof r[t]=="object"&&!Array.isArray(r[t])?r[t]:{},c=Number(o);if(!Number.isFinite(c)||c<=0)return r;let a=Math.floor(c/36e5)*36e5,l=s[a]!==null&&typeof s[a]=="object"?s[a]:{tokens:0,cost:0};return l.tokens+=Math.max(0,Number(n)||0),l.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...s,[a]:l}}}function io(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Zi,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},s=!1;for(let[c,a]of Object.entries(i)){if(a===null||typeof a!="object"||Array.isArray(a)){s=!0;continue}let l={};for(let[d,u]of Object.entries(a)){let m=Number(d);if(!Number.isFinite(m)||m<n||m>o+36e5){s=!0;continue}l[m]={tokens:Math.max(0,Number(u?.tokens)||0),cost:Math.max(0,Number(u?.cost)||0)}}Object.keys(l).length>0&&(r[c]=l)}return s||Object.keys(r).length!==Object.keys(i).length?r:i}function vt(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=_t(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as Be,readlinkSync as Xi,statSync as er}from"node:fs";import{execFileSync as ro}from"node:child_process";import{hostname as tr}from"node:os";import{join as nr}from"node:path";import{performance as or}from"node:perf_hooks";var co=tr(),Le=process.platform==="win32"?or.timeOrigin:Date.now()-process.uptime()*1e3,so={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},Pt,Nt,je;function Rt(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=Be(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=Be("/proc/sys/kernel/random/boot_id","utf8").trim(),s=Xi(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let c=e===process.pid?Le:null;if(t&&e!==process.pid){je??=Number(ro("getconf",["CLK_TCK"],so).trim());let a=Be("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(je)&&je>0&&a&&(c=(Number(a)+Number(i)/je)*1e3)}return{platform:"linux",boot:r,namespace:s,start:i,startedAtMs:c}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(Le)),unit:"ms",startedAtMs:Le};let n=nr(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=ro(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],so).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function Tt(){return Pt===void 0&&(Pt=Rt(process.pid)),Pt}function ao(){let e=Tt();return JSON.stringify({version:e?.unit==="ms"?2:1,host:co,identity:e})}function lo(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=Be(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==co)return!1;let c=Tt();if(i?.identity?.platform==="linux"&&c?.platform==="linux"&&i.identity.boot===c.boot&&i.identity.namespace!==c.namespace)return!1}try{process.kill(t,0)}catch(c){return c.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,Rt(t,n===""));let s=t===process.pid?Tt():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(Nt===void 0&&(Nt=Rt(t,!1,!0)),s=Nt),n===""){let c=t===process.pid?s?.startedAtMs??Le:s?.startedAtMs;return Number.isFinite(c)&&er(e).mtimeMs<c-2e3}if(!r||!s||r.platform!==s.platform||typeof r.start!="string"||!/^\d+$/.test(r.start))return!1;if(s.platform==="linux")return typeof r.boot!="string"||typeof r.namespace!="string"?!1:r.boot!==s.boot||r.start!==s.start;if(r.unit==="ms"||s.unit==="ms"){let c=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),a=c(r),l=c(s);return!Number.isSafeInteger(a)||a<=0||!Number.isSafeInteger(l)||l<=0?!1:a<l-2e3}return r.start!==s.start}import{createHash as rr,randomUUID as Ht}from"node:crypto";import{createHash as ir}from"node:crypto";var U=new WeakMap,uo=/^[a-f\d]{64}$/,me=e=>e&&typeof e=="object"&&!Array.isArray(e),po=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),Ut=e=>ir("sha256").update(JSON.stringify(e)).digest("hex"),fo=24;function We(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))We(t);return Object.freeze(e)}function ho(e,t,o=[],n=[]){if(e===t)return n;if(me(e)&&me(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))po(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)?ho(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 mo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=mo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function Fe(e,t,o,n){let i=o.get(n);if(i&&i.depth<fo){let r={base:n,patch:ho(t[n],e)};if(JSON.stringify(r).length<JSON.stringify(e).length)return{record:We(r),depth:i.depth+1,signature:Ut(r),baseValue:t[n]}}return{record:e,depth:0,signature:Ut(e)}}function ze(e,t,o,n){let i=U.get(e)??new Map;U.set(e,i),Object.hasOwn(e,t)||(e[t]=We(o)),i.has(t)||i.set(t,Fe(e[t],e,i,n))}function go(e={}){let t={...e};return U.set(t,new Map(U.get(e)??[])),t}function bo(e,t){let o={...t,...e};return U.set(o,new Map([...U.get(t)??[],...U.get(e)??[]])),o}function yo(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,Fe(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function ko(e,t,o){let n={},i=new Map,r=U.get(o),s=new Set,c=a=>{if(i.has(a))return!0;if(!uo.test(a)||s.has(a)||s.size>fo||!me(e[a]))return!1;s.add(a);let l=e[a],d;if(!me(l.prices)){if(!uo.test(l.base)||!Array.isArray(l.patch)||l.patch.length>1e5||l.patch.some(f=>!Array.isArray(f)||![1,2].includes(f.length)||!Array.isArray(f[0])||f[0].length>16||!f[0].every(po))||!c(l.base))return s.delete(a),!1;d=i.get(l.base)}let u=Ut(l),m=d?n[l.base]:void 0,g=r?.get(a);if(g&&o[a]&&(g.sourceSignature===u&&g.sourceBase===m||g.signature===u&&g.baseValue===m))n[a]=o[a],i.set(a,g);else{let f=d?n[l.base]:l;if(d)for(let A of l.patch)f=mo(f,A[0],A);if(!me(f?.prices))return s.delete(a),!1;n[a]=We(t(f));let y=Fe(n[a],n,i,d?l.base:void 0);i.set(a,{...y,sourceSignature:u,sourceBase:m})}return s.delete(a),!0};for(let a of Object.keys(e))c(a);if(U.set(n,i),![...i.values()].some(a=>a.depth>0)){let a;for(let l of Object.keys(n)){let{sourceSignature:d,sourceBase:u}=i.get(l);i.set(l,{...Fe(n[l],n,i,a),sourceSignature:d,sourceBase:u}),a=l}}return n}var Mo=new WeakMap,$e=new WeakMap,ge=new WeakSet,sr=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],Bt=e=>rr("sha256").update(JSON.stringify(e)).digest("hex"),re=e=>!["__proto__","constructor","prototype"].includes(e),Ke=e=>e&&typeof e=="object"&&!Array.isArray(e),cr=new Set(["peakWindows","peakHolidays","peakSchedule","start","end","cacheHit","cacheMiss","cacheWrite","input","cachedInput","output","reasoning","billingMode","unpriced","legacy","currency","aboveInputTokens","before","offPeak","peak","longContext","legacyBase","rateHistory","cny","multiplier","separateMultipliers","multipliers"]),be=e=>Array.isArray(e)?e.map(be):Ke(e)?Object.fromEntries(Object.entries(e).filter(([t])=>cr.has(t)||ht.test(t)).map(([t,o])=>[t,be(o)])):e,Dt=e=>Object.fromEntries(Object.entries(e??{}).filter(([t])=>re(t)).map(([t,o])=>[t,be(o)])),Ao=["at","before","after","days","sessions","skipped"],jt=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function Io(e){let t=$e.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||jt(n,r)>=0)&&o.set(i,n)}return t={changes:Object.values(e.changes).sort(jt),revisions:o,fingerprint:Bt([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((n,i)=>n.at-i.at||(n.sequence??0)-(i.sequence??0))},$e.set(e,t),t}function Lt(e,t=!1){let o=structuredClone(Object.fromEntries(sr.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:be(n.default),models:Dt(n.models),...n.custom?{custom:Dt(n.custom)}:{},providers:Object.fromEntries(Object.entries(n.providers??{}).filter(([i])=>re(i)).map(([i,r])=>[i,{...V(r),...r.currency?{currency:r.currency}:{},...r.default?{default:be(r.default)}:{},models:Dt(r.models)}]))},o}function wo(e,t=!1){let o=Lt(e,t),n=Bt(o),i={};ze(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:v(e)}}};return ge.add(r),r}function ye(e,t,o,n=!1){if(ge.has(e))return e;if(!Ke(e?.versions)||!Ke(e?.changes))return wo(t,n);let i=ko(e.versions,d=>Lt(d,!0),o?.versions),r=Object.fromEntries(Object.entries(e.changes).filter(([d,u])=>re(d)&&Number.isFinite(u?.at)&&u.at>=0&&i[u.version]));if(!Object.values(r).some(d=>d.at===0)){let d=Object.values(i),u={...t?.prices};for(let g of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])d.length&&(u[g]=d.every(f=>f.prices?.[g]===!0));let m=wo({...t,prices:u},n);for(let[g,f]of Object.entries(m.versions))ze(i,g,f);r[Ht()]=m.changes.initial}let s=Object.fromEntries(Object.entries(e.revisions??{}).filter(([d,u])=>re(d)&&typeof u?.sessionId=="string"&&(u.model===void 0||typeof u.model=="string"&&u.model.includes(":")&&u.model.length<=2048)&&/^\d{4}-\d{2}-\d{2}$/.test(u.date)&&Number.isFinite(u.at)&&i[u.version])),c=Object.fromEntries(Object.entries(Ke(e.runs)?e.runs:{}).filter(([d,u])=>re(d)&&Ao.every(m=>Number.isFinite(u?.[m])&&u[m]>=0)).map(([d,u])=>[d,{...Object.fromEntries([...Ao,...["beforeCny","afterCny","beforeEur","afterEur"].filter(m=>Number.isFinite(u[m])&&u[m]>=0)].map(m=>[m,u[m]])),...typeof u.model=="string"?{model:u.model}:{}}])),a=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([d,u])=>re(d)&&Number.isFinite(u?.at)&&u.at>=0&&["CNY","EUR"].every(m=>Number.isFinite(u.rates?.[m])&&u.rates[m]>0)));if(!Object.keys(a).length)for(let[d,u]of Object.entries(r))a[d]={at:u.at,sequence:u.sequence??0,rates:v({...i[u.version],currency:t.currency})};let l={versions:i,changes:r,revisions:s,runs:c,fxChanges:a};return ge.add(l),l}function qe(e,t,o=Date.now()){let n=Lt(t),i=Bt(n),r=Io(e),s=r.changes.at(-1),c=v(t),a=r.fx.at(-1),l=JSON.stringify(a?.rates)!==JSON.stringify(c);l&&(e.fxChanges??={},e.fxChanges[Ht()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,rates:c},$e.delete(e));let d=u=>{let{exchangeRate:m,...g}=u??{};return g};return s?.version===i||JSON.stringify(d(e.versions[s?.version]))===JSON.stringify(d(n))?l:(ze(e.versions,i,n,s?.version),e.changes[Ht()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},$e.delete(e),!0)}function So(e,t){return e&&t&&Mo.set(e,t),e}function Ft(e,t,o="",n=""){if(e?._repriceFxConfig){let I=Ft(e._repriceFxConfig,t,o,n),x=v(I);return{...e,fxRates:x,exchangeRate:x[e.currency]??e.exchangeRate}}let i=Mo.get(e);if(!i||!Number.isFinite(t))return e;let r=Io(i),s=new Date(t),c=Number.isFinite(t)?`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`:"",a=0,l=r.changes.length;for(;a<l;){let I=a+l>>>1;r.changes[I].at<=t?a=I+1:l=I}let d=r.changes[a-1],u=I=>I&&t<=I.at?I:null,m=u(r.revisions.get(JSON.stringify([o,c,""]))),g=n?u(r.revisions.get(JSON.stringify([o,c,n]))):null,f=m&&g?jt(m,g)>0?m:g:m??g,y=(f??d)?.version,A=y&&i.versions[y]?{...e,...i.versions[y]}:e,w=0,M=r.fx.length;for(;w<M;){let I=w+M>>>1;r.fx[I].at<=t?w=I+1:M=I}let b=r.fx[w-1]?.rates,S=f?.preserveFx?m?.fxRates??b??v(i.versions[d?.version]??e):f?f.fxRates??v(A):b??v(A);return{...A,fxRates:S,exchangeRate:S[A.currency]??A.exchangeRate}}function xo(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:bo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return ge.add(n),n}function Co(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:go(t)};return ge.add(n),n}function Oo(e){return e&&{...e,format:2,versions:yo(e.versions)}}var Y=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...R],G=e=>!["__proto__","constructor","prototype"].includes(e),O=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),se=e=>e===void 0?void 0:structuredClone(e);function Kt(e,t){if(O(e)){if(!O(t)){for(let o of R)delete e[o];return}for(let o of R)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))Kt(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)&&Kt(n,o.get(n.id))}}}function fr(e,t){if(!O(e)||!O(t))return e;for(let[o,n]of Object.entries(e))O(n)&&Kt(n,t[o]);return e}function $t(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)=>$t(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(!R.includes(n)&&!$t(e[n],t[n]))return!1;return!0}function qt(e,t,o){if(!O(e))return e;for(let n of R){let i=D(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??{}))qt(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(c=>O(c)&&typeof c.id=="string").map(c=>[c.id,c])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)O(s)&&typeof s.id=="string"&&qt(s,i.get(s.id),r.get(s.id))}return e}function Ae(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Co(t)}:{}}}var hr=new Int32Array(new SharedArrayBuffer(4)),Ho=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])=>Ho(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 we(e,t,o=5e3,n=Do()){Eo(Uo(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=ao(),c=new Map,a=Date.now()+o;for(;;)try{Eo(i);try{Ro(ke(i,r),s,{flag:"wx"})}catch(l){try{Ge(ke(i,r))}catch{}throw Ye(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=ar(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(lo(ke(i,d[0]),Number(u[1]),c)){Ge(ke(i,d[0])),Ye(i);continue}}else if(d.length===0&&Date.now()-ur(i).mtimeMs>3e4){Ye(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=a)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait(hr,0,0,10)}try{return t()}finally{Ge(ke(i,r)),Ye(i)}}function jo(e){let t;try{t=To(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 Bo(e,t){let o=`${e}.${process.pid}-${Do()}.tmp`;try{let n=_o(o,"wx",384);try{Ro(n,JSON.stringify(t),"utf8"),vo(n)}finally{Po(n)}if(lr(o,e),process.platform!=="win32"){let i=_o(Uo(e),"r");try{vo(i)}finally{Po(i)}}}finally{try{Ge(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function Yt(e){let t;try{t=To(`${e}.config-bak`,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!O(o)||o.version!==1||!O(o.config)||!Array.isArray(o.migrations))throw new Error("Unsupported ledger config backup format");return{version:1,config:o.config,migrations:o.migrations.filter(n=>typeof n=="string")}}function Gt(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=Yt(e)}catch(i){if(i.code)throw i}N(n,o)||Bo(`${e}.config-bak`,o)}function Qe(e,t,o=!1){if(o)try{dr(e,`${e}.pricing-history-v1.bak`,pr.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}Gt(e,t),Bo(e,{...t,pricingHistory:Oo(t.pricingHistory)})}var Wt=()=>Object.fromEntries(Y.map(e=>[e,0]));function No(e,t){for(let o of Y)e[o]=(Number(e[o])||0)+(t[o]??0)}function ce(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!Ho(d)||!Number.isSafeInteger(u)||u<1)throw Error("Invalid metered call identity");if((e.usageCursors?.[d]??0)>=u)return!1;if(e.usageCursors??={},e.usageCursors[d]=u,t.skip)return!0}let{date:o,sessionId:n,atMs:i,providerKey:r,values:s,planId:c}=t;O(e.days[o])||(e.days[o]={date:o,...Wt(),byProviderModel:{},sessions:[]});let a=e.days[o];Array.isArray(a.sessions)||(a.sessions=[]);let l=[a];if(typeof n=="string"&&n.length>0){let d=a.sessions.find(u=>u.id===n);d||(d={id:n,at:i,...Wt(),byProviderModel:{}},a.sessions.push(d)),l.push(d)}for(let d of l){No(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=Wt();No(u,s)}return c!==null&&(e.planHourBuckets=_t(e.planHourBuckets,c,i,st(s),s.cost)),!0}function D(e,t,o,n=!1){if(N(t,e))return se(o);if(N(o,e)||N(t,o))return se(t);if(O(t)&&O(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!G(r))continue;let s=D(e?.[r],t[r],o[r],n&&(O(t[r])||Y.includes(r)||r==="tokens"));s!==void 0&&(i[r]=s)}return i}return n&&typeof t=="number"&&typeof o=="number"?Math.max(0,o+t-(Number(e)||0)):se(t)}var zt=e=>Object.fromEntries((e?.sessions??[]).filter(t=>G(t.id)).map(t=>[t.id,t]));function mr(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!G(i))continue;let r=e[i],s=t[i],c=o[i];if($t(r,s)){c!==void 0&&(n[i]=qt(se(c),r,s));continue}if(!s||!c){s&&(n[i]=se(s));continue}if(N(s,c)){n[i]=se(c);continue}let a=D(r,s,c,!0),l=zt(r),d=zt(s),u=zt(c),m=D(l,d,u,!0),g=(f,y,A)=>Object.fromEntries(Y.map(w=>[w,(A?.[w]??0)+(y?.[w]??0)-(f?.[w]??0)]));Object.assign(a,g(r,s,c)),a.byProviderModel={};for(let f of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(c.byProviderModel??{})]))G(f)&&(a.byProviderModel[f]=g(r?.byProviderModel?.[f],s.byProviderModel?.[f],c.byProviderModel?.[f]));for(let f of Object.keys(d))if(!(!u[f]||N(l[f],d[f])||N(l[f],u[f]))){for(let y of Y)a[y]-=(d[f][y]??0)-(l[f]?.[y]??0)-((m[f]?.[y]??0)-(u[f][y]??0));for(let[y,A]of Object.entries(d[f].byProviderModel??{}))if(!(!G(y)||!a.byProviderModel[y]))for(let w of Y)a.byProviderModel[y][w]-=(A[w]??0)-(l[f]?.byProviderModel?.[y]?.[w]??0)-((m[f]?.byProviderModel?.[y]?.[w]??0)-(u[f].byProviderModel?.[y]?.[w]??0))}for(let f of[a,...Object.values(a.byProviderModel)])for(let y of Y)f[y]=Math.max(0,f[y]);a.sessions=Object.values(m).sort((f,y)=>(f.at??0)-(y.at??0)),n[i]=a}return n}function gr(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(G(r)){i[r]={};for(let s of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!G(s))continue;let c=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),a=D(c(e[r]?.[s]),c(t[r]?.[s]),c(o[r]?.[s]));i[r][s]=Object.values(a).filter(l=>l.t>=n-to).sort((l,d)=>l.t-d.t).slice(-eo)}}return i}function ae(e,t,o,n,i=Date.now(),r=[],s={}){let c=s.ownLocal===!0,a=o!==void 0&&o===e,l=Ae(e),d=a?l:Ae(o??e),u=c?t:Ae(t);fr(l.days,d.days);let m=!N(u.historyReset,l.historyReset),g=!N(d.historyReset,l.historyReset),f=m?u.historyReset:d.historyReset;if(m||g)for(let S of[l,...m?[d]:[u]])S.days={},S.planSamples={},S.planHourBuckets={},S.balanceRef=null;for(let S of n)g&&!m&&S.recordedAt<=(f?.at??0)||(ce(l,S),d!==l&&ce(d,S),g&&!m&&ce(u,S));let y={version:1,writeReceipts:H([...d.writeReceipts??[],...u.writeReceipts??[]]),config:D(l.config,u.config,d.config),days:mr(l.days,u.days,d.days),balanceRef:N(l.balanceRef,u.balanceRef)?d.balanceRef:N(l.balanceRef,d.balanceRef)?u.balanceRef:u.balanceRef==null||d.balanceRef==null?null:(d.balanceRef?.at??0)>(u.balanceRef?.at??0)?d.balanceRef:u.balanceRef,migrations:[...new Set([...d.migrations??[],...u.migrations??[]])],planSamples:gr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:io(D(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:D(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:xo(u.pricingHistory,d.pricingHistory),historyReset:f??null},A=X(u.usageCursors);for(let[S,I]of Object.entries(X(d.usageCursors)))A[S]=Math.max(A[S]??0,I);Object.keys(A).length&&(y.usageCursors=A);let w=D(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);w&&Object.keys(w).length&&(y.providerPriceHashes=w);let M=Object.keys(y.days).sort(),b=Math.max(7,Math.min(3650,Number(y.config.historyDays)||180));for(;M.length>b;)delete y.days[M.shift()];return Z(y.days).includes(y.balanceRef?.date)&&(y.balanceRef=null),br(y,r),y}function br(e,t){let o=(n,i)=>Y.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(oo(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(c=>!o(i.byProviderModel?.[c],r.byProviderModel?.[c]))))for(let c of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!G(c))continue;let a=e.planHourBuckets?.[c]??{},l=Object.fromEntries(Object.entries(a).filter(([u])=>+u>=n.start&&+u<n.end)),d=n.buckets[c]??{};N(l,d)||(e.planHourBuckets[c]={...Object.fromEntries(Object.entries(a).filter(([u])=>+u<n.start||+u>=n.end)),...d},e.planSamples&&delete e.planSamples[c])}}}function Lo(e,t,o){return D(e,t,o)}import{join as zo}from"node:path";var Ko=1,Go=180;function Ar(e){if(typeof e!="string"||e.length>2048||!/^https?:\/\//i.test(e.trim()))return"";try{let t=new URL(e.trim());return t.username||t.password?"":t.href}catch{return""}}function Me(e){try{let t=kr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Qt=["antigravity","claude","codex","kimi","xai","workbuddy"],wr=["sidebar","settings","both","off"],Mr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Ir(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function $o(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function Sr(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 s=t.slice(1,r),c=t.slice(r+1);return!s.includes(":")||!/^[0-9a-f:.]+$/.test(s)?!1:c===""||c.startsWith(":")&&$o(c.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!$o(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 xr(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(c=>typeof c=="string").map(c=>Ir(c)).filter(c=>Qt.includes(c)))]:Qt.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(c=>Sr(c)).map(c=>c.trim().toLowerCase()))].slice(0,16):[],s=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:wr.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:Qt.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function Cr(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 Xt(){return{queryAccounts:{},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:Bn,peakWindows:Ln.map(e=>({...e})),peakHolidays:[...Ue],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,sidebarTextOnly:!1,planQuotaStyle:"bars",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(St.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(St.default),providers:Object.fromEntries(Object.entries(q).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,officialChannelOnly:!1,quickHide:!1,budgetCap:null,reconcile:!0,clickHintSeen:!1},goQuota:{enabled:!0,display:"both",refreshMinutes:15,apiKey:"",main:"rolling",detail:!0},customBalance:{dashboardUrl:"",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:{...Ct},models:{},modelPlans:{}},historyDays:Go,fetchedAt:null,priceSource:"bundled"}}var cl=Object.keys(Xt());function Vt(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Zt(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function Or(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(":"),s=r>=0?n.slice(0,r):n;s.startsWith("llm-")&&(s=s.slice(4)),/^deepseek(?:-official|-account)?$/.test(s)&&(o+=Number(i?.cost)||0)}return o}function Er(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function Ve(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=Er(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 qo(e){for(let t of Object.values(e))if(Ve(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))Ve(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>Ve(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))Ve(i)===null&&delete o.byProviderModel[n]}}return e}function Ie(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)?Ie(r,i):i}return o}function le(e){let t=Xt(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(qn),currency:"CNY"});let n=Ie(t,o);n.queryAccounts=un(o.queryAccounts),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&&De(h)!==null).map(([p,h])=>[p,De(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=Ie({},h.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=Ie({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:p,cacheMiss:h,output:k}=t.prices.default;n.prices.default=Ie({cacheHit:p,cacheMiss:h,output:k},r)}let s=p=>{if(p&&typeof p=="object"&&!Oe(p))for(let h of nt)delete p[h]};for(let p of Object.values(n.prices?.providers??{})){s(p);for(let h of Object.values(p?.models??{}))s(h)}for(let p of[...Object.values(n.prices?.models??{}),n.prices?.default])s(p);let c=p=>typeof p=="number"&&Number.isFinite(p),a=(p,h,k)=>typeof p=="string"&&h.includes(p)?p:k;for(let[p,h]of Object.entries(t)){let k=n[p],_=typeof h;_==="boolean"&&typeof k!="boolean"||_==="number"&&!c(k)||_==="string"&&typeof k!="string"?n[p]=h:_==="object"&&h!==null&&k!==null&&typeof k=="object"&&p==="gatewayQuotas"&&Array.isArray(k)||_==="object"&&h!==null&&(k===null||typeof k!="object"||Array.isArray(k)!==Array.isArray(h))&&(n[p]=h)}n.locale=a(n.locale,["auto","zh","en"],"auto"),n.position=a(n.position,["dock","header","off"],"dock"),n.peakStyle=a(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=a(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=a(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=a(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=a(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=a(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=fn(n.modelStatistics);for(let p of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline","sidebarTextOnly"])n[p]=n[p]===!0;n.sessionCostCompact=n.sessionCostCompact===!0,n.contextCostsEnabled=n.contextCostsEnabled===!0,n.contextCostsPromptSeen=n.contextCostsPromptSeen===!0,n.sidebarTodayMetric=a(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=a(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 k=n.sidebarModels?.[p],_={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[p];return[p,_?_.includes(k)?k:h:typeof h=="boolean"?typeof k=="boolean"?k:h:typeof k=="number"&&Number.isFinite(k)?Math.min(p==="topN"?10:60,Math.max(p==="topN"?1:10,Math.floor(k))):h]})),n.sidebarStyle=a(n.sidebarStyle,["standard","compact","summary"],"standard"),n.planQuotaStyle=a(n.planQuotaStyle,["bars","gauge"],"bars"),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 l=Number(n.peakAlertAhead);n.peakAlertAhead=Number.isInteger(l)&&l>=1&&l<=30?l:2,n.peakAlertTarget=a(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=a(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=c(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=v(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:"",(!c(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(p=>p!==null&&typeof p=="object"&&c(Number(p.start))&&c(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 d={};if(n.priceOverrides!==null&&typeof n.priceOverrides=="object")for(let[p,h]of Object.entries(n.priceOverrides))typeof p=="string"&&typeof h=="string"&&(d[p]=h);n.priceOverrides=d;let u={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[p,h]of Object.entries(n.priceTableDisplay))typeof p=="string"&&(u[p]=typeof h=="boolean"?h:t.priceTableDisplay[p]===!0);n.priceTableDisplay={...t.priceTableDisplay,...u};let m=n.budget;m.enabled=m.enabled===!0,m.amount=c(m.amount)&&m.amount>=0?m.amount:100,m.period=a(m.period,["day","month","all","custom"],"month"),m.customStart=typeof m.customStart=="string"?m.customStart:null,m.customEnd=typeof m.customEnd=="string"?m.customEnd:null,m.detail=m.detail!==!1;let g=n.balance;g.display=a(g.display,["sidebar","settings","both","off"],"both"),g.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(g.refreshMinutes)||5))),g.showProgressBar===void 0&&(g.showProgressBar=n.customBalance?.showProgressBar!==void 0?n.customBalance.showProgressBar===!0:t.balance.showProgressBar===!0),g.showProgressBar=g.showProgressBar===!0,g.showSource=g.showSource===!0,g.officialChannelOnly=g.officialChannelOnly===!0,g.quickHide=g.quickHide===!0,g.clickHintSeen=g.clickHintSeen===!0,g.reconcile=g.reconcile!==!1;let f=Number(g.budgetCap);g.budgetCap=Number.isFinite(f)&&f>0?f:null;let y=n.goQuota;y.enabled=y.enabled===!0,typeof y.showInComposer!="boolean"&&delete y.showInComposer,y.display=a(y.display,["sidebar","settings","both","off"],"both"),y.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),y.apiKey=typeof y.apiKey=="string"?y.apiKey:"",y.main=a(y.main,["rolling","weekly","monthly"],"rolling"),y.detail=y.detail!==!1;let A=n.customBalance??t.customBalance,w=(p,h)=>{let k=p??{},_={...["aliyun","tokenrhythm"].includes(k.adapter)?{adapter:k.adapter}:{},enabled:k.enabled===!0,display:a(k.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(k.refreshMinutes)||15))),label:typeof k.label=="string"?k.label:h.label,labelEn:typeof k.labelEn=="string"?k.labelEn:h.labelEn,dashboardUrl:Ar(k.dashboardUrl),unit:k.adapter==="tokenrhythm"?"CNY":a(k.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:k.convertToDisplayCurrency===!0,allowInsecureHttp:k.allowInsecureHttp===!0};if(k.request===null||typeof k.request!="object"||Array.isArray(k.request))_.request={...h.request};else{let W={};for(let[B,z]of Object.entries(k.request.headers??{}))typeof B=="string"&&typeof z=="string"&&(W[B]=z);_.request={...h.request,...k.request,url:typeof k.request.url=="string"?k.request.url:"",method:typeof k.request.method=="string"?k.request.method:"GET",headers:{...h.request?.headers??{},...W}}}if(k.extract===null||typeof k.extract!="object"||Array.isArray(k.extract)?_.extract={...h.extract}:_.extract={...h.extract,...k.extract},Array.isArray(k.allowedHosts)){let W=k.allowedHosts.filter(B=>typeof B=="string"&&B.length>0);W.length>0&&(_.allowedHosts=W)}return _},M=w(A,t.customBalance);n.customBalance=M;let b=n.gatewayQuotas,S=Array.isArray(b)?b:b!==null&&typeof b=="object"&&Array.isArray(b.sources)?b.sources:[],I=[],x=new Set;for(let p of S.slice(0,4)){let h=xr(p);!Mr.test(h.id)||x.has(h.id)||h.type!=="cliproxyapi"||!Cr(h.baseURL)||(x.add(h.id),I.push(h))}n.gatewayQuotas={sources:I};let E=n.customBalances;Array.isArray(E)||(E=[]);let ue=t.customBalances?.[0]??t.customBalance,j=E.slice(0,8).map(p=>w(p,ue)),xe=M.enabled===!0||typeof M.request?.url=="string"&&M.request.url.length>0;j.length===0&&xe&&j.push(M),n.customBalances=j;let Q=n.corner;for(let p of["enabled","goRolling","goWeekly","goMonthly","budget"])Q[p]=Q[p]===!0||Q[p]!==!1&&p!=="enabled";let te=n.quotaStrip;te.enabled=te.enabled===!0,te.promptSeen=te.promptSeen===!0;for(let p of["budget","go","plans"])te[p]=te[p]!==!1;let Ce=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:Ce.balance==="used"?"used":"remaining",budget:Ce.budget==="remaining"?"remaining":"used",go:Ce.go==="remaining"?"remaining":"used",plan:Ce.plan==="remaining"?"remaining":"used"};let C={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[p,h]of Object.entries(n.codingPlans))if(!(!pe.includes(p)||h===null||typeof h!="object"||Array.isArray(h))){if(C[p]={enabled:h.enabled===!0,...typeof h.showInComposer=="boolean"?{showInComposer:h.showInComposer}:{},display:a(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 k=Nn(h.baseUrl);C[p].baseUrl=k??"",k===null&&(C[p].enabled=!1)}if(p==="workbuddy"&&(h.accountSource!==void 0&&(C[p].accountSource=a(h.accountSource,["auto","connect","xdpool"],"auto")),C[p].accountScope=a(h.accountScope,["current","all","selected"],"current"),C[p].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(dt))].slice(0,400):[]),p==="opendesign"){let k=Sn(h.workspaceId);C[p].workspaceId=k??"",k===null&&(C[p].enabled=!1)}if(p==="factory"){let k=In(h.orgId);C[p].orgId=k??"",k===null&&(C[p].enabled=!1),C[p].factoryPool=a(h.factoryPool,["standard","core","both"],"standard")}if(p==="scnet"){let k=Number(h.planCredits);C[p].planCredits=Number.isFinite(k)&&k>0?k:24e4,C[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:""}if(p==="qwen"){C[p].quotaSource=h.quotaSource==="cli"||h.quotaSource==="bailian"?h.quotaSource:"local";let k=Number(h.planCredits);C[p].planCredits=Number.isFinite(k)&&k>0?k:5e5,C[p].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:"";let _=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},W={};for(let[B,z]of Object.entries(_)){if(typeof B!="string"||B.length===0||z===null||typeof z!="object")continue;let et=ti=>{let tt=Number(ti);return Number.isFinite(tt)&&tt>0?tt:null},nn=et(z.input),on=et(z.cachedInput),rn=et(z.output);nn===null||on===null||rn===null||(W[B]={input:nn,cachedInput:on,output:rn})}C[p].rates=W}if(p==="volcengine"){let k=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",_=typeof h.apiKey=="string"?h.apiKey.trim():"";C[p].accessKeyId=k.length>0?k:_,C[p].secretAccessKey=typeof h.secretAccessKey=="string"?h.secretAccessKey:"",C[p].accessKeyId.length>0&&C[p].apiKey!==C[p].accessKeyId&&(C[p].apiKey=C[p].accessKeyId)}}}n.codingPlans=C;let Xe={};for(let p of J){let h=n.planBilling?.providers?.[p];Xe[p]=["auto","plan","api"].includes(h)?h:Ct[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)&&(Xe[p]=h);let tn={};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")&&(tn[p]=h);let Xo=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([p,h])=>p.includes(":")&&J.includes(h))),ei=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(p=>J.includes(p)):[...He(n)])];return n.planBilling={providers:Xe,models:tn,modelPlans:Xo,autoProviders:ei},n}var _r={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.baidu-coding":"BAIDU_QIANFAN_COOKIE","codingPlans.factory":"FACTORY_API_KEY"},al=Object.keys(_r);function Yo(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,s]of Object.entries(o))ct(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function Jt(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=Yo(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(Yo)),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 Ze=[{id:"provider-catalog-2026-10-03",apply:he},{id:"provider-catalog-2026-10-15",apply:Wn},{id:"provider-catalog-2026-10-28",apply:zn},{id:"stepfun-catalog-2026-10-16",apply:Kn},{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")}}],Je=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=ye(r.pricingHistory,t),this.config=t,ln(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??kn,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(s=>typeof s=="string"):[],this.secretMigration={ran:!1,pending:[]},this.planSamples=r.planSamples??{},this.planHourBuckets=r.planHourBuckets??{},this.openrouterPriceHashes=Object.fromEntries(Object.entries(r.openrouterPriceHashes??{}).filter(([s,c])=>!["__proto__","constructor","prototype"].includes(s)&&typeof c=="string"&&/^[a-f0-9]{64}$/.test(c))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([s,c])=>s.startsWith("opendesign:")&&typeof c=="string"&&/^[a-f0-9]{64}$/.test(c))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&qe(this.pricingHistory,t),this._config=So(t,this.pricingHistory)}static open(){let t=zo(ut(),"storages","cost-meter"),o=zo(t,"ledger.json");return we(o,()=>e.load(o))}static load(t){let o=Xt(),n={},i=null,r=[...Ze.map(b=>b.id),"quota-token-window-v2"],s={},c={},a={},l={},d=null,u={},m=[],g,f=!1,y=!1,A=!1;try{let b=JSON.parse(yr(t,"utf8"));if(b===null||typeof b!="object"||Array.isArray(b))throw new Error("Unsupported ledger format");if(b!==null&&typeof b=="object")if(b.version!==Ko){try{Fo(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(b.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=b.historyReset??null,u=X(b.usageCursors),m=H(b.writeReceipts);let S=typeof b.config=="object"&&b.config!==null?b.config:{};g=ye(b.pricingHistory,le(S),void 0,!0),f=!!b.pricingHistory&&b.pricingHistory.format!==2,r=Array.isArray(b.migrations)?b.migrations.filter(E=>typeof E=="string"):[];let I=new Set(r);for(let E of Ze)I.has(E.id)||(E.apply(S),r.push(E.id));o=le(S),b.openrouterPriceHashes&&typeof b.openrouterPriceHashes=="object"&&!Array.isArray(b.openrouterPriceHashes)&&(a=b.openrouterPriceHashes),b.providerPriceHashes&&typeof b.providerPriceHashes=="object"&&!Array.isArray(b.providerPriceHashes)&&(l=b.providerPriceHashes),b.days!==null&&typeof b.days=="object"&&!Array.isArray(b.days)&&(n=qo(b.days));let x=b.balanceRef;x!==null&&typeof x=="object"&&typeof x.date=="string"&&Number.isFinite(x.total)&&Number.isFinite(x.granted)&&Number.isFinite(x.topped)&&(i={date:x.date,total:x.total,granted:x.granted,topped:x.topped,currency:typeof x.currency=="string"?x.currency:void 0,at:Number(x.at)||0,ledgerCost:Number.isFinite(x.ledgerCost)&&x.ledgerCost>=0?x.ledgerCost:void 0}),b.planSamples!==null&&typeof b.planSamples=="object"&&!Array.isArray(b.planSamples)&&(s=b.planSamples),b.planHourBuckets!==null&&typeof b.planHourBuckets=="object"&&!Array.isArray(b.planHourBuckets)?c=b.planHourBuckets:Array.isArray(b.planRecentCalls)&&(c=vt(b.planRecentCalls)),y=!0}}catch(b){if(b?.code!=="ENOENT"){try{Fo(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(b?.message??b)}`)}}if(y)try{Gt(t,{config:Jt(o),migrations:r})}catch(b){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u5199\u5165\u5931\u8D25\uFF08${b?.code??"write error"}\uFF09`)}else try{let b=Yt(t);if(b){let S=b.config;r=b.migrations;for(let I of Ze)r.includes(I.id)||(I.apply(S),r.push(I.id));o=le(S),A=!0,console.warn(`[dsh-cost-meter] \u5DF2\u4ECE\u72EC\u7ACB\u5907\u4EFD\u6062\u590D\u914D\u7F6E\uFF0C\u81EA\u5B9A\u4E49\u4F59\u989D\u6E90 ${o.customBalances.length} \u6761`)}}catch(b){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u4E0D\u53EF\u7528\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\uFF08${b?.code??"invalid format"}\uFF09`)}let w=new e(o,n,t,r,{planSamples:s,planHourBuckets:c,openrouterPriceHashes:a,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:m,pricingHistory:g});w.legacyPricingHistory=f,w.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),w.quotaStatsNeedRepair&&(w.planSamples={}),(f||A)&&w.scheduleWrite();let M=Z(w.days);return M.length&&(M.includes(w.balanceRef?.date)&&(w.balanceRef=null),w.scheduleWrite()),w}account(t,o,n,i,r,s,c){if(this.closed)return;if(c!==void 0&&(!bn(c,i)||r!=="deepseek-official"||!gn(o,c)))throw new Error("Invalid official web request fee");let a=Ft(this.config,i,n,`${r||"deepseek"}:${o}`),l=Qn(r,o,a.prices,{mode:a.priceMatch==="exact"?"exact":"auto",overrides:a.priceOverrides}),d=l.entry??{cacheHit:0,cacheMiss:0,output:0},u={enabled:["deepseek-peak","utc-peak"].includes(l.billingMode)&&a.peakEnabled===!0,effectiveAtMs:Date.parse(a.peakEffectiveAt),windows:a.peakWindows,holidays:a.peakHolidays},m=c?c.requests*c.rateCny:l.priced?Vn(t,d,i,u):0,g=Zn(m,c?"CNY":l.currency,v(a).CNY),f=this.config.planBilling,y=He(this.config),A=c?"api":no(r,o,f,y,this.config.prices),w=A==="api"?g:0,M=x=>{let E=Number(x);return Number.isFinite(E)&&E>0?E:0},b={input:M(t?.input),output:M(t?.output),cacheRead:M(t?.cacheRead),cacheWrite:M(t?.cacheWrite),reasoning:M(t?.reasoning)},S=A==="plan"?Ot(r,f,o)??(Et(r,o,this.config.prices)?"go":null):null,I={...s?{meter:s}:{},date:Vt(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:S,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...b,calls:1,cost:g,apiCost:w,...ot(g,w,a)}};return ce(this,I)?(this.pendingAccounts.push(I),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};ce(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||Go)),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 Ae({version:Ko,config:Jt(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:Wo(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Me(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=jo(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=ye(o.pricingHistory,le(o.config),this.pricingHistory,!0);for(let i of Ze)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:Jt(le(o.config)),days:qo(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??vt(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=ye(t.pricingHistory,t.config),this.config=le(Lo(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){Me(this.path)!==this.diskRevision?this.flush():this.flushAsync();return}try{let t=Me(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(ae(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{we(this.path,()=>{qe(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=Z(n.days);i.includes(n.balanceRef?.date)&&(n.balanceRef=null);let r=(o===null||o===this.writeBase)&&!this.pendingPlanHourRepairs.length&&!i.length,s=r?n:ae(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});Qe(this.path,s,this.legacyPricingHistory),this.legacyPricingHistory=!1,r||this.adoptSnapshot(s),this.writeBase=r?s:this.snapshot(),this.pendingAccounts=[],this.pendingPlanHourRepairs=[],this.pendingWrite=!1,this.diskRevision=Me(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();qe(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,c=Wo();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:c,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},a=>{if(this.backgroundWrite=null,a.error){let u;try{u=this.readDiskSnapshot()}catch{}if(H(u?.writeReceipts).includes(c))a={merged:u,revision:Me(this.path)};else{a.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(a.error);return}}let l=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(a.ownDisk)this.writeReceipts=H(a.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=ae(t,this.snapshot(),a.merged,l,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(u),this.writeBase=a.merged}this.pendingAccounts=l,this.pendingPlanHourRepairs=d,this.pendingWrite=s!==this.writeGeneration||l.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=a.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(a){return this.fallbackWrite(a),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=Zt(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,de(o,i),o.cost+=i.cost??0,o.apiCost=(o.apiCost??0)+(i.apiCost??i.cost??0);for(let[r,s]of Object.entries(i.byProviderModel??{})){let c=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={...de({...Ee(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 o.date=t===void 0?"total":t,o}sumRange(t,o){let n=Zt(`${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,de(n,r),n.cost+=r.cost??0,n.apiCost=(n.apiCost??0)+(r.apiCost??r.cost??0);for(let[s,c]of Object.entries(r.byProviderModel??{})){let a=n.byProviderModel[s]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[s]={...de({...Ee(a)},c),input:a.input+(c.input??0),output:a.output+(c.output??0),cacheRead:a.cacheRead+(c.cacheRead??0),cacheWrite:a.cacheWrite+(c.cacheWrite??0),reasoning:a.reasoning+(c.reasoning??0),calls:a.calls+(c.calls??0),cost:a.cost+(c.cost??0),apiCost:(a.apiCost??0)+(c.apiCost??c.cost??0)}}}return n}today(){let t=Vt(Date.now()),o=this.days[t];return o===void 0?Zt(t):this.copyDay(o)}todayOfficialCost(){return Or(this.days[Vt(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{...Ee(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 Qo=e=>{try{let t=Pr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:Se,base:Vo,local:ee,pending:Nr,repairs:Zo,revision:Rr,backupHistory:Tr,transactionId:Ur,now:Dr,port:en,signal:Jo,lockId:Hr}=vr;try{let e=we(Se,()=>{let t=Qo(Se)===Rr,o=Z(ee.days);o.includes(ee.balanceRef?.date)&&(ee.balanceRef=null);let n=t&&!Zo.length&&!o.length,i=ee;if(!n){let r=new Je(ee.config,{},Se,[],{pricingHistory:ee.pricingHistory});r.writeBase=Vo,i=ae(Vo,ee,r.readDiskSnapshot(),Nr,Dr,Zo,{ownLocal:!0})}return i.writeReceipts=H([...i.writeReceipts??[],Ur]),Qe(Se,i,Tr),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Qo(Se)}},5e3,Hr);en.postMessage(e)}catch(e){en.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Jo,0,1),Atomics.notify(Jo,0),en.close()}