dsh-cost-meter 1.9.72 → 1.9.73

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 ts}from"node:worker_threads";import{statSync as ns}from"node:fs";function En(e){if(e==="auto")return!0;if(typeof e!="string"||!e||e.length>100||/^[+-]/.test(e))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:e}),!0}catch{return!1}}var Mt=["peakWindows","peakHolidays","peakSchedule"];function he(e){return Object.fromEntries(Mt.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Ke(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 $e(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={...he(n),...e.entry};return{...e,entry:i,billingMode:(i.peak||i.offPeak)&&Object.keys(he(i)).length&&i.billingMode!=="flat"?"deepseek-peak":e.billingMode}}function _n(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 St=[["CNY","\xA5",7.2],["USD","$",1],["EUR","\u20AC",.92],["GBP","\xA3",.75605],["JPY","JP\xA5",160],["KRW","\u20A9",1337.13],["INR","\u20B9",94.24],["HKD","HK$",7.846],["SGD","S$",1.2881],["AUD","A$",1.4738],["CAD","C$",1.4258],["CHF","CHF",.8384],["NZD","NZ$",1.8076],["BRL","R$",5.6637],["MXN","MX$",18.5931],["ZAR","R",16.9635],["TRY","\u20BA",50.368],["SEK","kr",10.0502],["NOK","NKr",9.5634],["DKK","Dkr",6.764],["PLN","z\u0142",3.9914],["THB","\u0E3F",33.915],["IDR","Rp",18244],["MYR","RM",4.0875],["PHP","\u20B1",63.813],["ILS","\u20AA",3.2107]],vn=St.map(([e])=>e),wi=new Map(St.map(e=>[e[0],e]));function qe(e){return typeof e=="string"&&wi.has(e)}function Ye(){let e={USD:1};for(let[t,,o]of St)t!=="USD"&&(e[t]=o);return e}var $=["costCny","apiCostCny","costEur","apiCostEur"],Mi=["USD","CNY","EUR"],Pn=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function q(e={}){let t=Ye(),o=e?.fxRates;if(o!==null&&typeof o=="object")for(let n of vn)n!=="USD"&&Pn(o[n])&&(t[n]=o[n]);return e?.currency!=="USD"&&qe(e?.currency)&&Pn(e?.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ge(e){let t=q(e);return Object.fromEntries(Mi.map(o=>[o,t[o]]))}function It(e,t,o){let n=q(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Qe(e){return Object.fromEntries($.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function _e(e,t,o=1){for(let n of $)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Nn(e,t){let o=n=>{let i=It(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of $)(!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 Si=["balance","goQuota",...["opendesign","anthropic","zai","minimax","kimi","openrouter","siliconflow","commandcode","clinepass","volcengine","mimo","baidu-coding","factory"].map(e=>"codingPlans."+e)],Ot=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ii=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",Oi=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function Rn(e){let t={};if(!Ot(e))return t;for(let o of Si){let n=e[o];if(!Ot(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!Ot(s)||!Ii(s.id)||!Oi(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 Tn=["today","summary","budget"],Dn=e=>e&&typeof e=="object"&&!Array.isArray(e);function Un(e){return Dn(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Dn(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Tn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Tn.some(o=>!t[o]))):{}}var Ct=/^(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 jn(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function Ze(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*jn(t,o+"."+i));return e.longContext&&(n.longContext={...Ze(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function Je(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 xt(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])=>!Ct.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]*jn(e,n+"."+r)))return!1}}return!0}var Hn={mistral:{models:{"zai-glm-5-3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/models/zai-glm-5-3-flash",checkedAt:"2026-11-05",notes:"Mistral-hosted Z.ai GLM 5.3 Flash at Mistral's published token prices. Batch/Priority/regional/tool fees excluded."},"deepseek-v4-1-flash-1017":{input:.3,output:1.2,cachedInput:.007,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/models/deepseek-v4-flash-1017",checkedAt:"2026-11-05",notes:"Mistral-hosted DeepSeek V4.1 Flash 1017 at Mistral's published token prices, which are double DeepSeek's own off-peak Flash rate. Batch/Priority/regional/tool fees excluded."}}}};var Et={"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."}}}};Et.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 _t={"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 Ci="https://platform.stepfun.ai/docs/en/guides/pricing/details",ve=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:Ci,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."}),Ln={models:{"step-5-preview":ve(1,.1,2.7),"step-3.7-flash":ve(.2,.04,1.15),"step-3.5-flash":ve(.1,.02,.3),"step-3.5-flash-2603":ve(.1,.02,.3),"step-1o-turbo-vision":ve(.36,.07,1.15)}};var Xe={openai:{models:{"gpt-6-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5}},"gpt-6.1-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5}},"gpt-6-luna":{input:.1,output:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,cacheHit:.02,output:.75,cacheWrite:.25}},"gpt-6-astra":{input:10,output:50,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,output:75,cacheWrite:25}},"gpt-5.6-sol":{input:4,output:20,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,cacheHit:.8,output:30,cacheWrite:10}},"gpt-5.6-terra":{input:2,output:12,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:18,cacheWrite:5}},"gpt-5.6-luna":{input:.2,output:1.2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,cacheHit:.04,output:1.8,cacheWrite:.5}},"gpt-5.5":{input:5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,cacheHit:1,output:45}},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Published direct Standard rates: short input30/output180; long input60/output270 USD/M. The pricing table labels short context<272K, but the model detail does not establish the exact equality/context counting rule. Intentionally unpriced pending clarification; no guessed boundary.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270},unpriced:!0},"gpt-5.4":{input:2.5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,cacheHit:.5,output:22.5}},"gpt-5.4-mini":{input:.75,output:4.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},"gpt-5.4-nano":{input:.2,output:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.02},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270}},"gpt-5.2":{input:1.75,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.175},"gpt-5.2-pro":{input:21,output:168,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-5.1":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5-mini":{input:.25,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-5-nano":{input:.05,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.005},"gpt-5-pro":{input:15,output:120,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4.1":{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"gpt-4.1-mini":{input:.4,output:1.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.1},"gpt-4.1-nano":{input:.1,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-4o":{input:2.5,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:1.25},"gpt-4o-2024-05-13":{input:5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4o-mini":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},o1:{input:15,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:7.5},"o1-pro":{input:150,output:600,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"o3-pro":{input:20,output:80,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},o3:{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"o4-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.275},"o3-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.55},"gpt-4-turbo-2024-04-09":{input:10,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4-0613":{input:30,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-0125":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-1106":{input:1,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-instruct":{input:1.5,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"davinci-002":{input:2,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"babbage-002":{input:.4,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"chat-latest":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for ChatGPT. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Codex. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5-search-api":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Search. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."}}},anthropic:{models:{"claude-fable-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-5-5":{input:4,cachedInput:.2,cacheWrite:5,output:20,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is8USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-5-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-haiku-4-5":{input:1,cachedInput:.1,cacheWrite:1.25,output:5,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is2USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-mythos-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-fable-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-mythos-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-opus-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-8":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-7":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-6":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-sonnet-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-6":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is6USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-5":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Current direct Claude Sonnet 4.5: maximum 200K context; 1M beta retired 2026-04-30 and over-limit requests fail. Standard rates for valid requests; 5-minute cache writes3.75USD/M, 1-hour writes6USD/M need TTL-specific accounting. Zen publishes a separate route with a long-context tier. Sources: https://platform.claude.com/docs/en/build-with-claude/context-windows and https://platform.claude.com/docs/en/release-notes/overview."}}},google:{models:{"gemini-3.8-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.7-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.6-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.1-flash-lite":{input:.25,cachedInput:.025,output:1.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid text/image/video input. Audio input0.50/cacheRead0.05 USD/M is a different modality; this generic token row cannot price that accurately. Cache storage1USD/M/hour and grounding excluded."}}},xai:{models:{"grok-4.7":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2,cacheHit:.4,output:4}},"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:.6,output:12}},"grok-4.3":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-multi-agent-0309":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-non-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-large-latest":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3-5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-latest":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-2603":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-latest":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-2512":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-latest":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-2512":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-latest":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-2512":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-latest":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"zai-glm-5-3":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-5":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-latest":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"codestral-2508":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-latest":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-embed-2505":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."},"codestral-embed":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."}}},"z-ai":{models:{"glm-5.3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3-flashx":{input:.37,output:1.25,cachedInput:.075,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.2":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.1":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5":{input:1,output:3.2,cachedInput:.2,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flashx":{input:.07,output:.4,cachedInput:.01,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-x":{input:2.2,output:8.9,cachedInput:.45,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-air":{input:.2,output:1.1,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-airx":{input:1.1,output:4.5,cachedInput:.22,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4-32b-0414-128k":{input:.1,output:.1,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v":{input:.3,output:.9,cachedInput:.05,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5v":{input:.6,output:1.8,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-ocr":{input:.03,output:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Official direct token pricing row. Separate Layout Parsing API can charge per page; this token entry cannot price page billing."}}},"opencode-zen":{models:{"big-pickle":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.5-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.1-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.0-flash-fin-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3-ultra-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3.5-lightning-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"muse-spark-1.3-contributor-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"jev-1.13-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0},"jev-1.13":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.042,output:0},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:3.2,cachedInput:.2},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"kimi-k2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.6,output:3,cachedInput:.1},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:7.5,cachedInput:.5,cacheWrite:3.125},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5},"qwen3.6-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05,cacheWrite:.625},"qwen3.5-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25},"deepseek-v4.1-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"deepseek-v4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.74,output:3.48,cachedInput:.145},"deepseek-v4-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"deepseek-v4-flash-vision-exp":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"claude-fable-5-1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:.25,cacheWrite:12.5},"claude-fable-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5},"claude-opus-5-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.2,cacheWrite:5},"claude-opus-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-8":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-sonnet-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5},"claude-sonnet-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75},"claude-sonnet-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75,longContext:{aboveInputTokens:2e5,cacheMiss:6,output:22.5,cacheHit:.6,cacheWrite:7.5}},"claude-haiku-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:5,cachedInput:.1,cacheWrite:1.25},"gemini-3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.7-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.5-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:9,cachedInput:.15},"gemini-3.5-flash-lite":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:2.5,cachedInput:.03},"gemini-3.1-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:18,cacheHit:.4}},"gemini-3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.3,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:.6}},"grok-build-0.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:2,cachedInput:.2},"muse-spark-1.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"muse-spark-1.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"gpt-6-astra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25}},"gpt-6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5}},"gpt-6.1-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10}},"gpt-5.6-terra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}},"gpt-5.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:30,cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,output:45,cacheHit:1}},"gpt-5.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:15,cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,output:22.5,cacheHit:.5}},"gpt-5.4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.75,output:4.5,cachedInput:.075},"gpt-5.4-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.25,cachedInput:.02},"gpt-5.3-codex-spark":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.3-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:10,cachedInput:.125},"gpt-5.1-codex-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.25,output:2,cachedInput:.025},"gpt-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.05,output:.4,cachedInput:.005}}},"opencode-go":{models:{"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"longcat-2.0":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.6-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"mimo-v2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06,cacheWrite:.375},"muse-spark-1.3-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"muse-spark-1.2-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5,longContext:{aboveInputTokens:256e3,cacheMiss:1.2,output:4.8,cacheHit:.12,cacheWrite:1.5}},"deepseek-v4.1-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-pro":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.66,output:1.98,cacheHit:.022},input:.66,output:1.98,cachedInput:.022,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:1.32,output:3.96,cacheHit:.044}},"deepseek-v4-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-flash-vision-exp":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"hy4-preview":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.834,output:2.501,cachedInput:.042},hy3:{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.58,cachedInput:.035},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}}}}},ee=Object.fromEntries([...new Set([...Object.keys(Xe),...Object.keys(_t)])].map(e=>[e,{models:{...Xe[e]?.models,..._t[e]?.models}}]));ee.stepfun=Ln;var Fn=structuredClone(ee);for(let[e,t]of Object.entries(Et))ee[e]={models:{...ee[e]?.models,...t.models}};var Bn=structuredClone(ee);for(let[e,t]of Object.entries(Hn))ee[e]={models:{...ee[e]?.models,...t.models}};var Wn={"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 zn=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,xi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,Ei=/^(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 vt(e,t){if(typeof t!="string"||t.length===0)return!1;if(zn.test(t)){let n=t.replace(new RegExp(zn.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(xi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||Ei.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var et="https://amr-api.open-design.ai/api/v1",vs=et+"/public/model-prices",ke=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],Ps=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var _i=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function Kn(e){return e===void 0||e===""?"":typeof e=="string"&&_i(e.trim())?e.trim():null}var tt=["vercel","copilot","cline","qoder","qoder-cn","qoder-global","trae","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cursor","windsurf","augment","roo","codebuddy"],B={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:["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"],scnet:["scnet","scnet-tokenplan","scnet-token-plan"],mimo:["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"],factory:["factory","droid","factory-a","factory-g","factory-o"]};var $n=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function qn({normalizePrice:e,normalizeCustomPrice:t}){function o(b,w){let S=w?.models??{};if(typeof b=="string"&&b.length>0){let E=Object.hasOwn(S,b)?S[b]:void 0;if(E!==void 0)return E}return w?.default??{cacheHit:0,cacheMiss:0,output:0}}function n(b){return String(b??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function i(b){return n(b).replace(/[^\p{L}\p{N}]+/gu,"")}function r(b,w=!0,S=!0){let E=n(b);return w&&/[-_./:@](?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(E)?E.slice(0,-5):w&&S&&/[-_./:@]\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(E)?E.slice(0,-7):E.replace(/[-_./:@](?:\d{4}-?\d{2}-?\d{2}|v\d+(?:\.\d+)*|\d+k|latest)$/,"")}function s(b,w,S=b,E=!0,_=!0){if(typeof b!="string"||b.length===0)return null;let R=Array.isArray(w)?w.filter(x=>typeof x=="string"&&x.length>0):[],I=R.find(x=>x===S);if(I!==void 0)return I;let M=b.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(M))return null;for(;;){let x=i(M);if(x.length===0)return null;let U=R.filter(J=>i(J)===x);if(U.length>0)return U.length===1?U[0]:null;let re=r(M,E,_);if(re===M.toLowerCase())return null;M=re}}let c=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),a={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 l(b){return["deepseek-peak","utc-peak"].includes(b?.billingMode)?b.billingMode:"flat"}function d(b,w,S,E,_){if(typeof b!="string")return null;if(Object.hasOwn(w,b))return b;if(E!=="auto")return null;let R=b.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),I=R.search(/[/:]/);if(I>0){let M=R.slice(0,I).trim().toLowerCase(),x=R.slice(I+1).trim();if(Object.hasOwn(a,M)&&(M===S||(S==="opencode-zen"||S==="opencode-go")&&(a[M].test(x)||s(x,Object.keys(M==="deepseek"?_?.models??{}:_?.providers?.[M]?.models??{}),x,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)!==null)))R=x;else if(Object.hasOwn(a,M))return null}return s(R,Object.keys(w),b,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)}function u(b,w,S,E){let _=E?.mode==="exact"?"exact":"auto",R=E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{},I=w,M=b,x=(b===""?"deepseek":b)+":"+w,U=R[x];if(U==="__custom__"){let h=t(S?.custom?.[x]);return{entry:h,billingMode:h?.billingMode??"flat",priced:h!==null,currency:h?.currency??"USD"}}if(U==="__local__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(typeof U=="string"&&U.length>0){let h=U.indexOf(":");if(h>0&&U.slice(h+1).length>0?(M=U.slice(0,h).trim().toLowerCase(),I=U.slice(h+1)):I=U,M==="deepseek"&&I==="__default__"){let y=S?.default??{cacheHit:0,cacheMiss:0,output:0},T=e(y);return T===null?{entry:null,billingMode:"flat",priced:!1}:{entry:T,billingMode:"deepseek-peak",priced:T.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(M)){let h=d(I,S?.providers?.[M]?.models??{},"opencode-go",_,S);h===null?M="opencode-go":I=h}if(ke.includes(M)&&M!=="opendesign"&&d(I,S?.providers?.[M]?.models??{},M,_,S)===null&&(M="opendesign"),C(M,I))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(M==="openrouter"){let h=S?.providers?.openrouter?.models??{},y=Object.hasOwn(h,I)?e(h[I]):null;return{entry:y,billingMode:"flat",priced:y!==null&&y.unpriced!==!0}}if(M===""||M==="deepseek"||M.includes("deepseek")){let h=S?.models??{},y=d(I,h,"deepseek",_,S);if(y!=null){let D=h[y],H=e(D);return H===null||H.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:H,billingMode:"deepseek-peak",priced:!0}}if(_==="auto"){let D=null,H=-1,Y=!1,z="flat";for(let[se,ce]of Object.entries(S?.providers??{})){if(c.has(se))continue;let Ee=ce?.models??{},X=d(I,Ee,se,_,S);if(X===null)continue;let xn=e(Ee[X]);if(xn===null)continue;let wt=+(X===I||i(X)===i(I));wt>H?(D=xn,H=wt,Y=!1,z=l(Ee[X])):wt===H&&(Y=!0)}if(Y)return{entry:null,billingMode:"flat",priced:!1};if(D!==null)return{entry:D,billingMode:z,priced:D.unpriced!==!0}}let T=o(I,S),F=e(T);return F===null?{entry:null,billingMode:"flat",priced:!1}:{entry:F,billingMode:"deepseek-peak",priced:F.unpriced!==!0}}let J=S?.providers?.[M]?.models??{},L=d(I,J,M,_,S);if(L===null&&c.has(M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&Object.hasOwn(a,M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&_==="auto"){let h=null,y=-1,T=!1,F="flat";for(let[D,H]of[["deepseek",{models:S?.models??{}}],...Object.entries(S?.providers??{})]){if(D===M||c.has(D))continue;let Y=H?.models??{},z=d(I,Y,D,_,S);if(z===null)continue;let se=e(Y[z]);if(se===null||D==="mistral"&&z.startsWith("deepseek-")&&z!==I&&!M.includes("mistral")&&!/^mistral[/:]/i.test(String(I).trim()))continue;let ce=+(z===I||i(z)===i(I));ce>y?(h=se,y=ce,T=!1,F=D==="deepseek"?"deepseek-peak":l(Y[z])):ce===y&&(T=!0)}if(T)return{entry:null,billingMode:"flat",priced:!1};if(h!==null)return{entry:h,billingMode:F,priced:h.unpriced!==!0}}if(L===null)return{entry:null,billingMode:"flat",priced:!1};let f=e(J[L]);return f===null||f.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:f,billingMode:l(J[L]),priced:!0}}function p(b,w,S){let E=w?.models??{},_=Object.hasOwn(E,b)?b:S==="auto"?s(b,Object.keys(E),b,w?.snapshotTags!==!1,w?.shortSnapshotTags!==!1):null;if(_==null)return null;let R=E[_],I=e(R);return I===null||I.unpriced===!0?null:{entry:I,billingMode:"deepseek-peak",priced:!0}}function g(b){return typeof b!="string"||b.length===0?!1:b.startsWith("modlens-")||b==="deepseek-modlens"}function m(b){if(typeof b!="string"||b.length===0)return null;if(b==="deepseek-modlens")return"deepseek-official";if(b.startsWith("modlens-")){let w=b.slice(8);return w.length>0?w:null}return null}let k=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),O=["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 C(b,w){if(typeof b=="string"&&k.has(b))return!0;let S=typeof w=="string"?n(w):"";return O.some(E=>S.startsWith(E))}function N(b,w,S,E,_){let R=_?.[(b||"deepseek")+":"+w];if(!b||E==="exact"||typeof w!="string"||C(b,w)||["our-free-model","our-free-model-region"].includes(b)||typeof R=="string"&&R.length>0||Object.hasOwn(S?.providers?.[b]?.models??{},w))return null;let I=w.indexOf("/");if(I<=0||I===w.length-1)return null;let M=w.slice(0,I).toLowerCase(),x=w.slice(I+1),U={codex:"openai",claude:"anthropic",gemini:"google","ollama-cloud":"ollama-cloud",volcengine:"volcengine",ark:"ark"},re=/^(?:dsh-)?magpie(?:$|-)/.test(b),J=Object.hasOwn(U,M)||c.has(M)||["workbuddy","workbuddy-ai","qoder","qoder-cn","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cline","copilot","vercel"].includes(M);if(!re&&(!J||Object.hasOwn(a,b)||c.has(b))||/(?:^|-)free$/.test(M)&&!Object.hasOwn(S?.providers??{},M))return null;let L=U[M]??M;return L==="deepseek"&&d(x,S?.models??{},"deepseek","auto",S)===null?null:{provider:Object.hasOwn(U,M)||c.has(L)||Object.hasOwn(a,L)||Object.hasOwn(S?.providers??{},L)||C(L,x)?L:b,model:x}}function A(b,w,S,E){let _=typeof b=="string"?b.trim().toLowerCase():"",R=_.startsWith("llm-")?_.slice(4):_,I=N(R,w,S,E?.mode,E?.overrides);if(I&&(R=I.provider,w=I.model,E={...E,overrides:{}}),["our-free-model","our-free-model-region"].includes(R)&&E?.overrides?.[R+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let M=$e(P(R,w,S,E),R,S);return["volcengine","ark"].includes(R)&&S?.volcenginePeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"volcengine"}}:R==="ollama-cloud"&&S?.ollamaPeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"&&(S?.ollamaTaggedPeak===!1?$n.has(typeof w=="string"?w.trim().toLowerCase():""):s(w,[...$n])!==null)?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"ollama"}}:M}function P(b,w,S,E){let _=u(b,w,S,E);if(_.currency&&!_.local)return _;if(_.priced&&!_.local||b===""||b==="deepseek"||b.includes("deepseek"))return v(_,S);let I=(E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{})[b+":"+w];if(typeof I!="string"||I.length===0||I==="__local__"||I.includes(":"))return v(_,S);let M=E?.mode==="exact"?"exact":"auto";return v(p(I,S,M)??_,S)}function v(b,w){return b.currency?b:b.priced?w?.currency==="CNY"&&b.entry?.cny?{...b,entry:Je(b.entry),currency:"CNY"}:{...b,currency:b.billingMode==="deepseek-peak"&&w?.currency==="CNY"?"CNY":"USD"}:{...b,currency:"USD"}}return A}var vi=qn({normalizePrice:W,normalizeCustomPrice:Ne});var Gn="2026-08-01T00:00:00Z",Tt="2026-08-22T16:00:00Z",ot=["2026-09-25","2026-09-26","2026-09-27","2026-10-01","2026-10-02","2026-10-03","2026-10-04","2026-10-05","2026-10-06","2026-10-07"],Pt="2026-09-10T04:00:00Z",Pi="2026-08-31T00:00:00Z",Yn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Ni(e){if(!Number.isFinite(e)||e<Date.parse(Tt))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(Tt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ri(e,t=ot){if(!Number.isFinite(e)||e<Date.parse(Tt)||!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 Ti=(e,t)=>Ri(e,t)??Ni(e),Di="2026-08-16T16:00:00Z";var Qn=[{start:1,end:4},{start:6,end:10}],me={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"}}}},Vn=Object.freeze(Object.keys(me["opencode-go"].models)),ne={...me};ne.opendesign={models:Wn};for(let[e,t]of Object.entries(ee)){let o=me[e]?.models??{};ne[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function Me(e,t=me){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(ne)){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(p=>!l.has(p)))continue;let d=W(r[c]),u=W(s[c]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[c]=structuredClone(a))}}}function Zn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Xe[o]?.models}}]));Me(e,t)}function Jn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Fn[o]?.models}}]));Me(e,t)}function Xn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Bn[o]?.models}}]));Me(e,t)}function eo(e){Me(e,Object.fromEntries(Object.entries(ne).filter(([t])=>t!=="stepfun")))}var Ui={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 Nt(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 to(e){let t=e==="CNY"?ji:Ui,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):Nt(i,e,Pt)]));return o["deepseek-v4.1-flash"]=Nt(t.models["deepseek-v4-flash-vision-exp"],e,Pt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:Nt(t.default,e,Pt)}}var Ut=to("USD"),no=to("CNY");function jt(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 le(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 W(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)||!Ke(e))return null;let t={...le(e),...he(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,...le(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=le(e.cny)}let n=le(e.offPeak);n!==void 0&&(t.offPeak=n);let i=le(e.peak);i!==void 0&&(t.peak=i);let r=le(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,...le(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]=le(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)),xt(t)?t:null}function Pe(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function de(e){return Pe(e).replace(/[\s._\-\u2010-\u2015\u2212]+/gu,"")}function Hi(e,t=!0,o=!0){let n=Pe(e),i=n.match(/[-_./:@](\d{4}-\d{2}-\d{2}|\d{8}|\d{6}|\d{4})$/);if(i){let r=i[1].replaceAll("-","");if(r.length===4&&!t||r.length===6&&(!t||!o))return n;let s=r.length===4?2e3:r.length===6?2e3+Number(r.slice(0,2)):Number(r.slice(0,4)),c=Number(r.slice(-4,-2)),a=Number(r.slice(-2)),l=new Date(Date.UTC(s,c-1,a));return s>=2e3&&l.getUTCFullYear()===s&&l.getUTCMonth()===c-1&&l.getUTCDate()===a?n.slice(0,i.index):n}return n.replace(/[-_./:@]latest$/,"")}function oo(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(l=>typeof l=="string"&&l.length>0):[],s=r.find(l=>l===o);if(s!==void 0)return{id:s,rank:3};let c=e.normalize("NFKC").trim(),a=2;for(;;){let l=de(c);if(l.length===0)return null;let d=r.filter(p=>de(p)===l);if(d.length>0)return{id:d.length===1?d[0]:null,rank:a};if(/[:((]\s*(?:free|online)\b/i.test(c))return null;let u=Hi(c,n,i);if(u===c.toLowerCase())return null;c=u,a=1}}function Ht(e,t,o=e,n=!0,i=!0){return oo(e,t,o,n,i)?.id??null}var we=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),ue={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 Rt(e){return["deepseek-peak","utc-peak"].includes(e?.billingMode)?e.billingMode:"flat"}function Ae(e,t,o,n,i){if(typeof e!="string")return null;if(Object.hasOwn(t,e))return{id:e,rank:3};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=c==="deepseek-ai"?"deepseek":c,l=r.slice(s+1).trim();if(Object.hasOwn(ue,a)&&(a===o||["opencode-zen","opencode-go","zen","opencode","opencode-go-plus"].includes(o)&&(ue[a].test(l)||Ht(l,Object.keys(a==="deepseek"?i?.models??{}:i?.providers?.[a]?.models??{}),l,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=l;else if(Object.hasOwn(ue,a))return null}return oo(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Li(e,t,o,n,i){return Ae(e,t,o,n,i)?.id??null}function Dt(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 u=Ne(o?.custom?.[a]);return{entry:u,billingMode:u?.billingMode??"flat",priced:u!==null,currency:u?.currency??"USD"}}if(l==="__local__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(typeof l=="string"&&l.length>0){let u=l.indexOf(":");if(u>0&&l.slice(u+1).length>0?(c=l.slice(0,u).trim().toLowerCase(),s=l.slice(u+1)):s=l,c==="deepseek"&&s==="__default__"){let p=o?.default??{cacheHit:0,cacheMiss:0,output:0},g=W(p);return g===null?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:"deepseek-peak",priced:g.unpriced!==!0}}}if(!G(c,s)&&c!=="openrouter"){let u=o?.providers?.[c]?.models??{},p=Ae(s,u,c,i,o);if(p){let g=p.id===null?null:u[p.id],m=W(g);return{entry:m,billingMode:Rt(g),priced:m!==null&&m.unpriced!==!0}}}if(/(?:^|[-_])free(?:$|[-_])/.test(c)&&!["our-free-model","our-free-model-region"].includes(c))return{entry:null,billingMode:"flat",priced:!1};if(c!=="opencode-go"&&B.go.includes(c))return Dt("opencode-go",s,o,{...n,overrides:{}});if(ke.includes(c)&&c!=="opendesign")return Dt("opendesign",s,o,{...n,overrides:{}});if(G(c,s))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(c==="openrouter"){let u=o?.providers?.openrouter?.models??{},p=Object.hasOwn(u,s)?W(u[s]):null;return{entry:p,billingMode:"flat",priced:p!==null&&p.unpriced!==!0}}if(["","deepseek","deepseek-official","deepseek-account"].includes(c)){let u=o?.models??{},p=Ae(s,u,"deepseek",i,o);if(p){let g=p.id===null?null:u[p.id],m=W(g);return m===null||m.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:m,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let g=null,m=-1,k=!1,O="flat";for(let[C,N]of Object.entries(o?.providers??{})){if(we.has(C))continue;let A=N?.models??{},P=Ae(s,A,C,i,o);if(!P)continue;let v=P.id===null?null:A[P.id],b=W(v),w=P.rank;w>m?(g=b,m=w,k=P.id===null||b===null,O=Rt(v)):w===m&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(g!==null)return{entry:g,billingMode:O,priced:g.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}if(we.has(c))return{entry:null,billingMode:"flat",priced:!1};let d=i==="auto"&&!l&&/^deepseek/i.test(Pe(s).replace(/^deepseek(?:-ai)?[/:]\s*/,""));if(Object.hasOwn(ue,c)&&!d)return{entry:null,billingMode:"flat",priced:!1};if(i==="auto"){let u=null,p=-1,g=!1,m="flat";for(let[k,O]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(k===c||we.has(k))continue;let C=O?.models??{},N=Ae(s,C,k,i,o);if(!N)continue;let A=N.id,P=A===null?null:C[A],v=W(P);if(k==="mistral"&&A?.startsWith("deepseek-")&&A!==s&&!c.includes("mistral")&&!/^mistral[/:]/i.test(String(s).trim()))continue;let b=N.rank;b>p?(u=v,p=b,g=A===null||v===null,m=k==="deepseek"?"deepseek-peak":Rt(P)):b===p&&(g=!0)}if(g)return{entry:null,billingMode:"flat",priced:!1};if(u!==null)return{entry:u,billingMode:m,priced:u.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}function Fi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Ht(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],s=W(r);return s===null||s.unpriced===!0?null:{entry:s,billingMode:"deepseek-peak",priced:!0}}var Bi=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),Wi=["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 G(e,t){if(typeof e=="string"&&Bi.has(e))return!0;let o=typeof t=="string"?Pe(t):"";return Wi.some(n=>o.startsWith(n))}function zi(e,t,o,n,i){let r=i?.[(e||"deepseek")+":"+t];if(!e||n==="exact"||typeof t!="string"||G(e,t)||/(?:^|[-_])free(?:$|[-_])/.test(e)||typeof r=="string"&&r.length>0||Ae(t,o?.providers?.[e]?.models??{},e,"auto",o))return null;let s=t.normalize("NFKC").trim(),c=s.indexOf("/");if(c<=0||c===s.length-1)return null;let a=s.slice(0,c).trim().toLowerCase().replace(/^llm-/,""),l=s.slice(c+1).trim(),d={codex:"openai",claude:"anthropic",gemini:"google","deepseek-ai":"deepseek","deepseek-official":"deepseek","ollama-cloud":"ollama-cloud",volcengine:"volcengine",ark:"ark"},u=/^(?:dsh-)?magpie(?:$|-)/.test(e),p=["our-free-model","our-free-model-region"].includes(a),g=Object.hasOwn(d,a)||we.has(a)||Object.hasOwn(o?.providers??{},a)||Object.values(B).some(k=>k.includes(a))||tt.includes(a)||p;if(!u&&(!g||we.has(e)||B.go.includes(e))||/(?:^|[-_])free(?:$|[-_])/.test(a)&&!p)return null;let m=Object.hasOwn(d,a)?d[a]:B.go.includes(a)?"opencode-go":a;return!u&&Object.hasOwn(ue,e)&&Object.hasOwn(ue,m)&&m!==e&&(m!=="deepseek"||!/^deepseek/i.test(Pe(l)))||Object.hasOwn(ue,m)&&Li(l,m==="deepseek"?o?.models??{}:o?.providers?.[m]?.models??{},m,"auto",o)===null?null:{provider:g||Object.hasOwn(d,a)||we.has(m)||Object.hasOwn(ue,m)||Object.hasOwn(o?.providers??{},m)||G(m,l)?m:e,model:l}}function io(e,t,o,n){if(o?.legacyModelMatching===!0)return vi(e,t,o,n);let i=typeof e=="string"?e.trim().toLowerCase():"",r=i.startsWith("llm-")?i.slice(4):i,s=Object.fromEntries(["our-free-model:*","our-free-model-region:*"].filter(a=>n?.overrides?.[a]==="__free__").map(a=>[a,"__free__"]));for(let a=0;a<8;a++){let l=zi(r,t,o,n?.mode,n?.overrides);if(!l)break;r=l.provider,t=l.model,n={...n,overrides:s}}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 c=$e(Ki(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&c.entry&&c.billingMode==="deepseek-peak"?{...c,entry:{...c.entry,peakSchedule:c.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&c.entry&&c.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?Yn.has(typeof t=="string"?t.trim().toLowerCase():""):Ht(t,[...Yn])!==null)?{...c,entry:{...c.entry,peakSchedule:c.entry.peakSchedule??"ollama"}}:c}function Ki(e,t,o,n){let i=Dt(e,t,o,n);if(i.currency&&!i.local)return i;if(i.priced&&!i.local||["","deepseek","deepseek-official","deepseek-account"].includes(e))return nt(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 nt(i,o);let c=n?.mode==="exact"?"exact":"auto";return nt(Fi(s,o,c)??i,o)}function nt(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:Je(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(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=W(e);if(!t)return null;let o={...t,currency:e.currency,billingMode:e.billingMode==="deepseek-peak"?"deepseek-peak":"flat"};return xt(o)?o:null}function $i(e,t,o,n=ot){if(!Array.isArray(o)||o.length===0||Ti(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 qi(e,t,o){let n=jt(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(a,l="base")=>Ze(a,n,l),r=_n(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(Pi))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($i(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 Lt(e,t,o,n){let i=qi(t,o,n),r=g=>{let m=Number(g);return Number.isFinite(m)&&m>0?m: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,p=(s*i.cacheMiss+c*i.output+a*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(p)&&p>0?p:0}function Ft(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 Bt={enabled:!1,providerPrefix:"local",referenceModel:"deepseek-flash",priceTier:"offPeak"},Yi=["base","offPeak","peak"];var Gi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ro=e=>typeof e=="string"&&e.trim().length>0&&e.trim().length<=512;function Wt(e){let t=Gi(e)?e:{};return{enabled:t.enabled===!0,providerPrefix:ro(t.providerPrefix)?t.providerPrefix.trim().toLowerCase():Bt.providerPrefix,referenceModel:ro(t.referenceModel)?t.referenceModel.trim():Bt.referenceModel,priceTier:Yi.includes(t.priceTier)?t.priceTier:Bt.priceTier}}import{readFileSync as Wr,renameSync as li,statSync as zr}from"node:fs";import{randomUUID as ui}from"node:crypto";var so=5/1e3,Qi=Date.parse("2026-11-01T00:00:00+08:00"),co=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function ao(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 lo(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<Qi?0:so):e.source===void 0&&e.rateCny===so}var zt=["input","output","cacheRead","cacheWrite","reasoning","calls"],oe=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function ge(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=$.filter(u=>i.every(p=>oe(p?.[u]))),c=Object.fromEntries([...zt,"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 p of Object.keys(c)){let g=p==="apiCost"?u.apiCost??u.cost:u[p]??0;if(!oe(g)){l=!1;break}c[p]+=g}if(!l||c.apiCost>c.cost+1e-8){l=!1;break}for(let[p,g]of Object.entries(u.byProviderModel??{})){if(a.has(p)&&a.get(p)===null)continue;let m=a.get(p)??Object.fromEntries(Object.keys(c).map(O=>[O,0])),k=g!==null&&typeof g=="object";for(let O of Object.keys(m)){if($.includes(O)&&!oe(g?.[O])){delete m[O];continue}let C=O==="apiCost"?g?.apiCost??g?.cost:g?.[O]??0;if(!oe(C)){k=!1;break}m[O]+=C}a.set(p,k?m:null)}}if(!l||!Object.values(c).every(oe)||!zt.every(u=>oe(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,p]of a){let g=n.byProviderModel?.[u];if(!(!p||!g||!p.calls||!Object.values(p).every(oe)||!zt.every(m=>p[m]===(g[m]??0)))&&!(Math.abs(p.cost-(g.cost??0))<=1e-8&&Math.abs(p.apiCost-(g.apiCost??g.cost??0))<=1e-8&&s.every(m=>!oe(p[m])||Math.abs(p[m]-(g[m]??0))<=1e-8))){for(let m of s)oe(p[m])&&(g[m]=p[m]);g.cost=p.cost,g.apiCost=p.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as Vi,MessageChannel as Zi,receiveMessageOnPort as uo}from"node:worker_threads";import{randomUUID as Ji}from"node:crypto";import{unlinkSync as Xi,rmdirSync as er}from"node:fs";import{join as tr}from"node:path";function po(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new Zi,s=new Int32Array(new SharedArrayBuffer(4)),c=!1,a,l,d,u=Ji(),p=new Promise(O=>{a=O}),g=new Vi(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),m=O=>{if(!c){c=!0,clearTimeout(k);try{t(O)}finally{i.close(),g.terminate(),a()}}},k=setTimeout(()=>{l={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},g.terminate().then(()=>m(l))},o);return k.unref?.(),i.on("message",m),g.on("error",O=>{d={error:{message:O.message,code:O.code}}}),g.on("exit",O=>{if(!c){try{Xi(tr(`${e.path}.lock`,`${process.pid}-${u}`)),er(`${e.path}.lock`)}catch{}m(uo(i)?.message??l??d??{error:{message:`Ledger worker exited (${O})`}})}}),{promise:p,wait(O=8e3){let C=Date.now()+O;for(;!c;){let N=uo(i);if(N){m(N.message);break}if(Date.now()>=C)return!1;Atomics.wait(s,0,0,Math.min(50,C-Date.now()))}return!0}}}function Kt(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 Vo,readdirSync as Nr,writeFileSync as ti,readFileSync as ni,renameSync as Rr,unlinkSync as gt,rmdirSync as mt,statSync as Tr,copyFileSync as Dr,openSync as Zo,fsyncSync as Jo,closeSync as Xo,constants as Ur}from"node:fs";import{dirname as oi,join as He}from"node:path";import{randomUUID as ii}from"node:crypto";import{isDeepStrictEqual as K}from"node:util";var fo="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var ho="https://api.factory.ai/api/billing/limits";var mo=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};import{homedir as $t}from"node:os";import{basename as dc,dirname as pc,join as go,resolve as nr}from"node:path";var bo=".dsh",fc=`~/${bo}`,or="DSH_HOME",ir=".agents",hc=`~/${ir}`;function rr(){return go($t(),bo)}function sr(e){return e==="~"?$t():e.startsWith("~/")||e.startsWith("~\\")?go($t(),e.slice(2)):e}function cr(e,t,o,n){let i=t[o];return nr(sr(e??(i!==void 0&&i.trim().length>0?i:n())))}function qt(e,t=process.env){return cr(e,t,or,rr)}var Yt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var ur=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var jc=672*60*60,Hc=744*60*60;var Qc=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),Vc=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 dr={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"}},Re=Object.keys(dr);var Qt="https://platform.xiaomimimo.com/api/v1",pr={usage:`${Qt}/tokenPlan/usage`,detail:`${Qt}/tokenPlan/detail`,balance:`${Qt}/balance`},Ra=B.mimo;var fr="open.volcengineapi.com";var hr="2024-01-01",mr=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var gr={"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 ko(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var Ta=Object.fromEntries(Object.entries(gr).map(([e,t])=>[ko(e),t]));var Da=B.scnet;var br={"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}},Ua=Object.fromEntries(Object.entries(br).map(([e,t])=>[ko(e),t])),ja=B.qwen;var Ha={opendesign:[et+"/workspaces/{workspaceId}/billing/preflight",et+"/workspaces/{workspaceId}/wallet/balance"],factory:[ho],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:mr.map(e=>`https://${fr}/?Action=${e}&Version=${hr}`),mimo:[pr.usage],"baidu-coding":[fo],workbuddy:[]};function Ao(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 yr={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"},kr=Object.entries(yr).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function it(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=kr.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 ie=[...Re,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Vt={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"},Mo=400,So=2160*36e5,Ga=168*36e5;var Ar=840*36e5;function Io(e,t){let o=String(e??"").normalize("NFKC").trim().toLowerCase().replace(/^llm-/,"");if(!o||typeof t!="string"||G(o,t)||/(?:^|[-_])free(?:$|[-_])/.test(o)||o==="opencode-zen"||ie.includes(o)||Object.values(B).some(c=>c.includes(o))||it(e)!==null)return null;let n=t.normalize("NFKC").trim().split("/").map(c=>c.trim());if(n.some(c=>!c)||n.slice(0,-1).some(c=>/(?:^|[-_])free(?:$|[-_])/.test(c.toLowerCase())||G(c.toLowerCase().replace(/^llm-/,""),""))||G("",n.at(-1)))return null;let i=/^(?:dsh-)?magpie(?:$|-)/.test(o),r=["openai","google","deepseek","deepseek-ai","deepseek-official","moonshot","z-ai","xai","alibaba","tencent","xiaomi","upstage","nvidia","mistral","meta","meituan","gemini","claude","ollama-cloud","ark"],s={anthropic:{vendor:"anthropic",model:/^claude/i},minimax:{vendor:"minimax",model:/^minimax/i},stepfun:{vendor:"stepfun",model:/^step-/i},codex:{vendor:"openai",model:/^(?:gpt|o\d|codex)/i}};for(let c=0;c<Math.min(n.length-1,8);c++){let a=n[c].toLowerCase().replace(/^llm-/,"");if(a==="openrouter"||a==="opencode-zen"||r.includes(a)||/(?:^|[-_])free(?:$|[-_])/.test(a)||G(a,n.slice(c+1).join("/")))return null;let l=Object.hasOwn(s,a)?s[a]:null;if(l){let d=n.slice(c+1);if(d[0].toLowerCase()===l.vendor&&d.shift(),d.length!==1||!l.model.test(d[0]))return null}for(let[d,u]of Object.entries(B))if(u.includes(a)||d===a)return{id:d,provider:a};if(ie.includes(a))return{id:a,provider:a};if(!i&&!tt.includes(a))return null}return null}function Zt(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(ie.includes(i))return i;if(n.length===0)return null;for(let[s,c]of Object.entries(B))if(c.includes(n))return s;if(ie.includes(n))return n;let r=it(e);return r!==null?r:G(n,o)||/(?:^|[-_])free(?:$|[-_])/.test(n)||n==="opencode-zen"?null:typeof o=="string"&&o.normalize("NFKC").includes("/")?Io(e,o)?.id??null:it(e,o)}var wo=new WeakMap;function wr(e){let t=wo.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(de)),n=new Set,i=new Set(Vn.map(de));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(de(r))&&n.add(de(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},wo.set(e,t)}return t}function Jt(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=de(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:s}=wr(o);return!r.has(i)&&s.has(i)}function Oo(e,t,o,n,i){if(co(e,t))return"api";let r=Zt(e,o,t);r===null&&Jt(e,t,i)&&(r="go");let s=o?.models;if(s!==null&&typeof s=="object"){let d=s[`${e}:${t}`];if(d==="plan"||d==="api")return d;if(r!==null){let u=s[`${r}:${t}`];if(u==="plan"||u==="api")return u}}let c=o?.providers;for(let d of[e,r]){if(d==null)continue;let u=c?.[d];if(u==="plan"||u==="api")return u}if(r===null)return"api";let a=Io(e,t),l=a?.id===r?a.provider:e;return r==="go"&&/^(?:llm-)?(?:dsh-opencode-go|opencode-go(?:-plus)?)$/i.test(String(l).trim())||r==="kimi"&&/^(?:llm-)?kimi-coding(?:-plan)?$/i.test(String(l).trim())||r==="minimax"&&/^(?:llm-)?minimax-(?:m-?plan|token-plan)$/i.test(String(l).trim())||n instanceof Set&&n.has(r)?"plan":"api"}function rt(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>ie.includes(n)));let t=new Set,o=e?.codingPlans;if(o!==null&&typeof o=="object")for(let n of Re)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function Co(e){return JSON.stringify([e?.planBilling,[...rt(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function Xt(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 xo(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Ar,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 p=Number(d);if(!Number.isFinite(p)||p<n||p>o+36e5){s=!0;continue}l[p]={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 en(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=Xt(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as ct,readlinkSync as Mr,statSync as Sr}from"node:fs";import{execFileSync as Eo}from"node:child_process";import{hostname as Ir}from"node:os";import{join as Or}from"node:path";import{performance as Cr}from"node:perf_hooks";var vo=Ir(),at=process.platform==="win32"?Cr.timeOrigin:Date.now()-process.uptime()*1e3,_o={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},tn,nn,st;function on(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=ct(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=ct("/proc/sys/kernel/random/boot_id","utf8").trim(),s=Mr(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let c=e===process.pid?at:null;if(t&&e!==process.pid){st??=Number(Eo("getconf",["CLK_TCK"],_o).trim());let a=ct("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(st)&&st>0&&a&&(c=(Number(a)+Number(i)/st)*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(at)),unit:"ms",startedAtMs:at};let n=Or(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=Eo(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],_o).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function rn(){return tn===void 0&&(tn=on(process.pid)),tn}function Po(){let e=rn();return JSON.stringify({version:e?.unit==="ms"?2:1,host:vo,identity:e})}function No(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=ct(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==vo)return!1;let c=rn();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,on(t,n===""));let s=t===process.pid?rn():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(nn===void 0&&(nn=on(t,!1,!0)),s=nn),n===""){let c=t===process.pid?s?.startedAtMs??at:s?.startedAtMs;return Number.isFinite(c)&&Sr(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 Er,randomUUID as an}from"node:crypto";import{createHash as xr}from"node:crypto";var Q=new WeakMap,Ro=/^[a-f\d]{64}$/,Te=e=>e&&typeof e=="object"&&!Array.isArray(e),To=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),sn=e=>xr("sha256").update(JSON.stringify(e)).digest("hex"),Do=24;function ut(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))ut(t);return Object.freeze(e)}function Uo(e,t,o=[],n=[]){if(e===t)return n;if(Te(e)&&Te(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))To(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)?Uo(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 jo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=jo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function lt(e,t,o,n){let i=o.get(n);if(i&&i.depth<Do){let r={base:n,patch:Uo(t[n],e)},s=JSON.stringify(r).length;if(s<1024||s<JSON.stringify(e).length)return{record:ut(r),depth:i.depth+1,signature:sn(r),baseValue:t[n]}}return{record:e,depth:0,signature:sn(e)}}function dt(e,t,o,n){let i=Q.get(e)??new Map;Q.set(e,i),Object.hasOwn(e,t)||(e[t]=ut(o)),i.has(t)||i.set(t,lt(e[t],e,i,n))}function Ho(e={}){let t={...e};return Q.set(t,new Map(Q.get(e)??[])),t}function Lo(e,t){let o={...t,...e};return Q.set(o,new Map([...Q.get(t)??[],...Q.get(e)??[]])),o}function Fo(e){let t=Q.get(e)??new Map;Q.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,lt(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function Bo(e,t,o){let n={},i=new Map,r=Q.get(o),s=new Set,c=a=>{if(i.has(a))return!0;if(!Ro.test(a)||s.has(a)||s.size>Do||!Te(e[a]))return!1;s.add(a);let l=e[a],d;if(!Te(l.prices)){if(!Ro.test(l.base)||!Array.isArray(l.patch)||l.patch.length>1e5||l.patch.some(m=>!Array.isArray(m)||![1,2].includes(m.length)||!Array.isArray(m[0])||m[0].length>16||!m[0].every(To))||!c(l.base))return s.delete(a),!1;d=i.get(l.base)}let u=sn(l),p=d?n[l.base]:void 0,g=r?.get(a);if(g&&o[a]&&(g.sourceSignature===u&&g.sourceBase===p||g.signature===u&&g.baseValue===p))n[a]=o[a],i.set(a,g);else{let m=d?n[l.base]:l;if(d)for(let O of l.patch)m=jo(m,O[0],O);if(!Te(m?.prices))return s.delete(a),!1;n[a]=ut(t(m));let k=lt(n[a],n,i,d?l.base:void 0);i.set(a,{...k,sourceSignature:u,sourceBase:p})}return s.delete(a),!0};for(let a of Object.keys(e))c(a);if(Q.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,{...lt(n[l],n,i,a),sourceSignature:d,sourceBase:u}),a=l}}return n}var Ko=new WeakMap,ft=new WeakMap,De=new WeakSet,_r=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],un=e=>Er("sha256").update(JSON.stringify(e)).digest("hex"),Se=e=>!["__proto__","constructor","prototype"].includes(e),pt=e=>e&&typeof e=="object"&&!Array.isArray(e),vr=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"]);function dn(e,t,o){if(!e||typeof e!="object"||!t)return o();if(t.has(e))return t.get(e);let n=o();return t.set(e,n),t.set(n,n),n}var Ue=(e,t)=>dn(e,t?.rates,()=>Array.isArray(e)?e.map(o=>Ue(o,t)):pt(e)?Object.fromEntries(Object.entries(e).filter(([o])=>vr.has(o)||Ct.test(o)).map(([o,n])=>[o,Ue(n,t)])):e),cn=(e,t)=>dn(e,t?.models,()=>Object.fromEntries(Object.entries(e??{}).filter(([o])=>Se(o)).map(([o,n])=>[o,Ue(n,t)]))),Wo=["at","before","after","days","sessions","skipped"];function Pr(e){return typeof e?.sessionId=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e.date)&&typeof e.model=="string"&&["usage","ledgerModelMissing","logModelMissing","dayModelMissing","logMissing"].includes(e.reason)&&Array.isArray(e.fields)&&e.fields.every(t=>["input","output","cacheRead","cacheWrite","reasoning","calls"].includes(t?.field)&&Number.isFinite(t.ledger)&&t.ledger>=0&&Number.isFinite(t.log)&&t.log>=0)}var ln=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function $o(e){let t=ft.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||ln(n,r)>=0)&&o.set(i,n)}return t={changes:Object.values(e.changes).sort(ln),revisions:o,fingerprint:un([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((n,i)=>n.at-i.at||(n.sequence??0)-(i.sequence??0))},ft.set(e,t),t}function pn(e,t=!1,o){let n=structuredClone(Object.fromEntries(_r.filter(r=>r!=="prices"&&e?.[r]!==void 0).map(r=>[r,e[r]]))),i=e?.prices??{};return n.prices={...i.currency?{currency:i.currency}:{},ollamaPeak:!t||i.ollamaPeak===!0,ollamaTaggedPeak:!t||i.ollamaTaggedPeak===!0,snapshotTags:!t||i.snapshotTags===!0,shortSnapshotTags:!t||i.shortSnapshotTags===!0,volcenginePeak:!t||i.volcenginePeak===!0,legacyModelMatching:t&&i.legacyModelMatching!==!1,default:Ue(i.default,o),models:cn(i.models,o),...i.custom?{custom:cn(i.custom,o)}:{},providers:Object.fromEntries(Object.entries(i.providers??{}).filter(([r])=>Se(r)).map(([r,s])=>[r,dn(s,o?.providers,()=>({...he(s),...s.currency?{currency:s.currency}:{},...s.default?{default:Ue(s.default,o)}:{},models:cn(s.models,o)}))]))},n}function zo(e,t=!1){let o=pn(e,t),n=un(o),i={};dt(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:Ge(e)}}};return De.add(r),r}function je(e,t,o,n=!1){if(De.has(e))return e;if(!pt(e?.versions)||!pt(e?.changes))return zo(t,n);let i={rates:new WeakMap,models:new WeakMap,providers:new WeakMap},r=Bo(e.versions,u=>pn(u,!0,i),o?.versions),s=Object.fromEntries(Object.entries(e.changes).filter(([u,p])=>Se(u)&&Number.isFinite(p?.at)&&p.at>=0&&r[p.version]));if(!Object.values(s).some(u=>u.at===0)){let u=Object.values(r),p={...t?.prices};for(let m of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])u.length&&(p[m]=u.every(k=>k.prices?.[m]===!0));u.length&&(p.legacyModelMatching=u.every(m=>m.prices?.legacyModelMatching===!0));let g=zo({...t,prices:p},n);for(let[m,k]of Object.entries(g.versions))dt(r,m,k);s[an()]=g.changes.initial}let c=Object.fromEntries(Object.entries(e.revisions??{}).filter(([u,p])=>Se(u)&&typeof p?.sessionId=="string"&&(p.model===void 0||typeof p.model=="string"&&p.model.includes(":")&&p.model.length<=2048)&&/^\d{4}-\d{2}-\d{2}$/.test(p.date)&&Number.isFinite(p.at)&&r[p.version])),a=Object.fromEntries(Object.entries(pt(e.runs)?e.runs:{}).filter(([u,p])=>Se(u)&&Wo.every(g=>Number.isFinite(p?.[g])&&p[g]>=0)).map(([u,p])=>[u,{...Object.fromEntries([...Wo,...["beforeCny","afterCny","beforeEur","afterEur"].filter(g=>Number.isFinite(p[g])&&p[g]>=0)].map(g=>[g,p[g]])),...typeof p.model=="string"?{model:p.model}:{},...Array.isArray(p.skippedDetails)?{skippedDetails:p.skippedDetails.filter(Pr)}:{}}])),l=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([u,p])=>Se(u)&&Number.isFinite(p?.at)&&p.at>=0&&["CNY","EUR"].every(g=>Number.isFinite(p.rates?.[g])&&p.rates[g]>0)));if(!Object.keys(l).length)for(let[u,p]of Object.entries(s))l[u]={at:p.at,sequence:p.sequence??0,rates:Ge({...r[p.version],currency:t.currency})};let d={versions:r,changes:s,revisions:c,runs:a,fxChanges:l};return De.add(d),d}function ht(e,t,o=Date.now()){let n=pn(t),i=un(n),r=$o(e),s=r.changes.at(-1),c=Ge(t),a=r.fx.at(-1),l=JSON.stringify(a?.rates)!==JSON.stringify(c);l&&(e.fxChanges??={},e.fxChanges[an()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,rates:c},ft.delete(e));let d=u=>{let{exchangeRate:p,...g}=u??{};return g};return s?.version===i||JSON.stringify(d(e.versions[s?.version]))===JSON.stringify(d(n))?l:(dt(e.versions,i,n,s?.version),e.changes[an()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},ft.delete(e),!0)}function qo(e,t){return e&&t&&Ko.set(e,t),e}function fn(e,t,o="",n=""){if(e?._repriceFxConfig){let v=fn(e._repriceFxConfig,t,o,n),b=q(v);return{...e,fxRates:b,exchangeRate:b[e.currency]??e.exchangeRate}}let i=Ko.get(e);if(!i||!Number.isFinite(t))return e;let r=$o(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 v=a+l>>>1;r.changes[v].at<=t?a=v+1:l=v}let d=r.changes[a-1],u=v=>v&&t<=v.at?v:null,p=u(r.revisions.get(JSON.stringify([o,c,""]))),g=n?u(r.revisions.get(JSON.stringify([o,c,n]))):null,m=p&&g?ln(p,g)>0?p:g:p??g,k=(m??d)?.version,O=k&&i.versions[k]?{...e,...i.versions[k]}:e,C=0,N=r.fx.length;for(;C<N;){let v=C+N>>>1;r.fx[v].at<=t?C=v+1:N=v}let A=r.fx[C-1]?.rates,P=m?.preserveFx?p?.fxRates??A??q(i.versions[d?.version]??e):m?m.fxRates??q(O):A??q(O);return{...O,fxRates:P,exchangeRate:P[O.currency]??O.exchangeRate}}function Yo(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:Lo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return De.add(n),n}function Go(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Ho(t)};return De.add(n),n}function Qo(e){return e&&{...e,format:2,versions:Fo(e.versions)}}var pe=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...$],fe=e=>!["__proto__","constructor","prototype"].includes(e),j=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ie=e=>e===void 0?void 0:structuredClone(e);function gn(e,t){if(j(e)){if(!j(t)){for(let o of $)delete e[o];return}for(let o of $)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))gn(n,t.byProviderModel?.[o]);if(Array.isArray(e.sessions)){let o=new Map((Array.isArray(t.sessions)?t.sessions:[]).filter(n=>j(n)&&typeof n.id=="string").map(n=>[n.id,n]));for(let n of e.sessions)j(n)&&o.has(n.id)&&gn(n,o.get(n.id))}}}function jr(e,t){if(!j(e)||!j(t))return e;for(let[o,n]of Object.entries(e))j(n)&&gn(n,t[o]);return e}function bn(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)=>bn(n,t[i]));if(!j(e)||!j(t))return!1;let o=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of o)if(!$.includes(n)&&!bn(e[n],t[n]))return!1;return!0}function yn(e,t,o){if(!j(e))return e;for(let n of $){let i=V(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??{}))yn(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(c=>j(c)&&typeof c.id=="string").map(c=>[c.id,c])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)j(s)&&typeof s.id=="string"&&yn(s,i.get(s.id),r.get(s.id))}return e}function Le(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Go(t)}:{}}}var Hr=new Int32Array(new SharedArrayBuffer(4)),ri=e=>typeof e=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}:[a-f\d]{64}$/i.test(e),be=e=>Object.fromEntries(Object.entries(j(e)?e:{}).filter(([t,o])=>ri(t)&&Number.isSafeInteger(o)&&o>=0)),Z=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 Fe(e,t,o=5e3,n=ii()){Vo(oi(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=Po(),c=new Map,a=Date.now()+o;for(;;)try{Vo(i);try{ti(He(i,r),s,{flag:"wx"})}catch(l){try{gt(He(i,r))}catch{}throw mt(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=Nr(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(No(He(i,d[0]),Number(u[1]),c)){gt(He(i,d[0])),mt(i);continue}}else if(d.length===0&&Date.now()-Tr(i).mtimeMs>3e4){mt(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{gt(He(i,r)),mt(i)}}function si(e){let t;try{t=ni(e,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!j(o)||o.version!==1)throw new Error("Unsupported ledger format");return o}function ci(e,t){let o=`${e}.${process.pid}-${ii()}.tmp`;try{let n=Zo(o,"wx",384);try{ti(n,JSON.stringify(t),"utf8"),Jo(n)}finally{Xo(n)}if(Rr(o,e),process.platform!=="win32"){let i=Zo(oi(e),"r");try{Jo(i)}finally{Xo(i)}}}finally{try{gt(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function kn(e){let t;try{t=ni(`${e}.config-bak`,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!j(o)||o.version!==1||!j(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 An(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=kn(e)}catch(i){if(i.code)throw i}K(n,o)||ci(`${e}.config-bak`,o)}function bt(e,t,o=!1){if(o)try{Dr(e,`${e}.pricing-history-v1.bak`,Ur.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}An(e,t),ci(e,{...t,pricingHistory:Qo(t.pricingHistory)})}var hn=()=>Object.fromEntries(pe.map(e=>[e,0]));function ei(e,t){for(let o of pe)e[o]=(Number(e[o])||0)+(t[o]??0)}function Oe(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!ri(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;j(e.days[o])||(e.days[o]={date:o,...hn(),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,...hn(),byProviderModel:{}},a.sessions.push(d)),l.push(d)}for(let d of l){ei(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=hn();ei(u,s)}return c!==null&&(e.planHourBuckets=Xt(e.planHourBuckets,c,i,Kt(s),s.cost)),!0}function V(e,t,o,n=!1){if(K(t,e))return Ie(o);if(K(o,e)||K(t,o))return Ie(t);if(j(t)&&j(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!fe(r))continue;let s=V(e?.[r],t[r],o[r],n&&(j(t[r])||pe.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)):Ie(t)}var mn=e=>Object.fromEntries((e?.sessions??[]).filter(t=>fe(t.id)).map(t=>[t.id,t]));function Lr(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!fe(i))continue;let r=e[i],s=t[i],c=o[i];if(bn(r,s)){c!==void 0&&(n[i]=yn(Ie(c),r,s));continue}if(!s||!c){s&&(n[i]=Ie(s));continue}if(K(s,c)){n[i]=Ie(c);continue}let a=V(r,s,c,!0),l=mn(r),d=mn(s),u=mn(c),p=V(l,d,u,!0),g=(m,k,O)=>Object.fromEntries(pe.map(C=>[C,(O?.[C]??0)+(k?.[C]??0)-(m?.[C]??0)]));Object.assign(a,g(r,s,c)),a.byProviderModel={};for(let m of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(c.byProviderModel??{})]))fe(m)&&(a.byProviderModel[m]=g(r?.byProviderModel?.[m],s.byProviderModel?.[m],c.byProviderModel?.[m]));for(let m of Object.keys(d))if(!(!u[m]||K(l[m],d[m])||K(l[m],u[m]))){for(let k of pe)a[k]-=(d[m][k]??0)-(l[m]?.[k]??0)-((p[m]?.[k]??0)-(u[m][k]??0));for(let[k,O]of Object.entries(d[m].byProviderModel??{}))if(!(!fe(k)||!a.byProviderModel[k]))for(let C of pe)a.byProviderModel[k][C]-=(O[C]??0)-(l[m]?.byProviderModel?.[k]?.[C]??0)-((p[m]?.byProviderModel?.[k]?.[C]??0)-(u[m].byProviderModel?.[k]?.[C]??0))}for(let m of[a,...Object.values(a.byProviderModel)])for(let k of pe)m[k]=Math.max(0,m[k]);a.sessions=Object.values(p).sort((m,k)=>(m.at??0)-(k.at??0)),n[i]=a}return n}function Fr(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(fe(r)){i[r]={};for(let s of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!fe(s))continue;let c=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),a=V(c(e[r]?.[s]),c(t[r]?.[s]),c(o[r]?.[s]));i[r][s]=Object.values(a).filter(l=>l.t>=n-So).sort((l,d)=>l.t-d.t).slice(-Mo)}}return i}function Ce(e,t,o,n,i=Date.now(),r=[],s={}){let c=s.ownLocal===!0,a=o!==void 0&&o===e,l=Le(e),d=a?l:Le(o??e),u=c?t:Le(t);jr(l.days,d.days);let p=!K(u.historyReset,l.historyReset),g=!K(d.historyReset,l.historyReset),m=p?u.historyReset:d.historyReset;if(p||g)for(let P of[l,...p?[d]:[u]])P.days={},P.planSamples={},P.planHourBuckets={},P.balanceRef=null;for(let P of n)g&&!p&&P.recordedAt<=(m?.at??0)||(Oe(l,P),d!==l&&Oe(d,P),g&&!p&&Oe(u,P));let k={version:1,writeReceipts:Z([...d.writeReceipts??[],...u.writeReceipts??[]]),config:V(l.config,u.config,d.config),days:Lr(l.days,u.days,d.days),balanceRef:K(l.balanceRef,u.balanceRef)?d.balanceRef:K(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:Fr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:xo(V(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:V(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:Yo(u.pricingHistory,d.pricingHistory),historyReset:m??null},O=be(u.usageCursors);for(let[P,v]of Object.entries(be(d.usageCursors)))O[P]=Math.max(O[P]??0,v);Object.keys(O).length&&(k.usageCursors=O);let C=V(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);C&&Object.keys(C).length&&(k.providerPriceHashes=C);let N=Object.keys(k.days).sort(),A=Math.max(7,Math.min(3650,Number(k.config.historyDays)||180));for(;N.length>A;)delete k.days[N.shift()];return ge(k.days).includes(k.balanceRef?.date)&&(k.balanceRef=null),Br(k,r),k}function Br(e,t){let o=(n,i)=>pe.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(Co(e.config)!==n.fingerprint||!K(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(!fe(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]??{};K(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 ai(e,t,o){return V(e,t,o)}import{join as di}from"node:path";var pi=1,gi=180;function Kr(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 Be(e){try{let t=zr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var wn=["antigravity","claude","codex","kimi","xai","workbuddy"],$r=["sidebar","settings","both","off"],qr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Yr(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function fi(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function Gr(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(":")&&fi(c.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!fi(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 Qr(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=>Yr(c)).filter(c=>wn.includes(c)))]:wn.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(c=>Gr(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:$r.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:wn.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function Vr(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 On(){return{queryAccounts:{},peakTimeZone:"auto",locale:"auto",position:"dock",sidebar:!0,currency:"CNY",symbol:"\xA5",decimals:4,exchangeRateAuto:!0,fxRates:Ye(),exchangeRateCheckedAt:0,exchangeRateDate:"",exchangeRate:7.2,pricingCurrency:"USD",peakEnabled:!0,peakEffectiveAt:Gn,peakWindows:Qn.map(e=>({...e})),peakHolidays:[...ot],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:{},localSavings:Wt(),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(Ut.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(Ut.default),providers:Object.fromEntries(Object.entries(ne).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:{source:"auto",display:"both",refreshMinutes:5,showProgressBar:!1,showSource:!1,officialChannelOnly:!1,quickHide:!1,budgetCap:null,currency:"native",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,planAmounts:!0,promptSeen:!1},barDirections:{balance:"remaining",budget:"used",go:"used",plan:"used"},usage:{position:"cost"},planBilling:{providers:{...Vt},models:{},modelPlans:{}},historyDays:gi,fetchedAt:null,priceSource:"bundled"}}var iu=Object.keys(On());function Mn(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Sn(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function Zr(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 Jr(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function yt(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=Jr(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 hi(e){for(let t of Object.values(e))if(yt(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))yt(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>yt(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))yt(i)===null&&delete o.byProviderModel[n]}}return e}function We(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)?We(r,i):i}return o}function Xr(e){return e==="native"||e==="display"||qe(e)}function xe(e){let t=On(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(no),currency:"CNY"});let n=We(t,o);n.queryAccounts=Rn(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(([f,h])=>f.includes(":")&&f.length<=512&&Ne(h)!==null).map(([f,h])=>[f,Ne(h)])));for(let[f,h]of Object.entries(o.prices?.providers??{}))!h?.models||typeof h.models!="object"||Array.isArray(h.models)||Object.hasOwn(n.prices?.providers??{},f)&&(n.prices.providers[f].models=We({},h.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=We({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:f,cacheMiss:h,output:y}=t.prices.default;n.prices.default=We({cacheHit:f,cacheMiss:h,output:y},r)}let s=f=>{if(f&&typeof f=="object"&&!Ke(f))for(let h of Mt)delete f[h]};for(let f of Object.values(n.prices?.providers??{})){s(f);for(let h of Object.values(f?.models??{}))s(h)}for(let f of[...Object.values(n.prices?.models??{}),n.prices?.default])s(f);let c=f=>typeof f=="number"&&Number.isFinite(f),a=(f,h,y)=>typeof f=="string"&&h.includes(f)?f:y;for(let[f,h]of Object.entries(t)){let y=n[f],T=typeof h;T==="boolean"&&typeof y!="boolean"||T==="number"&&!c(y)||T==="string"&&typeof y!="string"?n[f]=h:T==="object"&&h!==null&&y!==null&&typeof y=="object"&&f==="gatewayQuotas"&&Array.isArray(y)||T==="object"&&h!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(h))&&(n[f]=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=Un(n.modelStatistics),n.localSavings=Wt(n.localSavings);for(let f of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline","sidebarTextOnly"])n[f]=n[f]===!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(f=>typeof f=="string"&&/^(balance|customBalance|today|peak|models|localSavings|go|budget|codex|(plan|gateway):[A-Za-z0-9_-]{1,100})$/.test(f)))].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(f=>typeof f=="string"&&f.length<=160))].slice(-32),n.sidebarModels=Object.fromEntries(Object.entries(t.sidebarModels).map(([f,h])=>{let y=n.sidebarModels?.[f],T={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[f];return[f,T?T.includes(y)?y:h:typeof h=="boolean"?typeof y=="boolean"?y:h:typeof y=="number"&&Number.isFinite(y)?Math.min(f==="topN"?10:60,Math.max(f==="topN"?1:10,Math.floor(y))):h]})),n.sidebarStyle=a(n.sidebarStyle,["standard","compact","summary","icons"],"standard"),n.planQuotaStyle=a(n.planQuotaStyle,["bars","gauge"],"bars"),n.priceMatchDismissed=Array.isArray(n.priceMatchDismissed)?[...new Set(n.priceMatchDismissed.filter(f=>typeof f=="string"&&f.length>0&&f.length<=512))].slice(0,1e3):[],delete n.hideAmounts,n.peakTimeZone=En(n.peakTimeZone)?n.peakTimeZone:"auto",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=q(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(f=>f!==null&&typeof f=="object"&&c(Number(f.start))&&c(Number(f.end))):n.peakWindows=t.peakWindows,Array.isArray(n.peakHolidays)?n.peakHolidays=[...new Set(n.peakHolidays.filter(f=>typeof f=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(f)&&!Number.isNaN(Date.parse(f+"T00:00:00Z"))&&new Date(f+"T00:00:00Z").toISOString().slice(0,10)===f))].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[f,h]of Object.entries(n.priceOverrides))typeof f=="string"&&typeof h=="string"&&(d[f]=h);n.priceOverrides=d;let u={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[f,h]of Object.entries(n.priceTableDisplay))typeof f=="string"&&(u[f]=typeof h=="boolean"?h:t.priceTableDisplay[f]===!0);n.priceTableDisplay={...t.priceTableDisplay,...u};let p=n.budget;p.enabled=p.enabled===!0,p.amount=c(p.amount)&&p.amount>=0?p.amount:100,p.period=a(p.period,["day","month","all","custom"],"month"),p.customStart=typeof p.customStart=="string"?p.customStart:null,p.customEnd=typeof p.customEnd=="string"?p.customEnd:null,p.detail=p.detail!==!1;let g=n.balance;g.display=a(g.display,["sidebar","settings","both","off"],"both"),g.source=a(g.source,["auto","account"],"auto"),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,Xr(g.currency)||(g.currency="native");let m=Number(g.budgetCap);g.budgetCap=Number.isFinite(m)&&m>0?m:null;let k=n.goQuota;k.enabled=k.enabled===!0,typeof k.showInComposer!="boolean"&&delete k.showInComposer,k.display=a(k.display,["sidebar","settings","both","off"],"both"),k.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(k.refreshMinutes)||15))),k.apiKey=typeof k.apiKey=="string"?k.apiKey:"",k.main=a(k.main,["rolling","weekly","monthly"],"rolling"),k.detail=k.detail!==!1;let O=n.customBalance??t.customBalance,C=(f,h)=>{let y=f??{},T={...["aliyun","tokenrhythm"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:a(y.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),label:typeof y.label=="string"?y.label:h.label,labelEn:typeof y.labelEn=="string"?y.labelEn:h.labelEn,dashboardUrl:Kr(y.dashboardUrl),unit:y.adapter==="tokenrhythm"?"CNY":a(y.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))T.request={...h.request};else{let F={};for(let[D,H]of Object.entries(y.request.headers??{}))typeof D=="string"&&typeof H=="string"&&(F[D]=H);T.request={...h.request,...y.request,url:typeof y.request.url=="string"?y.request.url:"",method:typeof y.request.method=="string"?y.request.method:"GET",headers:{...h.request?.headers??{},...F}}}if(y.extract===null||typeof y.extract!="object"||Array.isArray(y.extract)?T.extract={...h.extract}:T.extract={...h.extract,...y.extract},Array.isArray(y.allowedHosts)){let F=y.allowedHosts.filter(D=>typeof D=="string"&&D.length>0);F.length>0&&(T.allowedHosts=F)}return T},N=C(O,t.customBalance);n.customBalance=N;let A=n.gatewayQuotas,P=Array.isArray(A)?A:A!==null&&typeof A=="object"&&Array.isArray(A.sources)?A.sources:[],v=[],b=new Set;for(let f of P.slice(0,4)){let h=Qr(f);!qr.test(h.id)||b.has(h.id)||h.type!=="cliproxyapi"||!Vr(h.baseURL)||(b.add(h.id),v.push(h))}n.gatewayQuotas={sources:v};let w=n.customBalances;Array.isArray(w)||(w=[]);let S=t.customBalances?.[0]??t.customBalance,E=w.slice(0,8).map(f=>C(f,S)),_=N.enabled===!0||typeof N.request?.url=="string"&&N.request.url.length>0;E.length===0&&_&&E.push(N),n.customBalances=E;let R=n.corner;for(let f of["enabled","goRolling","goWeekly","goMonthly","budget"])R[f]=R[f]===!0||R[f]!==!1&&f!=="enabled";let I=n.quotaStrip;I.enabled=I.enabled===!0,I.promptSeen=I.promptSeen===!0;for(let f of["budget","go","plans","planAmounts"])I[f]=I[f]!==!1;let M=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:M.balance==="used"?"used":"remaining",budget:M.budget==="remaining"?"remaining":"used",go:M.go==="remaining"?"remaining":"used",plan:M.plan==="remaining"?"remaining":"used"};let x={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[f,h]of Object.entries(n.codingPlans))if(!(!Re.includes(f)||h===null||typeof h!="object"||Array.isArray(h))){if(x[f]={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:""},f==="minimax"){let y=Ao(h.baseUrl);x[f].baseUrl=y??"",y===null&&(x[f].enabled=!1)}if(f==="workbuddy"&&(h.accountSource!==void 0&&(x[f].accountSource=a(h.accountSource,["auto","connect","xdpool"],"auto")),x[f].accountScope=a(h.accountScope,["current","all","selected"],"current"),x[f].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(Yt))].slice(0,400):[]),f==="opendesign"){let y=Kn(h.workspaceId);x[f].workspaceId=y??"",y===null&&(x[f].enabled=!1)}if(f==="factory"){let y=mo(h.orgId);x[f].orgId=y??"",y===null&&(x[f].enabled=!1),x[f].factoryPool=a(h.factoryPool,["standard","core","both"],"standard")}if(f==="scnet"){let y=Number(h.planCredits);x[f].planCredits=Number.isFinite(y)&&y>0?y:24e4,x[f].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:""}if(f==="qwen"){x[f].quotaSource=h.quotaSource==="cli"||h.quotaSource==="bailian"?h.quotaSource:"local";let y=Number(h.planCredits);x[f].planCredits=Number.isFinite(y)&&y>0?y:5e5,x[f].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:"";let T=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},F={};for(let[D,H]of Object.entries(T)){if(typeof D!="string"||D.length===0||H===null||typeof H!="object")continue;let Y=Ee=>{let X=Number(Ee);return Number.isFinite(X)&&X>0?X:null},z=Y(H.input),se=Y(H.cachedInput),ce=Y(H.output);z===null||se===null||ce===null||(F[D]={input:z,cachedInput:se,output:ce})}x[f].rates=F}if(f==="volcengine"){let y=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",T=typeof h.apiKey=="string"?h.apiKey.trim():"";x[f].accessKeyId=y.length>0?y:T,x[f].secretAccessKey=typeof h.secretAccessKey=="string"?h.secretAccessKey:"",x[f].accessKeyId.length>0&&x[f].apiKey!==x[f].accessKeyId&&(x[f].apiKey=x[f].accessKeyId)}}}n.codingPlans=x;let U={};for(let f of ie){let h=n.planBilling?.providers?.[f];U[f]=["auto","plan","api"].includes(h)?h:Vt[f]??"auto"}if(n.planBilling?.providers&&typeof n.planBilling.providers=="object"&&!Array.isArray(n.planBilling.providers))for(let[f,h]of Object.entries(n.planBilling.providers))f.trim()&&!["__proto__","constructor","prototype"].includes(f)&&["auto","plan","api"].includes(h)&&(U[f]=h);let re={};if(n.planBilling?.models!==null&&typeof n.planBilling?.models=="object"&&!Array.isArray(n.planBilling?.models))for(let[f,h]of Object.entries(n.planBilling.models))typeof f=="string"&&f.length>0&&(h==="plan"||h==="api")&&(re[f]=h);let J=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([f,h])=>f.includes(":")&&ie.includes(h))),L=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(f=>ie.includes(f)):[...rt(n)])];return n.planBilling={providers:U,models:re,modelPlans:J,autoProviders:L},n}var es={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"},ru=Object.keys(es);function mi(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))vt(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function In(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=mi(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(mi)),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 kt=[{id:"provider-catalog-2026-10-03",apply:Me},{id:"provider-catalog-2026-10-15",apply:Zn},{id:"provider-catalog-2026-10-28",apply:Jn},{id:"provider-catalog-2026-11-05",apply:Xn},{id:"stepfun-catalog-2026-10-16",apply:eo},{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")}}],At=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=je(r.pricingHistory,t),this.config=t,Nn(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??po,this.writeReceipts=Z(r.writeReceipts),this.diskRevision=null,this.balanceRef=r.balanceRef??null,this.historyReset=r.historyReset??null,this.usageCursors=be(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&&ht(this.pricingHistory,t),this._config=qo(t,this.pricingHistory)}static open(){let t=di(qt(),"storages","cost-meter"),o=di(t,"ledger.json");return Fe(o,()=>e.load(o))}static load(t){let o=On(),n={},i=null,r=[...kt.map(A=>A.id),"quota-token-window-v2"],s={},c={},a={},l={},d=null,u={},p=[],g,m=!1,k=!1,O=!1;try{let A=JSON.parse(Wr(t,"utf8"));if(A===null||typeof A!="object"||Array.isArray(A))throw new Error("Unsupported ledger format");if(A!==null&&typeof A=="object")if(A.version!==pi){try{li(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(A.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=A.historyReset??null,u=be(A.usageCursors),p=Z(A.writeReceipts);let P=typeof A.config=="object"&&A.config!==null?A.config:{};g=je(A.pricingHistory,xe(P),void 0,!0),m=!!A.pricingHistory&&A.pricingHistory.format!==2,r=Array.isArray(A.migrations)?A.migrations.filter(w=>typeof w=="string"):[];let v=new Set(r);for(let w of kt)v.has(w.id)||(w.apply(P),r.push(w.id));o=xe(P),A.openrouterPriceHashes&&typeof A.openrouterPriceHashes=="object"&&!Array.isArray(A.openrouterPriceHashes)&&(a=A.openrouterPriceHashes),A.providerPriceHashes&&typeof A.providerPriceHashes=="object"&&!Array.isArray(A.providerPriceHashes)&&(l=A.providerPriceHashes),A.days!==null&&typeof A.days=="object"&&!Array.isArray(A.days)&&(n=hi(A.days));let b=A.balanceRef;b!==null&&typeof b=="object"&&typeof b.date=="string"&&Number.isFinite(b.total)&&Number.isFinite(b.granted)&&Number.isFinite(b.topped)&&(i={date:b.date,total:b.total,granted:b.granted,topped:b.topped,currency:typeof b.currency=="string"?b.currency:void 0,at:Number(b.at)||0,ledgerCost:Number.isFinite(b.ledgerCost)&&b.ledgerCost>=0?b.ledgerCost:void 0}),A.planSamples!==null&&typeof A.planSamples=="object"&&!Array.isArray(A.planSamples)&&(s=A.planSamples),A.planHourBuckets!==null&&typeof A.planHourBuckets=="object"&&!Array.isArray(A.planHourBuckets)?c=A.planHourBuckets:Array.isArray(A.planRecentCalls)&&(c=en(A.planRecentCalls)),k=!0}}catch(A){if(A?.code!=="ENOENT"){try{li(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(A?.message??A)}`)}}if(k)try{An(t,{config:In(o),migrations:r})}catch(A){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u5199\u5165\u5931\u8D25\uFF08${A?.code??"write error"}\uFF09`)}else try{let A=kn(t);if(A){let P=A.config;r=A.migrations;for(let v of kt)r.includes(v.id)||(v.apply(P),r.push(v.id));o=xe(P),O=!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(A){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u4E0D\u53EF\u7528\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\uFF08${A?.code??"invalid format"}\uFF09`)}let C=new e(o,n,t,r,{planSamples:s,planHourBuckets:c,openrouterPriceHashes:a,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:p,pricingHistory:g});C.legacyPricingHistory=m,C.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),C.quotaStatsNeedRepair&&(C.planSamples={}),(m||O)&&C.scheduleWrite();let N=ge(C.days);return N.length&&(N.includes(C.balanceRef?.date)&&(C.balanceRef=null),C.scheduleWrite()),C}account(t,o,n,i,r,s,c){if(this.closed)return;if(c!==void 0&&(!lo(c,i)||r!=="deepseek-official"||!ao(o,c)))throw new Error("Invalid official web request fee");let a=fn(this.config,i,n,`${r||"deepseek"}:${o}`),l=io(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},p=c?c.requests*c.rateCny:l.priced?Lt(t,d,i,u):0,g=Ft(p,c?"CNY":l.currency,q(a).CNY),m=this.config.planBilling,k=rt(this.config),O=c?"api":Oo(r,o,m,k,this.config.prices),C=O==="api"?g:0,N=b=>{let w=Number(b);return Number.isFinite(w)&&w>0?w:0},A={input:N(t?.input),output:N(t?.output),cacheRead:N(t?.cacheRead),cacheWrite:N(t?.cacheWrite),reasoning:N(t?.reasoning)},P=O==="plan"?Zt(r,m,o)??(Jt(r,o,this.config.prices)?"go":null):null,v={...s?{meter:s}:{},date:Mn(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:P,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...A,calls:1,cost:g,apiCost:C,...It(g,C,a)}};return Oe(this,v)?(this.pendingAccounts.push(v),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};Oe(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||gi)),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 Le({version:pi,config:In(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:ui(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Be(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=si(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=je(o.pricingHistory,xe(o.config),this.pricingHistory,!0);for(let i of kt)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:In(xe(o.config)),days:hi(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??en(o.planRecentCalls??[]),openrouterPriceHashes:o.openrouterPriceHashes??{},historyReset:o.historyReset??null,usageCursors:be(o.usageCursors),writeReceipts:Z(o.writeReceipts),providerPriceHashes:o.providerPriceHashes??{},pricingHistory:n}}adoptSnapshot(t){this.pricingHistory=je(t.pricingHistory,t.config),this.config=xe(ai(this.writeBase.config,this.config,t.config));for(let o of["days","balanceRef","migrations","planSamples","planHourBuckets","openrouterPriceHashes","historyReset"])this[o]=t[o];this.usageCursors=be(t.usageCursors),this.writeReceipts=Z(t.writeReceipts),this.providerPriceHashes=t.providerPriceHashes??{}}refresh(){if(!this.closed){if(this.pendingWrite){Be(this.path)!==this.diskRevision?this.flush():this.writeTimer===null&&!this.backgroundWrite&&this.scheduleWrite();return}try{let t=Be(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(Ce(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{Fe(this.path,()=>{ht(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=ge(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:Ce(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});bt(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=Be(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();ht(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,c=ui();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(Z(u?.writeReceipts).includes(c))a={merged:u,revision:Be(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=Z(a.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=Ce(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=Sn(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,_e(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]={..._e({...Qe(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=Sn(`${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,_e(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]={..._e({...Qe(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=Mn(Date.now()),o=this.days[t];return o===void 0?Sn(t):this.copyDay(o)}todayOfficialCost(){return Zr(this.days[Mn(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{...Qe(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 bi=e=>{try{let t=ns(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:ze,base:yi,local:ye,pending:os,repairs:ki,revision:is,backupHistory:rs,transactionId:ss,now:cs,port:Cn,signal:Ai,lockId:as}=ts;try{let e=Fe(ze,()=>{let t=bi(ze)===is,o=ge(ye.days);o.includes(ye.balanceRef?.date)&&(ye.balanceRef=null);let n=t&&!ki.length&&!o.length,i=ye;if(!n){let r=new At(ye.config,{},ze,[],{pricingHistory:ye.pricingHistory});r.writeBase=yi,i=Ce(yi,ye,r.readDiskSnapshot(),os,cs,ki,{ownLocal:!0})}return i.writeReceipts=Z([...i.writeReceipts??[],ss]),bt(ze,i,rs),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:bi(ze)}},5e3,as);Cn.postMessage(e)}catch(e){Cn.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Ai,0,1),Atomics.notify(Ai,0),Cn.close()}
2
+ import{workerData as ts}from"node:worker_threads";import{statSync as ns}from"node:fs";function En(e){if(e==="auto")return!0;if(typeof e!="string"||!e||e.length>100||/^[+-]/.test(e))return!1;try{return new Intl.DateTimeFormat("en",{timeZone:e}),!0}catch{return!1}}var Mt=["peakWindows","peakHolidays","peakSchedule"];function he(e){return Object.fromEntries(Mt.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function Ke(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 $e(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={...he(n),...e.entry};return{...e,entry:i,billingMode:(i.peak||i.offPeak)&&Object.keys(he(i)).length&&i.billingMode!=="flat"?"deepseek-peak":e.billingMode}}function _n(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 St=[["CNY","\xA5",7.2],["USD","$",1],["EUR","\u20AC",.92],["GBP","\xA3",.75605],["JPY","JP\xA5",160],["KRW","\u20A9",1337.13],["INR","\u20B9",94.24],["HKD","HK$",7.846],["SGD","S$",1.2881],["AUD","A$",1.4738],["CAD","C$",1.4258],["CHF","CHF",.8384],["NZD","NZ$",1.8076],["BRL","R$",5.6637],["MXN","MX$",18.5931],["ZAR","R",16.9635],["TRY","\u20BA",50.368],["SEK","kr",10.0502],["NOK","NKr",9.5634],["DKK","Dkr",6.764],["PLN","z\u0142",3.9914],["THB","\u0E3F",33.915],["IDR","Rp",18244],["MYR","RM",4.0875],["PHP","\u20B1",63.813],["ILS","\u20AA",3.2107]],vn=St.map(([e])=>e),wi=new Map(St.map(e=>[e[0],e]));function qe(e){return typeof e=="string"&&wi.has(e)}function Ye(){let e={USD:1};for(let[t,,o]of St)t!=="USD"&&(e[t]=o);return e}var $=["costCny","apiCostCny","costEur","apiCostEur"],Mi=["USD","CNY","EUR"],Pn=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<1e6;function q(e={}){let t=Ye(),o=e?.fxRates;if(o!==null&&typeof o=="object")for(let n of vn)n!=="USD"&&Pn(o[n])&&(t[n]=o[n]);return e?.currency!=="USD"&&qe(e?.currency)&&Pn(e?.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ge(e){let t=q(e);return Object.fromEntries(Mi.map(o=>[o,t[o]]))}function It(e,t,o){let n=q(o);return{costCny:e*n.CNY,apiCostCny:t*n.CNY,costEur:e*n.EUR,apiCostEur:t*n.EUR}}function Qe(e){return Object.fromEntries($.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function _e(e,t,o=1){for(let n of $)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Nn(e,t){let o=n=>{let i=It(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of $)(!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 Si=["balance","goQuota",...["opendesign","anthropic","zai","minimax","kimi","openrouter","siliconflow","commandcode","clinepass","volcengine","mimo","baidu-coding","factory"].map(e=>"codingPlans."+e)],Ot=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ii=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",Oi=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function Rn(e){let t={};if(!Ot(e))return t;for(let o of Si){let n=e[o];if(!Ot(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!Ot(s)||!Ii(s.id)||!Oi(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 Tn=["today","summary","budget"],Dn=e=>e&&typeof e=="object"&&!Array.isArray(e);function Un(e){return Dn(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Dn(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Tn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Tn.some(o=>!t[o]))):{}}var Ct=/^(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 jn(e,t){return(e.separateMultipliers?e.multipliers?.[t]:void 0)??e.multiplier??1}function Ze(e,t,o="base"){let n={};for(let i of["cacheHit","cacheMiss","cacheWrite","output","reasoning"])e[i]!==void 0&&(n[i]=e[i]*jn(t,o+"."+i));return e.longContext&&(n.longContext={...Ze(e.longContext,t,"longContext"),aboveInputTokens:e.longContext.aboveInputTokens}),n}function Je(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 xt(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])=>!Ct.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]*jn(e,n+"."+r)))return!1}}return!0}var Hn={mistral:{models:{"zai-glm-5-3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/models/zai-glm-5-3-flash",checkedAt:"2026-11-05",notes:"Mistral-hosted Z.ai GLM 5.3 Flash at Mistral's published token prices. Batch/Priority/regional/tool fees excluded."},"deepseek-v4-1-flash-1017":{input:.3,output:1.2,cachedInput:.007,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/models/deepseek-v4-flash-1017",checkedAt:"2026-11-05",notes:"Mistral-hosted DeepSeek V4.1 Flash 1017 at Mistral's published token prices, which are double DeepSeek's own off-peak Flash rate. Batch/Priority/regional/tool fees excluded."}}}};var Et={"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."}}}};Et.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 _t={"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 Ci="https://platform.stepfun.ai/docs/en/guides/pricing/details",ve=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:Ci,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."}),Ln={models:{"step-5-preview":ve(1,.1,2.7),"step-3.7-flash":ve(.2,.04,1.15),"step-3.5-flash":ve(.1,.02,.3),"step-3.5-flash-2603":ve(.1,.02,.3),"step-1o-turbo-vision":ve(.36,.07,1.15)}};var Xe={openai:{models:{"gpt-6-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:15,cacheWrite:5}},"gpt-6.1-sol":{input:2,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.2,output:15,cacheWrite:5}},"gpt-6-luna":{input:.1,output:.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,cacheHit:.02,output:.75,cacheWrite:.25}},"gpt-6-astra":{input:10,output:50,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,cacheHit:2,output:75,cacheWrite:25}},"gpt-5.6-sol":{input:4,output:20,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,cacheHit:.8,output:30,cacheWrite:10}},"gpt-5.6-terra":{input:2,output:12,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,cacheHit:.4,output:18,cacheWrite:5}},"gpt-5.6-luna":{input:.2,output:1.2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,cacheHit:.04,output:1.8,cacheWrite:.5}},"gpt-5.5":{input:5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,cacheHit:1,output:45}},"gpt-5.5-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Published direct Standard rates: short input30/output180; long input60/output270 USD/M. The pricing table labels short context<272K, but the model detail does not establish the exact equality/context counting rule. Intentionally unpriced pending clarification; no guessed boundary.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270},unpriced:!0},"gpt-5.4":{input:2.5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,cacheHit:.5,output:22.5}},"gpt-5.4-mini":{input:.75,output:4.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},"gpt-5.4-nano":{input:.2,output:1.25,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.02},"gpt-5.4-pro":{input:30,output:180,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket. Entire request uses long tier only above272000 input tokens.",longContext:{aboveInputTokens:272e3,cacheMiss:60,cacheHit:60,output:270}},"gpt-5.2":{input:1.75,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.175},"gpt-5.2-pro":{input:21,output:168,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-5.1":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5":{input:1.25,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.125},"gpt-5-mini":{input:.25,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-5-nano":{input:.05,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.005},"gpt-5-pro":{input:15,output:120,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4.1":{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"gpt-4.1-mini":{input:.4,output:1.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.1},"gpt-4.1-nano":{input:.1,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.025},"gpt-4o":{input:2.5,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:1.25},"gpt-4o-2024-05-13":{input:5,output:15,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4o-mini":{input:.15,output:.6,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.075},o1:{input:15,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:7.5},"o1-pro":{input:150,output:600,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"o3-pro":{input:20,output:80,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},o3:{input:2,output:8,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.5},"o4-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.275},"o3-mini":{input:1.1,output:4.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket.",cachedInput:.55},"gpt-4-turbo-2024-04-09":{input:10,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-4-0613":{input:30,output:60,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-0125":{input:.5,output:1.5,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-1106":{input:1,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"gpt-3.5-turbo-instruct":{input:1.5,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"davinci-002":{input:2,output:2,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"babbage-002":{input:.4,output:.4,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official Standard global direct OpenAI API token prices. Other processing tiers, regional/FedRAMP10% uplifts, tools and modality-specific costs excluded. A dash in the source means that cache rate is not independently available, not a free cache bucket."},"chat-latest":{input:5,cachedInput:.5,output:30,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for ChatGPT. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5.3-codex":{input:1.75,cachedInput:.175,output:14,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Codex. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."},"gpt-5-search-api":{input:1.25,cachedInput:.125,output:10,billingMode:"flat",sourceUrl:"https://developers.openai.com/api/docs/pricing",checkedAt:"2026-10-03",notes:"Official grouped Standard text-token price for Search. Extra search/tool fees excluded. No future-billing/restricted Rosalind, embeddings or moderation units inferred."}}},anthropic:{models:{"claude-fable-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-5-5":{input:4,cachedInput:.2,cacheWrite:5,output:20,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is8USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-5-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-haiku-4-5":{input:1,cachedInput:.1,cacheWrite:1.25,output:5,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is2USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-mythos-5-1":{input:10,cachedInput:.25,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-fable-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-mythos-5":{input:10,cachedInput:1,cacheWrite:12.5,output:50,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is20USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Invite-only availability does not change published per-token rates. Full1M context uses standard rates."},"claude-opus-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-8":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-7":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-6":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-opus-4-5":{input:5,cachedInput:.5,cacheWrite:6.25,output:25,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is10USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded."},"claude-sonnet-5":{input:2,cachedInput:.2,cacheWrite:2.5,output:10,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is4USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-6":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Official direct Claude API Standard global token rates. cacheWrite is5-minute creation;1-hour creation is6USD/M and requires separate TTL usage. Other tiers, regional premiums and tool fees excluded. Full1M context uses standard rates."},"claude-sonnet-4-5":{input:3,cachedInput:.3,cacheWrite:3.75,output:15,billingMode:"flat",sourceUrl:"https://platform.claude.com/docs/en/about-claude/pricing",checkedAt:"2026-10-03",notes:"Current direct Claude Sonnet 4.5: maximum 200K context; 1M beta retired 2026-04-30 and over-limit requests fail. Standard rates for valid requests; 5-minute cache writes3.75USD/M, 1-hour writes6USD/M need TTL-specific accounting. Zen publishes a separate route with a long-context tier. Sources: https://platform.claude.com/docs/en/build-with-claude/context-windows and https://platform.claude.com/docs/en/release-notes/overview."}}},google:{models:{"gemini-3.8-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.7-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.6-flash":{input:.75,cachedInput:.075,output:3.75,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid direct Gemini Developer API promotional prices through 2026-12-31. Starting 2027-01-01: input1.50/cacheRead0.15/output7.50 USD/M. Cache storage is0.50 USD/M token/hour now,1.00 from2027; excluded from per-request token estimate. Output includes thinking. Zen currently charges the higher1.50/0.15/7.50 route rates. Batch/Flex/Priority/free-tier/grounding excluded."},"gemini-3.1-flash-lite":{input:.25,cachedInput:.025,output:1.5,billingMode:"flat",sourceUrl:"https://ai.google.dev/gemini-api/docs/pricing?hl=en",checkedAt:"2026-10-03",notes:"Standard paid text/image/video input. Audio input0.50/cacheRead0.05 USD/M is a different modality; this generic token row cannot price that accurately. Cache storage1USD/M/hour and grounding excluded."}}},xai:{models:{"grok-4.7":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-build-0.1":{input:1,cachedInput:.2,output:2,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2,cacheHit:.4,output:4}},"grok-4.6":{input:2,cachedInput:.5,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:1,output:12}},"grok-4.5":{input:2,cachedInput:.3,output:6,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:4,cacheHit:.6,output:12}},"grok-4.3":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-multi-agent-0309":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}},"grok-4.20-0309-non-reasoning":{input:1.25,cachedInput:.2,output:2.5,billingMode:"flat",sourceUrl:"https://docs.x.ai/developers/pricing",checkedAt:"2026-10-03",notes:"Standard global direct API. Official pricing table states long context \u2265200000 prompt tokens, entire request. aboveInputTokens199999 represents that inclusive cutoff for integer counts; differs from Zen table >200K wording. US regional1.1x and server-tool fees excluded.",longContext:{aboveInputTokens:199999,cacheMiss:2.5,cacheHit:.4,output:5}}}},mistral:{models:{"mistral-large-2512":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-large-latest":{input:.5,cachedInput:.05,output:1.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3-5":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-3":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-medium-latest":{input:1.5,cachedInput:.15,output:7.5,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-2603":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"mistral-small-latest":{input:.15,cachedInput:.015,output:.6,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-2512":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-14b-latest":{input:.2,cachedInput:.02,output:.2,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-2512":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-8b-latest":{input:.15,cachedInput:.015,output:.15,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-2512":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"ministral-3b-latest":{input:.1,cachedInput:.01,output:.1,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"zai-glm-5-3":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-5":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"zai-glm-latest":{input:1.4,cachedInput:.14,output:4.4,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Mistral-hosted GLM cache read0.14 differs from direct ZAI0.26."},"codestral-2508":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-latest":{input:.3,cachedInput:.03,output:.9,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded."},"codestral-embed-2505":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."},"codestral-embed":{input:.15,cachedInput:.015,output:0,billingMode:"flat",sourceUrl:"https://docs.mistral.ai/inference/pricing",checkedAt:"2026-10-03",notes:"Standard direct Mistral global token prices. Batch/Priority/regional/tool fees excluded. Embedding-only endpoint, no generated output token charge; output0 represents not applicable, not free generated completions."}}},"z-ai":{models:{"glm-5.3-flash":{input:.15,output:.5,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3-flashx":{input:.37,output:1.25,cachedInput:.075,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.3":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.2":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5.1":{input:1.4,output:4.4,cachedInput:.26,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-5":{input:1,output:3.2,cachedInput:.2,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flashx":{input:.07,output:.4,cachedInput:.01,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5":{input:.6,output:2.2,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-x":{input:2.2,output:8.9,cachedInput:.45,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-air":{input:.2,output:1.1,cachedInput:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-airx":{input:1.1,output:4.5,cachedInput:.22,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4-32b-0414-128k":{input:.1,output:.1,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.7-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v":{input:.3,output:.9,cachedInput:.05,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.5v":{input:.6,output:1.8,cachedInput:.11,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-4.6v-flash":{input:0,output:0,cachedInput:0,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Standard direct ZAI USD/token prices; cached input storage is currently limited-time free, not a separately established cache-creation-token rate. Domestic CNY routes, Coding Plans and web-search/tool fees excluded."},"glm-ocr":{input:.03,output:.03,billingMode:"flat",sourceUrl:"https://docs.z.ai/guides/overview/pricing",checkedAt:"2026-10-03",notes:"Official direct token pricing row. Separate Layout Parsing API can charge per page; this token entry cannot price page billing."}}},"opencode-zen":{models:{"big-pickle":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.5-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.1-flash-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"ling-3.0-flash-fin-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3-ultra-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"nemotron-3.5-lightning-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"muse-spark-1.3-contributor-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"jev-1.13-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:0,output:0},"jev-1.13":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.042,output:0},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:3.2,cachedInput:.2},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"kimi-k2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.6,output:3,cachedInput:.1},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:7.5,cachedInput:.5,cacheWrite:3.125},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5},"qwen3.6-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05,cacheWrite:.625},"qwen3.5-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25},"deepseek-v4.1-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"deepseek-v4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.74,output:3.48,cachedInput:.145},"deepseek-v4-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"deepseek-v4-flash-vision-exp":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.028},"claude-fable-5-1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:.25,cacheWrite:12.5},"claude-fable-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5},"claude-opus-5-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.2,cacheWrite:5},"claude-opus-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-8":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-opus-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:25,cachedInput:.5,cacheWrite:6.25},"claude-sonnet-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5},"claude-sonnet-4-6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75},"claude-sonnet-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3,cacheWrite:3.75,longContext:{aboveInputTokens:2e5,cacheMiss:6,output:22.5,cacheHit:.6,cacheWrite:7.5}},"claude-haiku-4-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:5,cachedInput:.1,cacheWrite:1.25},"gemini-3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.7-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:7.5,cachedInput:.15},"gemini-3.5-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.5,output:9,cachedInput:.15},"gemini-3.5-flash-lite":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.3,output:2.5,cachedInput:.03},"gemini-3.1-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:18,cacheHit:.4}},"gemini-3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.5,output:3,cachedInput:.05},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.3,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:.6}},"grok-build-0.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1,output:2,cachedInput:.2},"muse-spark-1.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"muse-spark-1.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:4.25,cachedInput:.15},"gpt-6-astra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:10,output:50,cachedInput:1,cacheWrite:12.5,longContext:{aboveInputTokens:272e3,cacheMiss:20,output:75,cacheHit:2,cacheWrite:25}},"gpt-6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.4,cacheWrite:5}},"gpt-6.1-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:10,cachedInput:.1,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:15,cacheHit:.2,cacheWrite:5}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-sol":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:4,output:20,cachedInput:.4,cacheWrite:5,longContext:{aboveInputTokens:272e3,cacheMiss:8,output:30,cacheHit:.8,cacheWrite:10}},"gpt-5.6-terra":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2,output:12,cachedInput:.2,cacheWrite:2.5,longContext:{aboveInputTokens:272e3,cacheMiss:4,output:18,cacheHit:.4,cacheWrite:5}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}},"gpt-5.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:5,output:30,cachedInput:.5,longContext:{aboveInputTokens:272e3,cacheMiss:10,output:45,cacheHit:1}},"gpt-5.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:2.5,output:15,cachedInput:.25,longContext:{aboveInputTokens:272e3,cacheMiss:5,output:22.5,cacheHit:.5}},"gpt-5.4-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:30,output:180,cachedInput:30},"gpt-5.4-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.75,output:4.5,cachedInput:.075},"gpt-5.4-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.2,output:1.25,cachedInput:.02},"gpt-5.3-codex-spark":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.3-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.2-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.75,output:14,cachedInput:.175},"gpt-5.1":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5.1-codex-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.25,output:10,cachedInput:.125},"gpt-5.1-codex-mini":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.25,output:2,cachedInput:.025},"gpt-5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-codex":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:1.07,output:8.5,cachedInput:.107},"gpt-5-nano":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/zen",checkedAt:"2026-10-03",input:.05,output:.4,cachedInput:.005}}},"opencode-go":{models:{"glm-5.3-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.5,cachedInput:.03},"glm-5.3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"glm-5.2":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:1.4,output:4.4,cachedInput:.26},"kimi-k3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:3,output:15,cachedInput:.3},"kimi-k2.7-code":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.19},"kimi-k2.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.95,output:4,cachedInput:.16},"longcat-2.0":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.006},"longcat-2.5-preview-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"mimo-v2.6-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.6-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"mimo-v2.5":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.28,cachedInput:.0028},"mimo-v2.5-pro":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.435,output:.87,cachedInput:.003625},"minimax-m3":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06},"minimax-m2.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.3,output:1.2,cachedInput:.06,cacheWrite:.375},"muse-spark-1.3-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"muse-spark-1.2-contributor":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.2,cachedInput:.002},"qwen3.8-max":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.25,cacheWrite:2.5},"qwen3.8-flash":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.15,output:.47,cachedInput:.016,cacheWrite:.2},"qwen3.7-plus":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.4,output:1.6,cachedInput:.04,cacheWrite:.5,longContext:{aboveInputTokens:256e3,cacheMiss:1.2,output:4.8,cacheHit:.12,cacheWrite:1.5}},"deepseek-v4.1-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-pro":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.66,output:1.98,cacheHit:.022},input:.66,output:1.98,cachedInput:.022,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:1.32,output:3.96,cacheHit:.044}},"deepseek-v4-flash":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"deepseek-v4-flash-vision-exp":{billingMode:"utc-peak",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",offPeak:{cacheMiss:.15,output:.6,cacheHit:.003},input:.15,output:.6,cachedInput:.003,notes:"Go published reference-token prices; Peak 01:00\u201304:00 and 06:00\u201310:00 UTC Monday\u2013Friday; weekends Off-Peak. Separate from direct DeepSeek and flat Zen prices. Historical effective dates and holiday treatment not verified.",peak:{cacheMiss:.3,output:1.2,cacheHit:.006}},"hy4-preview":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.834,output:2.501,cachedInput:.042},hy3:{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.14,output:.58,cachedInput:.035},"space-bunny-free":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:0,output:0,cachedInput:0},"grok-4.7":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"grok-4.6":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:2,output:6,cachedInput:.5,longContext:{aboveInputTokens:2e5,cacheMiss:4,output:12,cacheHit:1}},"gpt-6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.1,output:.5,cachedInput:.01,cacheWrite:.125,longContext:{aboveInputTokens:272e3,cacheMiss:.2,output:.75,cacheHit:.02,cacheWrite:.25}},"gpt-5.6-luna":{billingMode:"flat",sourceUrl:"https://opencode.ai/docs/go",checkedAt:"2026-10-03",input:.2,output:1.2,cachedInput:.02,cacheWrite:.25,longContext:{aboveInputTokens:272e3,cacheMiss:.4,output:1.8,cacheHit:.04,cacheWrite:.5}}}}},ee=Object.fromEntries([...new Set([...Object.keys(Xe),...Object.keys(_t)])].map(e=>[e,{models:{...Xe[e]?.models,..._t[e]?.models}}]));ee.stepfun=Ln;var Fn=structuredClone(ee);for(let[e,t]of Object.entries(Et))ee[e]={models:{...ee[e]?.models,...t.models}};var Bn=structuredClone(ee);for(let[e,t]of Object.entries(Hn))ee[e]={models:{...ee[e]?.models,...t.models}};var Wn={"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 zn=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,xi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,Ei=/^(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 vt(e,t){if(typeof t!="string"||t.length===0)return!1;if(zn.test(t)){let n=t.replace(new RegExp(zn.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(xi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||Ei.test(o)||o.length>=32&&/^[A-Za-z0-9_-]+$/.test(o)&&/[A-Za-z]/.test(o)&&/[0-9]/.test(o))}var et="https://amr-api.open-design.ai/api/v1",vs=et+"/public/model-prices",ke=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],Ps=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var _i=e=>typeof e=="string"&&/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);function Kn(e){return e===void 0||e===""?"":typeof e=="string"&&_i(e.trim())?e.trim():null}var tt=["vercel","copilot","cline","qoder","qoder-cn","qoder-global","trae","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cursor","windsurf","augment","roo","codebuddy"],B={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:["qwen","qwen-tokenplan","qianwen-tokenplan","qwen-token-plan","qianwen-token-plan"],scnet:["scnet","scnet-tokenplan","scnet-token-plan"],mimo:["mimo","xiaomimimo","mimo-token-plan","xiaomi-token-plan","xiaomi-token-plan-cn","xiaomi-token-plan-sgp","xiaomi-token-plan-ams"],factory:["factory","droid","factory-a","factory-g","factory-o"]};var $n=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function qn({normalizePrice:e,normalizeCustomPrice:t}){function o(b,w){let S=w?.models??{};if(typeof b=="string"&&b.length>0){let E=Object.hasOwn(S,b)?S[b]:void 0;if(E!==void 0)return E}return w?.default??{cacheHit:0,cacheMiss:0,output:0}}function n(b){return String(b??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function i(b){return n(b).replace(/[^\p{L}\p{N}]+/gu,"")}function r(b,w=!0,S=!0){let E=n(b);return w&&/[-_./:@](?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(E)?E.slice(0,-5):w&&S&&/[-_./:@]\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])$/.test(E)?E.slice(0,-7):E.replace(/[-_./:@](?:\d{4}-?\d{2}-?\d{2}|v\d+(?:\.\d+)*|\d+k|latest)$/,"")}function s(b,w,S=b,E=!0,_=!0){if(typeof b!="string"||b.length===0)return null;let R=Array.isArray(w)?w.filter(x=>typeof x=="string"&&x.length>0):[],I=R.find(x=>x===S);if(I!==void 0)return I;let M=b.normalize("NFKC").trim();if(/[:((]\s*(?:free|online)\b/i.test(M))return null;for(;;){let x=i(M);if(x.length===0)return null;let U=R.filter(J=>i(J)===x);if(U.length>0)return U.length===1?U[0]:null;let re=r(M,E,_);if(re===M.toLowerCase())return null;M=re}}let c=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),a={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 l(b){return["deepseek-peak","utc-peak"].includes(b?.billingMode)?b.billingMode:"flat"}function d(b,w,S,E,_){if(typeof b!="string")return null;if(Object.hasOwn(w,b))return b;if(E!=="auto")return null;let R=b.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),I=R.search(/[/:]/);if(I>0){let M=R.slice(0,I).trim().toLowerCase(),x=R.slice(I+1).trim();if(Object.hasOwn(a,M)&&(M===S||(S==="opencode-zen"||S==="opencode-go")&&(a[M].test(x)||s(x,Object.keys(M==="deepseek"?_?.models??{}:_?.providers?.[M]?.models??{}),x,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)!==null)))R=x;else if(Object.hasOwn(a,M))return null}return s(R,Object.keys(w),b,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)}function u(b,w,S,E){let _=E?.mode==="exact"?"exact":"auto",R=E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{},I=w,M=b,x=(b===""?"deepseek":b)+":"+w,U=R[x];if(U==="__custom__"){let h=t(S?.custom?.[x]);return{entry:h,billingMode:h?.billingMode??"flat",priced:h!==null,currency:h?.currency??"USD"}}if(U==="__local__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(typeof U=="string"&&U.length>0){let h=U.indexOf(":");if(h>0&&U.slice(h+1).length>0?(M=U.slice(0,h).trim().toLowerCase(),I=U.slice(h+1)):I=U,M==="deepseek"&&I==="__default__"){let y=S?.default??{cacheHit:0,cacheMiss:0,output:0},T=e(y);return T===null?{entry:null,billingMode:"flat",priced:!1}:{entry:T,billingMode:"deepseek-peak",priced:T.unpriced!==!0}}}if(["zen","opencode","opencode-go-plus"].includes(M)){let h=d(I,S?.providers?.[M]?.models??{},"opencode-go",_,S);h===null?M="opencode-go":I=h}if(ke.includes(M)&&M!=="opendesign"&&d(I,S?.providers?.[M]?.models??{},M,_,S)===null&&(M="opendesign"),C(M,I))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(M==="openrouter"){let h=S?.providers?.openrouter?.models??{},y=Object.hasOwn(h,I)?e(h[I]):null;return{entry:y,billingMode:"flat",priced:y!==null&&y.unpriced!==!0}}if(M===""||M==="deepseek"||M.includes("deepseek")){let h=S?.models??{},y=d(I,h,"deepseek",_,S);if(y!=null){let D=h[y],H=e(D);return H===null||H.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:H,billingMode:"deepseek-peak",priced:!0}}if(_==="auto"){let D=null,H=-1,Y=!1,z="flat";for(let[se,ce]of Object.entries(S?.providers??{})){if(c.has(se))continue;let Ee=ce?.models??{},X=d(I,Ee,se,_,S);if(X===null)continue;let xn=e(Ee[X]);if(xn===null)continue;let wt=+(X===I||i(X)===i(I));wt>H?(D=xn,H=wt,Y=!1,z=l(Ee[X])):wt===H&&(Y=!0)}if(Y)return{entry:null,billingMode:"flat",priced:!1};if(D!==null)return{entry:D,billingMode:z,priced:D.unpriced!==!0}}let T=o(I,S),F=e(T);return F===null?{entry:null,billingMode:"flat",priced:!1}:{entry:F,billingMode:"deepseek-peak",priced:F.unpriced!==!0}}let J=S?.providers?.[M]?.models??{},L=d(I,J,M,_,S);if(L===null&&c.has(M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&Object.hasOwn(a,M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&_==="auto"){let h=null,y=-1,T=!1,F="flat";for(let[D,H]of[["deepseek",{models:S?.models??{}}],...Object.entries(S?.providers??{})]){if(D===M||c.has(D))continue;let Y=H?.models??{},z=d(I,Y,D,_,S);if(z===null)continue;let se=e(Y[z]);if(se===null||D==="mistral"&&z.startsWith("deepseek-")&&z!==I&&!M.includes("mistral")&&!/^mistral[/:]/i.test(String(I).trim()))continue;let ce=+(z===I||i(z)===i(I));ce>y?(h=se,y=ce,T=!1,F=D==="deepseek"?"deepseek-peak":l(Y[z])):ce===y&&(T=!0)}if(T)return{entry:null,billingMode:"flat",priced:!1};if(h!==null)return{entry:h,billingMode:F,priced:h.unpriced!==!0}}if(L===null)return{entry:null,billingMode:"flat",priced:!1};let f=e(J[L]);return f===null||f.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:f,billingMode:l(J[L]),priced:!0}}function p(b,w,S){let E=w?.models??{},_=Object.hasOwn(E,b)?b:S==="auto"?s(b,Object.keys(E),b,w?.snapshotTags!==!1,w?.shortSnapshotTags!==!1):null;if(_==null)return null;let R=E[_],I=e(R);return I===null||I.unpriced===!0?null:{entry:I,billingMode:"deepseek-peak",priced:!0}}function m(b){return typeof b!="string"||b.length===0?!1:b.startsWith("modlens-")||b==="deepseek-modlens"}function g(b){if(typeof b!="string"||b.length===0)return null;if(b==="deepseek-modlens")return"deepseek-official";if(b.startsWith("modlens-")){let w=b.slice(8);return w.length>0?w:null}return null}let k=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),O=["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 C(b,w){if(typeof b=="string"&&k.has(b))return!0;let S=typeof w=="string"?n(w):"";return O.some(E=>S.startsWith(E))}function N(b,w,S,E,_){let R=_?.[(b||"deepseek")+":"+w];if(!b||E==="exact"||typeof w!="string"||C(b,w)||["our-free-model","our-free-model-region"].includes(b)||typeof R=="string"&&R.length>0||Object.hasOwn(S?.providers?.[b]?.models??{},w))return null;let I=w.indexOf("/");if(I<=0||I===w.length-1)return null;let M=w.slice(0,I).toLowerCase(),x=w.slice(I+1),U={codex:"openai",claude:"anthropic",gemini:"google","ollama-cloud":"ollama-cloud",volcengine:"volcengine",ark:"ark"},re=/^(?:dsh-)?magpie(?:$|-)/.test(b),J=Object.hasOwn(U,M)||c.has(M)||["workbuddy","workbuddy-ai","qoder","qoder-cn","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cline","copilot","vercel"].includes(M);if(!re&&(!J||Object.hasOwn(a,b)||c.has(b))||/(?:^|-)free$/.test(M)&&!Object.hasOwn(S?.providers??{},M))return null;let L=U[M]??M;return L==="deepseek"&&d(x,S?.models??{},"deepseek","auto",S)===null?null:{provider:Object.hasOwn(U,M)||c.has(L)||Object.hasOwn(a,L)||Object.hasOwn(S?.providers??{},L)||C(L,x)?L:b,model:x}}function A(b,w,S,E){let _=typeof b=="string"?b.trim().toLowerCase():"",R=_.startsWith("llm-")?_.slice(4):_,I=N(R,w,S,E?.mode,E?.overrides);if(I&&(R=I.provider,w=I.model,E={...E,overrides:{}}),["our-free-model","our-free-model-region"].includes(R)&&E?.overrides?.[R+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let M=$e(P(R,w,S,E),R,S);return["volcengine","ark"].includes(R)&&S?.volcenginePeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"volcengine"}}:R==="ollama-cloud"&&S?.ollamaPeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"&&(S?.ollamaTaggedPeak===!1?$n.has(typeof w=="string"?w.trim().toLowerCase():""):s(w,[...$n])!==null)?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"ollama"}}:M}function P(b,w,S,E){let _=u(b,w,S,E);if(_.currency&&!_.local)return _;if(_.priced&&!_.local||b===""||b==="deepseek"||b.includes("deepseek"))return v(_,S);let I=(E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{})[b+":"+w];if(typeof I!="string"||I.length===0||I==="__local__"||I.includes(":"))return v(_,S);let M=E?.mode==="exact"?"exact":"auto";return v(p(I,S,M)??_,S)}function v(b,w){return b.currency?b:b.priced?w?.currency==="CNY"&&b.entry?.cny?{...b,entry:Je(b.entry),currency:"CNY"}:{...b,currency:b.billingMode==="deepseek-peak"&&w?.currency==="CNY"?"CNY":"USD"}:{...b,currency:"USD"}}return A}var vi=qn({normalizePrice:W,normalizeCustomPrice:Ne});var Gn="2026-08-01T00:00:00Z",Tt="2026-08-22T16:00:00Z",ot=["2026-09-25","2026-09-26","2026-09-27","2026-10-01","2026-10-02","2026-10-03","2026-10-04","2026-10-05","2026-10-06","2026-10-07"],Pt="2026-09-10T04:00:00Z",Pi="2026-08-31T00:00:00Z",Yn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Ni(e){if(!Number.isFinite(e)||e<Date.parse(Tt))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(Tt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ri(e,t=ot){if(!Number.isFinite(e)||e<Date.parse(Tt)||!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 Ti=(e,t)=>Ri(e,t)??Ni(e),Di="2026-08-16T16:00:00Z";var Qn=[{start:1,end:4},{start:6,end:10}],me={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"}}}},Vn=Object.freeze(Object.keys(me["opencode-go"].models)),ne={...me};ne.opendesign={models:Wn};for(let[e,t]of Object.entries(ee)){let o=me[e]?.models??{};ne[e]={models:{...e==="opencode-zen"||e==="opencode-go"?{}:o,...t.models}}}function Me(e,t=me){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(ne)){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(p=>!l.has(p)))continue;let d=W(r[c]),u=W(s[c]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[c]=structuredClone(a))}}}function Zn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Xe[o]?.models}}]));Me(e,t)}function Jn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Fn[o]?.models}}]));Me(e,t)}function Xn(e){let t=Object.fromEntries(Object.keys(ne).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Bn[o]?.models}}]));Me(e,t)}function eo(e){Me(e,Object.fromEntries(Object.entries(ne).filter(([t])=>t!=="stepfun")))}var Ui={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 Nt(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 to(e){let t=e==="CNY"?ji:Ui,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):Nt(i,e,Pt)]));return o["deepseek-v4.1-flash"]=Nt(t.models["deepseek-v4-flash-vision-exp"],e,Pt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:Nt(t.default,e,Pt)}}var Ut=to("USD"),no=to("CNY");function jt(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 le(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 W(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)||!Ke(e))return null;let t={...le(e),...he(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,...le(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=le(e.cny)}let n=le(e.offPeak);n!==void 0&&(t.offPeak=n);let i=le(e.peak);i!==void 0&&(t.peak=i);let r=le(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,...le(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]=le(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)),xt(t)?t:null}function Pe(e){return String(e??"").normalize("NFKC").toLowerCase().replace(/[((]\s*(?:go|zen)\s*[))]/g," ").trim()}function de(e){return Pe(e).replace(/[\s._\-\u2010-\u2015\u2212]+/gu,"")}function Hi(e,t=!0,o=!0){let n=Pe(e),i=n.match(/[-_./:@](\d{4}-\d{2}-\d{2}|\d{8}|\d{6}|\d{4})$/);if(i){let r=i[1].replaceAll("-","");if(r.length===4&&!t||r.length===6&&(!t||!o))return n;let s=r.length===4?2e3:r.length===6?2e3+Number(r.slice(0,2)):Number(r.slice(0,4)),c=Number(r.slice(-4,-2)),a=Number(r.slice(-2)),l=new Date(Date.UTC(s,c-1,a));return s>=2e3&&l.getUTCFullYear()===s&&l.getUTCMonth()===c-1&&l.getUTCDate()===a?n.slice(0,i.index):n}return n.replace(/[-_./:@]latest$/,"")}function oo(e,t,o=e,n=!0,i=!0){if(typeof e!="string"||e.length===0)return null;let r=Array.isArray(t)?t.filter(l=>typeof l=="string"&&l.length>0):[],s=r.find(l=>l===o);if(s!==void 0)return{id:s,rank:3};let c=e.normalize("NFKC").trim(),a=2;for(;;){let l=de(c);if(l.length===0)return null;let d=r.filter(p=>de(p)===l);if(d.length>0)return{id:d.length===1?d[0]:null,rank:a};if(/[:((]\s*(?:free|online)\b/i.test(c))return null;let u=Hi(c,n,i);if(u===c.toLowerCase())return null;c=u,a=1}}function Ht(e,t,o=e,n=!0,i=!0){return oo(e,t,o,n,i)?.id??null}var we=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),ue={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 Rt(e){return["deepseek-peak","utc-peak"].includes(e?.billingMode)?e.billingMode:"flat"}function Ae(e,t,o,n,i){if(typeof e!="string")return null;if(Object.hasOwn(t,e))return{id:e,rank:3};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=c==="deepseek-ai"?"deepseek":c,l=r.slice(s+1).trim();if(Object.hasOwn(ue,a)&&(a===o||["opencode-zen","opencode-go","zen","opencode","opencode-go-plus"].includes(o)&&(ue[a].test(l)||Ht(l,Object.keys(a==="deepseek"?i?.models??{}:i?.providers?.[a]?.models??{}),l,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=l;else if(Object.hasOwn(ue,a))return null}return oo(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Li(e,t,o,n,i){return Ae(e,t,o,n,i)?.id??null}function Dt(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 u=Ne(o?.custom?.[a]);return{entry:u,billingMode:u?.billingMode??"flat",priced:u!==null,currency:u?.currency??"USD"}}if(l==="__local__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(typeof l=="string"&&l.length>0){let u=l.indexOf(":");if(u>0&&l.slice(u+1).length>0?(c=l.slice(0,u).trim().toLowerCase(),s=l.slice(u+1)):s=l,c==="deepseek"&&s==="__default__"){let p=o?.default??{cacheHit:0,cacheMiss:0,output:0},m=W(p);return m===null?{entry:null,billingMode:"flat",priced:!1}:{entry:m,billingMode:"deepseek-peak",priced:m.unpriced!==!0}}}if(!G(c,s)&&c!=="openrouter"){let u=o?.providers?.[c]?.models??{},p=Ae(s,u,c,i,o);if(p){let m=p.id===null?null:u[p.id],g=W(m);return{entry:g,billingMode:Rt(m),priced:g!==null&&g.unpriced!==!0}}}if(/(?:^|[-_])free(?:$|[-_])/.test(c)&&!["our-free-model","our-free-model-region"].includes(c))return{entry:null,billingMode:"flat",priced:!1};if(c!=="opencode-go"&&B.go.includes(c))return Dt("opencode-go",s,o,{...n,overrides:{}});if(ke.includes(c)&&c!=="opendesign")return Dt("opendesign",s,o,{...n,overrides:{}});if(G(c,s))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(c==="openrouter"){let u=o?.providers?.openrouter?.models??{},p=Object.hasOwn(u,s)?W(u[s]):null;return{entry:p,billingMode:"flat",priced:p!==null&&p.unpriced!==!0}}if(["","deepseek","deepseek-official","deepseek-account"].includes(c)){let u=o?.models??{},p=Ae(s,u,"deepseek",i,o);if(p){let m=p.id===null?null:u[p.id],g=W(m);return g===null||g.unpriced===!0?{entry:null,billingMode:"flat",priced:!1}:{entry:g,billingMode:"deepseek-peak",priced:!0}}if(i==="auto"){let m=null,g=-1,k=!1,O="flat";for(let[C,N]of Object.entries(o?.providers??{})){if(we.has(C))continue;let A=N?.models??{},P=Ae(s,A,C,i,o);if(!P)continue;let v=P.id===null?null:A[P.id],b=W(v),w=P.rank;w>g?(m=b,g=w,k=P.id===null||b===null,O=Rt(v)):w===g&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(m!==null)return{entry:m,billingMode:O,priced:m.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}if(we.has(c))return{entry:null,billingMode:"flat",priced:!1};let d=i==="auto"&&!l&&/^deepseek/i.test(Pe(s).replace(/^deepseek(?:-ai)?[/:]\s*/,""));if(Object.hasOwn(ue,c)&&!d)return{entry:null,billingMode:"flat",priced:!1};if(i==="auto"){let u=null,p=-1,m=!1,g="flat";for(let[k,O]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(k===c||we.has(k))continue;let C=O?.models??{},N=Ae(s,C,k,i,o);if(!N)continue;let A=N.id,P=A===null?null:C[A],v=W(P);if(k==="mistral"&&A?.startsWith("deepseek-")&&A!==s&&!c.includes("mistral")&&!/^mistral[/:]/i.test(String(s).trim()))continue;let b=N.rank;b>p?(u=v,p=b,m=A===null||v===null,g=k==="deepseek"?"deepseek-peak":Rt(P)):b===p&&(m=!0)}if(m)return{entry:null,billingMode:"flat",priced:!1};if(u!==null)return{entry:u,billingMode:g,priced:u.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}function Fi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Ht(e,Object.keys(n),e,t?.snapshotTags!==!1,t?.shortSnapshotTags!==!1):null;if(i==null)return null;let r=n[i],s=W(r);return s===null||s.unpriced===!0?null:{entry:s,billingMode:"deepseek-peak",priced:!0}}var Bi=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),Wi=["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 G(e,t){if(typeof e=="string"&&Bi.has(e))return!0;let o=typeof t=="string"?Pe(t):"";return Wi.some(n=>o.startsWith(n))}function zi(e,t,o,n,i){let r=i?.[(e||"deepseek")+":"+t];if(!e||n==="exact"||typeof t!="string"||G(e,t)||/(?:^|[-_])free(?:$|[-_])/.test(e)||typeof r=="string"&&r.length>0||Ae(t,o?.providers?.[e]?.models??{},e,"auto",o))return null;let s=t.normalize("NFKC").trim(),c=s.indexOf("/");if(c<=0||c===s.length-1)return null;let a=s.slice(0,c).trim().toLowerCase().replace(/^llm-/,""),l=s.slice(c+1).trim(),d={codex:"openai",claude:"anthropic",gemini:"google","deepseek-ai":"deepseek","deepseek-official":"deepseek","ollama-cloud":"ollama-cloud",volcengine:"volcengine",ark:"ark"},u=/^(?:dsh-)?magpie(?:$|-)/.test(e),p=["our-free-model","our-free-model-region"].includes(a),m=Object.hasOwn(d,a)||we.has(a)||Object.hasOwn(o?.providers??{},a)||Object.values(B).some(k=>k.includes(a))||tt.includes(a)||p;if(!u&&(!m||we.has(e)||B.go.includes(e))||/(?:^|[-_])free(?:$|[-_])/.test(a)&&!p)return null;let g=Object.hasOwn(d,a)?d[a]:B.go.includes(a)?"opencode-go":a;return!u&&Object.hasOwn(ue,e)&&Object.hasOwn(ue,g)&&g!==e&&(g!=="deepseek"||!/^deepseek/i.test(Pe(l)))||Object.hasOwn(ue,g)&&Li(l,g==="deepseek"?o?.models??{}:o?.providers?.[g]?.models??{},g,"auto",o)===null?null:{provider:m||Object.hasOwn(d,a)||we.has(g)||Object.hasOwn(ue,g)||Object.hasOwn(o?.providers??{},g)||G(g,l)?g:e,model:l}}function io(e,t,o,n){if(o?.legacyModelMatching===!0)return vi(e,t,o,n);let i=typeof e=="string"?e.trim().toLowerCase():"",r=i.startsWith("llm-")?i.slice(4):i,s=Object.fromEntries(["our-free-model:*","our-free-model-region:*"].filter(a=>n?.overrides?.[a]==="__free__").map(a=>[a,"__free__"]));for(let a=0;a<8;a++){let l=zi(r,t,o,n?.mode,n?.overrides);if(!l)break;r=l.provider,t=l.model,n={...n,overrides:s}}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 c=$e(Ki(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&c.entry&&c.billingMode==="deepseek-peak"?{...c,entry:{...c.entry,peakSchedule:c.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&c.entry&&c.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?Yn.has(typeof t=="string"?t.trim().toLowerCase():""):Ht(t,[...Yn])!==null)?{...c,entry:{...c.entry,peakSchedule:c.entry.peakSchedule??"ollama"}}:c}function Ki(e,t,o,n){let i=Dt(e,t,o,n);if(i.currency&&!i.local)return i;if(i.priced&&!i.local||["","deepseek","deepseek-official","deepseek-account"].includes(e))return nt(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 nt(i,o);let c=n?.mode==="exact"?"exact":"auto";return nt(Fi(s,o,c)??i,o)}function nt(e,t){return e.currency?e:e.priced?t?.currency==="CNY"&&e.entry?.cny?{...e,entry:Je(e.entry),currency:"CNY"}:{...e,currency:e.billingMode==="deepseek-peak"&&t?.currency==="CNY"?"CNY":"USD"}:{...e,currency:"USD"}}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e)||!["USD","CNY"].includes(e.currency)||!["cacheMiss","cacheHit","output"].every(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=W(e);if(!t)return null;let o={...t,currency:e.currency,billingMode:e.billingMode==="deepseek-peak"?"deepseek-peak":"flat"};return xt(o)?o:null}function $i(e,t,o,n=ot){if(!Array.isArray(o)||o.length===0||Ti(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 qi(e,t,o){let n=jt(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(a,l="base")=>Ze(a,n,l),r=_n(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(Pi))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($i(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 Lt(e,t,o,n){let i=qi(t,o,n),r=m=>{let g=Number(m);return Number.isFinite(g)&&g>0?g: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,p=(s*i.cacheMiss+c*i.output+a*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(p)&&p>0?p:0}function Ft(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 Bt={enabled:!1,providerPrefix:"local",referenceModel:"deepseek-flash",priceTier:"offPeak"},Yi=["base","offPeak","peak"];var Gi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ro=e=>typeof e=="string"&&e.trim().length>0&&e.trim().length<=512;function Wt(e){let t=Gi(e)?e:{};return{enabled:t.enabled===!0,providerPrefix:ro(t.providerPrefix)?t.providerPrefix.trim().toLowerCase():Bt.providerPrefix,referenceModel:ro(t.referenceModel)?t.referenceModel.trim():Bt.referenceModel,priceTier:Yi.includes(t.priceTier)?t.priceTier:Bt.priceTier}}import{readFileSync as Wr,renameSync as li,statSync as zr}from"node:fs";import{randomUUID as ui}from"node:crypto";var so=5/1e3,Qi=Date.parse("2026-11-01T00:00:00+08:00"),co=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function ao(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 lo(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<Qi?0:so):e.source===void 0&&e.rateCny===so}var zt=["input","output","cacheRead","cacheWrite","reasoning","calls"],oe=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function ge(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=$.filter(u=>i.every(p=>oe(p?.[u]))),c=Object.fromEntries([...zt,"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 p of Object.keys(c)){let m=p==="apiCost"?u.apiCost??u.cost:u[p]??0;if(!oe(m)){l=!1;break}c[p]+=m}if(!l||c.apiCost>c.cost+1e-8){l=!1;break}for(let[p,m]of Object.entries(u.byProviderModel??{})){if(a.has(p)&&a.get(p)===null)continue;let g=a.get(p)??Object.fromEntries(Object.keys(c).map(O=>[O,0])),k=m!==null&&typeof m=="object";for(let O of Object.keys(g)){if($.includes(O)&&!oe(m?.[O])){delete g[O];continue}let C=O==="apiCost"?m?.apiCost??m?.cost:m?.[O]??0;if(!oe(C)){k=!1;break}g[O]+=C}a.set(p,k?g:null)}}if(!l||!Object.values(c).every(oe)||!zt.every(u=>oe(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,p]of a){let m=n.byProviderModel?.[u];if(!(!p||!m||!p.calls||!Object.values(p).every(oe)||!zt.every(g=>p[g]===(m[g]??0)))&&!(Math.abs(p.cost-(m.cost??0))<=1e-8&&Math.abs(p.apiCost-(m.apiCost??m.cost??0))<=1e-8&&s.every(g=>!oe(p[g])||Math.abs(p[g]-(m[g]??0))<=1e-8))){for(let g of s)oe(p[g])&&(m[g]=p[g]);m.cost=p.cost,m.apiCost=p.apiCost,d=!0}}d&&t.push(o)}return t}import{Worker as Vi,MessageChannel as Zi,receiveMessageOnPort as uo}from"node:worker_threads";import{randomUUID as Ji}from"node:crypto";import{unlinkSync as Xi,rmdirSync as er}from"node:fs";import{join as tr}from"node:path";function po(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new Zi,s=new Int32Array(new SharedArrayBuffer(4)),c=!1,a,l,d,u=Ji(),p=new Promise(O=>{a=O}),m=new Vi(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),g=O=>{if(!c){c=!0,clearTimeout(k);try{t(O)}finally{i.close(),m.terminate(),a()}}},k=setTimeout(()=>{l={error:{message:"Ledger worker timed out",code:"ETIMEDOUT"}},m.terminate().then(()=>g(l))},o);return k.unref?.(),i.on("message",g),m.on("error",O=>{d={error:{message:O.message,code:O.code}}}),m.on("exit",O=>{if(!c){try{Xi(tr(`${e.path}.lock`,`${process.pid}-${u}`)),er(`${e.path}.lock`)}catch{}g(uo(i)?.message??l??d??{error:{message:`Ledger worker exited (${O})`}})}}),{promise:p,wait(O=8e3){let C=Date.now()+O;for(;!c;){let N=uo(i);if(N){g(N.message);break}if(Date.now()>=C)return!1;Atomics.wait(s,0,0,Math.min(50,C-Date.now()))}return!0}}}function Kt(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 Vo,readdirSync as Nr,writeFileSync as ti,readFileSync as ni,renameSync as Rr,unlinkSync as gt,rmdirSync as mt,statSync as Tr,copyFileSync as Dr,openSync as Zo,fsyncSync as Jo,closeSync as Xo,constants as Ur}from"node:fs";import{dirname as oi,join as He}from"node:path";import{randomUUID as ii}from"node:crypto";import{isDeepStrictEqual as K}from"node:util";var fo="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var ho="https://api.factory.ai/api/billing/limits";var mo=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};import{homedir as $t}from"node:os";import{basename as dc,dirname as pc,join as go,resolve as nr}from"node:path";var bo=".dsh",fc=`~/${bo}`,or="DSH_HOME",ir=".agents",hc=`~/${ir}`;function rr(){return go($t(),bo)}function sr(e){return e==="~"?$t():e.startsWith("~/")||e.startsWith("~\\")?go($t(),e.slice(2)):e}function cr(e,t,o,n){let i=t[o];return nr(sr(e??(i!==void 0&&i.trim().length>0?i:n())))}function qt(e,t=process.env){return cr(e,t,or,rr)}var Yt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var ur=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var jc=672*60*60,Hc=744*60*60;var Qc=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),Vc=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 dr={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"}},Re=Object.keys(dr);var Qt="https://platform.xiaomimimo.com/api/v1",pr={usage:`${Qt}/tokenPlan/usage`,detail:`${Qt}/tokenPlan/detail`,balance:`${Qt}/balance`},Ra=B.mimo;var fr="open.volcengineapi.com";var hr="2024-01-01",mr=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var gr={"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 ko(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var Ta=Object.fromEntries(Object.entries(gr).map(([e,t])=>[ko(e),t]));var Da=B.scnet;var br={"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}},Ua=Object.fromEntries(Object.entries(br).map(([e,t])=>[ko(e),t])),ja=B.qwen;var Ha={opendesign:[et+"/workspaces/{workspaceId}/billing/preflight",et+"/workspaces/{workspaceId}/wallet/balance"],factory:[ho],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:mr.map(e=>`https://${fr}/?Action=${e}&Version=${hr}`),mimo:[pr.usage],"baidu-coding":[fo],workbuddy:[]};function Ao(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 yr={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"},kr=Object.entries(yr).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function it(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=kr.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 ie=[...Re,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Vt={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"},Mo=400,So=2160*36e5,Ga=168*36e5;var Ar=840*36e5;function Io(e,t){let o=String(e??"").normalize("NFKC").trim().toLowerCase().replace(/^llm-/,"");if(!o||typeof t!="string"||G(o,t)||/(?:^|[-_])free(?:$|[-_])/.test(o)||o==="opencode-zen"||ie.includes(o)||Object.values(B).some(c=>c.includes(o))||it(e)!==null)return null;let n=t.normalize("NFKC").trim().split("/").map(c=>c.trim());if(n.some(c=>!c)||n.slice(0,-1).some(c=>/(?:^|[-_])free(?:$|[-_])/.test(c.toLowerCase())||G(c.toLowerCase().replace(/^llm-/,""),""))||G("",n.at(-1)))return null;let i=/^(?:dsh-)?magpie(?:$|-)/.test(o),r=["openai","google","deepseek","deepseek-ai","deepseek-official","moonshot","z-ai","xai","alibaba","tencent","xiaomi","upstage","nvidia","mistral","meta","meituan","gemini","claude","ollama-cloud","ark"],s={anthropic:{vendor:"anthropic",model:/^claude/i},minimax:{vendor:"minimax",model:/^minimax/i},stepfun:{vendor:"stepfun",model:/^step-/i},codex:{vendor:"openai",model:/^(?:gpt|o\d|codex)/i}};for(let c=0;c<Math.min(n.length-1,8);c++){let a=n[c].toLowerCase().replace(/^llm-/,"");if(a==="openrouter"||a==="opencode-zen"||r.includes(a)||/(?:^|[-_])free(?:$|[-_])/.test(a)||G(a,n.slice(c+1).join("/")))return null;let l=Object.hasOwn(s,a)?s[a]:null;if(l){let d=n.slice(c+1);if(d[0].toLowerCase()===l.vendor&&d.shift(),d.length!==1||!l.model.test(d[0]))return null}for(let[d,u]of Object.entries(B))if(u.includes(a)||d===a)return{id:d,provider:a};if(ie.includes(a))return{id:a,provider:a};if(!i&&!tt.includes(a))return null}return null}function Zt(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(ie.includes(i))return i;if(n.length===0)return null;for(let[s,c]of Object.entries(B))if(c.includes(n))return s;if(ie.includes(n))return n;let r=it(e);return r!==null?r:G(n,o)||/(?:^|[-_])free(?:$|[-_])/.test(n)||n==="opencode-zen"?null:typeof o=="string"&&o.normalize("NFKC").includes("/")?Io(e,o)?.id??null:it(e,o)}var wo=new WeakMap;function wr(e){let t=wo.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(de)),n=new Set,i=new Set(Vn.map(de));for(let r of Object.keys(e?.providers?.["opencode-go"]?.models??{}))i.has(de(r))&&n.add(de(r));for(let r of o)n.delete(r);t={dsCanon:o,thirdCanon:n},wo.set(e,t)}return t}function Jt(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=de(t);if(i.length===0)return!1;let{dsCanon:r,thirdCanon:s}=wr(o);return!r.has(i)&&s.has(i)}function Oo(e,t,o,n,i){if(co(e,t))return"api";let r=Zt(e,o,t);r===null&&Jt(e,t,i)&&(r="go");let s=o?.models;if(s!==null&&typeof s=="object"){let d=s[`${e}:${t}`];if(d==="plan"||d==="api")return d;if(r!==null){let u=s[`${r}:${t}`];if(u==="plan"||u==="api")return u}}let c=o?.providers;for(let d of[e,r]){if(d==null)continue;let u=c?.[d];if(u==="plan"||u==="api")return u}if(r===null)return"api";let a=Io(e,t),l=a?.id===r?a.provider:e;return r==="go"&&/^(?:llm-)?(?:dsh-opencode-go|opencode-go(?:-plus)?)$/i.test(String(l).trim())||r==="kimi"&&/^(?:llm-)?kimi-coding(?:-plan)?$/i.test(String(l).trim())||r==="minimax"&&/^(?:llm-)?minimax-(?:m-?plan|token-plan)$/i.test(String(l).trim())||n instanceof Set&&n.has(r)?"plan":"api"}function rt(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>ie.includes(n)));let t=new Set,o=e?.codingPlans;if(o!==null&&typeof o=="object")for(let n of Re)o[n]?.enabled===!0&&t.add(n);return e?.goQuota?.enabled===!0&&t.add("go"),e?.codexQuotaEnabled===!0&&t.add("codex"),t}function Co(e){return JSON.stringify([e?.planBilling,[...rt(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function Xt(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 xo(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Ar,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 p=Number(d);if(!Number.isFinite(p)||p<n||p>o+36e5){s=!0;continue}l[p]={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 en(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=Xt(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as ct,readlinkSync as Mr,statSync as Sr}from"node:fs";import{execFileSync as Eo}from"node:child_process";import{hostname as Ir}from"node:os";import{join as Or}from"node:path";import{performance as Cr}from"node:perf_hooks";var vo=Ir(),at=process.platform==="win32"?Cr.timeOrigin:Date.now()-process.uptime()*1e3,_o={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},tn,nn,st;function on(e,t=!1,o=!1){try{if(process.platform==="linux"){let n=ct(`/proc/${e}/stat`,"utf8"),i=n.slice(n.lastIndexOf(")")+2).trim().split(/\s+/)[19];if(!/^\d+$/.test(i??""))return null;let r=ct("/proc/sys/kernel/random/boot_id","utf8").trim(),s=Mr(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let c=e===process.pid?at:null;if(t&&e!==process.pid){st??=Number(Eo("getconf",["CLK_TCK"],_o).trim());let a=ct("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(st)&&st>0&&a&&(c=(Number(a)+Number(i)/st)*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(at)),unit:"ms",startedAtMs:at};let n=Or(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=Eo(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],_o).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function rn(){return tn===void 0&&(tn=on(process.pid)),tn}function Po(){let e=rn();return JSON.stringify({version:e?.unit==="ms"?2:1,host:vo,identity:e})}function No(e,t,o=new Map){if(!Number.isSafeInteger(t)||t<=0||t>2147483647)return!1;let n=ct(e,"utf8"),i;if(n!==""){try{i=JSON.parse(n)}catch{}if(i?.host&&i.host!==vo)return!1;let c=rn();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,on(t,n===""));let s=t===process.pid?rn():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(nn===void 0&&(nn=on(t,!1,!0)),s=nn),n===""){let c=t===process.pid?s?.startedAtMs??at:s?.startedAtMs;return Number.isFinite(c)&&Sr(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 Er,randomUUID as an}from"node:crypto";import{createHash as xr}from"node:crypto";var Q=new WeakMap,Ro=/^[a-f\d]{64}$/,Te=e=>e&&typeof e=="object"&&!Array.isArray(e),To=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),sn=e=>xr("sha256").update(JSON.stringify(e)).digest("hex"),Do=24;function ut(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))ut(t);return Object.freeze(e)}function Uo(e,t,o=[],n=[]){if(e===t)return n;if(Te(e)&&Te(t))for(let i of new Set([...Object.keys(e),...Object.keys(t)]))To(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)?Uo(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 jo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=jo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function lt(e,t,o,n){let i=o.get(n);if(i&&i.depth<Do){let r={base:n,patch:Uo(t[n],e)},s=JSON.stringify(r).length;if(s<1024||s<JSON.stringify(e).length)return{record:ut(r),depth:i.depth+1,signature:sn(r),baseValue:t[n]}}return{record:e,depth:0,signature:sn(e)}}function dt(e,t,o,n){let i=Q.get(e)??new Map;Q.set(e,i),Object.hasOwn(e,t)||(e[t]=ut(o)),i.has(t)||i.set(t,lt(e[t],e,i,n))}function Ho(e={}){let t={...e};return Q.set(t,new Map(Q.get(e)??[])),t}function Lo(e,t){let o={...t,...e};return Q.set(o,new Map([...Q.get(t)??[],...Q.get(e)??[]])),o}function Fo(e){let t=Q.get(e)??new Map;Q.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,lt(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function Bo(e,t,o){let n={},i=new Map,r=Q.get(o),s=new Set,c=a=>{if(i.has(a))return!0;if(!Ro.test(a)||s.has(a)||s.size>Do||!Te(e[a]))return!1;s.add(a);let l=e[a],d;if(!Te(l.prices)){if(!Ro.test(l.base)||!Array.isArray(l.patch)||l.patch.length>1e5||l.patch.some(g=>!Array.isArray(g)||![1,2].includes(g.length)||!Array.isArray(g[0])||g[0].length>16||!g[0].every(To))||!c(l.base))return s.delete(a),!1;d=i.get(l.base)}let u=sn(l),p=d?n[l.base]:void 0,m=r?.get(a);if(m&&o[a]&&(m.sourceSignature===u&&m.sourceBase===p||m.signature===u&&m.baseValue===p))n[a]=o[a],i.set(a,m);else{let g=d?n[l.base]:l;if(d)for(let O of l.patch)g=jo(g,O[0],O);if(!Te(g?.prices))return s.delete(a),!1;n[a]=ut(t(g));let k=lt(n[a],n,i,d?l.base:void 0);i.set(a,{...k,sourceSignature:u,sourceBase:p})}return s.delete(a),!0};for(let a of Object.keys(e))c(a);if(Q.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,{...lt(n[l],n,i,a),sourceSignature:d,sourceBase:u}),a=l}}return n}var Ko=new WeakMap,ft=new WeakMap,De=new WeakSet,_r=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],un=e=>Er("sha256").update(JSON.stringify(e)).digest("hex"),Se=e=>!["__proto__","constructor","prototype"].includes(e),pt=e=>e&&typeof e=="object"&&!Array.isArray(e),vr=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"]);function dn(e,t,o){if(!e||typeof e!="object"||!t)return o();if(t.has(e))return t.get(e);let n=o();return t.set(e,n),t.set(n,n),n}var Ue=(e,t)=>dn(e,t?.rates,()=>Array.isArray(e)?e.map(o=>Ue(o,t)):pt(e)?Object.fromEntries(Object.entries(e).filter(([o])=>vr.has(o)||Ct.test(o)).map(([o,n])=>[o,Ue(n,t)])):e),cn=(e,t)=>dn(e,t?.models,()=>Object.fromEntries(Object.entries(e??{}).filter(([o])=>Se(o)).map(([o,n])=>[o,Ue(n,t)]))),Wo=["at","before","after","days","sessions","skipped"];function Pr(e){return typeof e?.sessionId=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e.date)&&typeof e.model=="string"&&["usage","ledgerModelMissing","logModelMissing","dayModelMissing","logMissing"].includes(e.reason)&&Array.isArray(e.fields)&&e.fields.every(t=>["input","output","cacheRead","cacheWrite","reasoning","calls"].includes(t?.field)&&Number.isFinite(t.ledger)&&t.ledger>=0&&Number.isFinite(t.log)&&t.log>=0)}var ln=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function $o(e){let t=ft.get(e);if(t)return t;let o=new Map,n=new Set;for(let i of Object.values(e.revisions)){let r=JSON.stringify([i.sessionId,i.date,i.model??""]),s=o.get(r);if((!s||ln(i,s)>=0)&&o.set(r,i),Array.isArray(i.unloggedResidualModels))for(let c of i.unloggedResidualModels)n.add(JSON.stringify([i.sessionId,i.date,c]))}return t={changes:Object.values(e.changes).sort(ln),revisions:o,residualModels:n,fingerprint:un([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((i,r)=>i.at-r.at||(i.sequence??0)-(r.sequence??0))},ft.set(e,t),t}function pn(e,t=!1,o){let n=structuredClone(Object.fromEntries(_r.filter(r=>r!=="prices"&&e?.[r]!==void 0).map(r=>[r,e[r]]))),i=e?.prices??{};return n.prices={...i.currency?{currency:i.currency}:{},ollamaPeak:!t||i.ollamaPeak===!0,ollamaTaggedPeak:!t||i.ollamaTaggedPeak===!0,snapshotTags:!t||i.snapshotTags===!0,shortSnapshotTags:!t||i.shortSnapshotTags===!0,volcenginePeak:!t||i.volcenginePeak===!0,legacyModelMatching:t&&i.legacyModelMatching!==!1,default:Ue(i.default,o),models:cn(i.models,o),...i.custom?{custom:cn(i.custom,o)}:{},providers:Object.fromEntries(Object.entries(i.providers??{}).filter(([r])=>Se(r)).map(([r,s])=>[r,dn(s,o?.providers,()=>({...he(s),...s.currency?{currency:s.currency}:{},...s.default?{default:Ue(s.default,o)}:{},models:cn(s.models,o)}))]))},n}function zo(e,t=!1){let o=pn(e,t),n=un(o),i={};dt(i,n,o);let r={versions:i,changes:{initial:{at:0,version:n}},revisions:{},runs:{},fxChanges:{initial:{at:0,rates:Ge(e)}}};return De.add(r),r}function je(e,t,o,n=!1){if(De.has(e))return e;if(!pt(e?.versions)||!pt(e?.changes))return zo(t,n);let i={rates:new WeakMap,models:new WeakMap,providers:new WeakMap},r=Bo(e.versions,u=>pn(u,!0,i),o?.versions),s=Object.fromEntries(Object.entries(e.changes).filter(([u,p])=>Se(u)&&Number.isFinite(p?.at)&&p.at>=0&&r[p.version]));if(!Object.values(s).some(u=>u.at===0)){let u=Object.values(r),p={...t?.prices};for(let g of["ollamaPeak","ollamaTaggedPeak","snapshotTags","shortSnapshotTags","volcenginePeak"])u.length&&(p[g]=u.every(k=>k.prices?.[g]===!0));u.length&&(p.legacyModelMatching=u.every(g=>g.prices?.legacyModelMatching===!0));let m=zo({...t,prices:p},n);for(let[g,k]of Object.entries(m.versions))dt(r,g,k);s[an()]=m.changes.initial}let c=Object.fromEntries(Object.entries(e.revisions??{}).filter(([u,p])=>Se(u)&&typeof p?.sessionId=="string"&&(p.model===void 0||typeof p.model=="string"&&p.model.includes(":")&&p.model.length<=2048)&&(p.unloggedResidualModels===void 0||Array.isArray(p.unloggedResidualModels)&&p.unloggedResidualModels.every(m=>typeof m=="string"&&m.includes(":")&&m.length<=2048))&&/^\d{4}-\d{2}-\d{2}$/.test(p.date)&&Number.isFinite(p.at)&&r[p.version])),a=Object.fromEntries(Object.entries(pt(e.runs)?e.runs:{}).filter(([u,p])=>Se(u)&&Wo.every(m=>Number.isFinite(p?.[m])&&p[m]>=0)).map(([u,p])=>[u,{...Object.fromEntries([...Wo,...["beforeCny","afterCny","beforeEur","afterEur"].filter(m=>Number.isFinite(p[m])&&p[m]>=0)].map(m=>[m,p[m]])),...typeof p.model=="string"?{model:p.model}:{},...Array.isArray(p.skippedDetails)?{skippedDetails:p.skippedDetails.filter(Pr)}:{}}])),l=Object.fromEntries(Object.entries(e.fxChanges??{}).filter(([u,p])=>Se(u)&&Number.isFinite(p?.at)&&p.at>=0&&["CNY","EUR"].every(m=>Number.isFinite(p.rates?.[m])&&p.rates[m]>0)));if(!Object.keys(l).length)for(let[u,p]of Object.entries(s))l[u]={at:p.at,sequence:p.sequence??0,rates:Ge({...r[p.version],currency:t.currency})};let d={versions:r,changes:s,revisions:c,runs:a,fxChanges:l};return De.add(d),d}function ht(e,t,o=Date.now()){let n=pn(t),i=un(n),r=$o(e),s=r.changes.at(-1),c=Ge(t),a=r.fx.at(-1),l=JSON.stringify(a?.rates)!==JSON.stringify(c);l&&(e.fxChanges??={},e.fxChanges[an()]={at:Math.max(o,a?.at??0),sequence:(a?.sequence??0)+1,rates:c},ft.delete(e));let d=u=>{let{exchangeRate:p,...m}=u??{};return m};return s?.version===i||JSON.stringify(d(e.versions[s?.version]))===JSON.stringify(d(n))?l:(dt(e.versions,i,n,s?.version),e.changes[an()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},ft.delete(e),!0)}function qo(e,t){return e&&t&&Ko.set(e,t),e}function fn(e,t,o="",n=""){if(e?._repriceFxConfig){let v=fn(e._repriceFxConfig,t,o,n),b=q(v);return{...e,fxRates:b,exchangeRate:b[e.currency]??e.exchangeRate}}let i=Ko.get(e);if(!i||!Number.isFinite(t))return e;let r=$o(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 v=a+l>>>1;r.changes[v].at<=t?a=v+1:l=v}let d=r.changes[a-1],u=v=>v&&t<=v.at?v:null,p=u(r.revisions.get(JSON.stringify([o,c,""]))),m=n?u(r.revisions.get(JSON.stringify([o,c,n]))):null,g=p&&m?ln(p,m)>0?p:m:p??m,k=(g??d)?.version,O=k&&i.versions[k]?{...e,...i.versions[k]}:e,C=0,N=r.fx.length;for(;C<N;){let v=C+N>>>1;r.fx[v].at<=t?C=v+1:N=v}let A=r.fx[C-1]?.rates,P=g?.preserveFx?p?.fxRates??A??q(i.versions[d?.version]??e):g?g.fxRates??q(O):A??q(O);return{...O,fxRates:P,exchangeRate:P[O.currency]??O.exchangeRate}}function Yo(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:Lo(e.versions,t.versions),changes:{...e.changes,...t.changes},revisions:o,runs:{...t.runs,...e.runs},fxChanges:{...t.fxChanges,...e.fxChanges}};return De.add(n),n}function Go(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Ho(t)};return De.add(n),n}function Qo(e){return e&&{...e,format:2,versions:Fo(e.versions)}}var pe=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...$],fe=e=>!["__proto__","constructor","prototype"].includes(e),j=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ie=e=>e===void 0?void 0:structuredClone(e);function gn(e,t){if(j(e)){if(!j(t)){for(let o of $)delete e[o];return}for(let o of $)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))gn(n,t.byProviderModel?.[o]);if(Array.isArray(e.sessions)){let o=new Map((Array.isArray(t.sessions)?t.sessions:[]).filter(n=>j(n)&&typeof n.id=="string").map(n=>[n.id,n]));for(let n of e.sessions)j(n)&&o.has(n.id)&&gn(n,o.get(n.id))}}}function jr(e,t){if(!j(e)||!j(t))return e;for(let[o,n]of Object.entries(e))j(n)&&gn(n,t[o]);return e}function bn(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)=>bn(n,t[i]));if(!j(e)||!j(t))return!1;let o=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of o)if(!$.includes(n)&&!bn(e[n],t[n]))return!1;return!0}function yn(e,t,o){if(!j(e))return e;for(let n of $){let i=V(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??{}))yn(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(c=>j(c)&&typeof c.id=="string").map(c=>[c.id,c])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)j(s)&&typeof s.id=="string"&&yn(s,i.get(s.id),r.get(s.id))}return e}function Le(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Go(t)}:{}}}var Hr=new Int32Array(new SharedArrayBuffer(4)),ri=e=>typeof e=="string"&&/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}:[a-f\d]{64}$/i.test(e),be=e=>Object.fromEntries(Object.entries(j(e)?e:{}).filter(([t,o])=>ri(t)&&Number.isSafeInteger(o)&&o>=0)),Z=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 Fe(e,t,o=5e3,n=ii()){Vo(oi(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=Po(),c=new Map,a=Date.now()+o;for(;;)try{Vo(i);try{ti(He(i,r),s,{flag:"wx"})}catch(l){try{gt(He(i,r))}catch{}throw mt(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=Nr(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(No(He(i,d[0]),Number(u[1]),c)){gt(He(i,d[0])),mt(i);continue}}else if(d.length===0&&Date.now()-Tr(i).mtimeMs>3e4){mt(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{gt(He(i,r)),mt(i)}}function si(e){let t;try{t=ni(e,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!j(o)||o.version!==1)throw new Error("Unsupported ledger format");return o}function ci(e,t){let o=`${e}.${process.pid}-${ii()}.tmp`;try{let n=Zo(o,"wx",384);try{ti(n,JSON.stringify(t),"utf8"),Jo(n)}finally{Xo(n)}if(Rr(o,e),process.platform!=="win32"){let i=Zo(oi(e),"r");try{Jo(i)}finally{Xo(i)}}}finally{try{gt(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function kn(e){let t;try{t=ni(`${e}.config-bak`,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}let o=JSON.parse(t);if(!j(o)||o.version!==1||!j(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 An(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=kn(e)}catch(i){if(i.code)throw i}K(n,o)||ci(`${e}.config-bak`,o)}function bt(e,t,o=!1){if(o)try{Dr(e,`${e}.pricing-history-v1.bak`,Ur.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}An(e,t),ci(e,{...t,pricingHistory:Qo(t.pricingHistory)})}var hn=()=>Object.fromEntries(pe.map(e=>[e,0]));function ei(e,t){for(let o of pe)e[o]=(Number(e[o])||0)+(t[o]??0)}function Oe(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!ri(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;j(e.days[o])||(e.days[o]={date:o,...hn(),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,...hn(),byProviderModel:{}},a.sessions.push(d)),l.push(d)}for(let d of l){ei(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=hn();ei(u,s)}return c!==null&&(e.planHourBuckets=Xt(e.planHourBuckets,c,i,Kt(s),s.cost)),!0}function V(e,t,o,n=!1){if(K(t,e))return Ie(o);if(K(o,e)||K(t,o))return Ie(t);if(j(t)&&j(o)){let i={};for(let r of new Set([...Object.keys(e??{}),...Object.keys(t),...Object.keys(o)])){if(!fe(r))continue;let s=V(e?.[r],t[r],o[r],n&&(j(t[r])||pe.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)):Ie(t)}var mn=e=>Object.fromEntries((e?.sessions??[]).filter(t=>fe(t.id)).map(t=>[t.id,t]));function Lr(e,t,o){let n={};for(let i of new Set([...Object.keys(t),...Object.keys(o)])){if(!fe(i))continue;let r=e[i],s=t[i],c=o[i];if(bn(r,s)){c!==void 0&&(n[i]=yn(Ie(c),r,s));continue}if(!s||!c){s&&(n[i]=Ie(s));continue}if(K(s,c)){n[i]=Ie(c);continue}let a=V(r,s,c,!0),l=mn(r),d=mn(s),u=mn(c),p=V(l,d,u,!0),m=(g,k,O)=>Object.fromEntries(pe.map(C=>[C,(O?.[C]??0)+(k?.[C]??0)-(g?.[C]??0)]));Object.assign(a,m(r,s,c)),a.byProviderModel={};for(let g of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(c.byProviderModel??{})]))fe(g)&&(a.byProviderModel[g]=m(r?.byProviderModel?.[g],s.byProviderModel?.[g],c.byProviderModel?.[g]));for(let g of Object.keys(d))if(!(!u[g]||K(l[g],d[g])||K(l[g],u[g]))){for(let k of pe)a[k]-=(d[g][k]??0)-(l[g]?.[k]??0)-((p[g]?.[k]??0)-(u[g][k]??0));for(let[k,O]of Object.entries(d[g].byProviderModel??{}))if(!(!fe(k)||!a.byProviderModel[k]))for(let C of pe)a.byProviderModel[k][C]-=(O[C]??0)-(l[g]?.byProviderModel?.[k]?.[C]??0)-((p[g]?.byProviderModel?.[k]?.[C]??0)-(u[g].byProviderModel?.[k]?.[C]??0))}for(let g of[a,...Object.values(a.byProviderModel)])for(let k of pe)g[k]=Math.max(0,g[k]);a.sessions=Object.values(p).sort((g,k)=>(g.at??0)-(k.at??0)),n[i]=a}return n}function Fr(e,t,o,n){let i={};for(let r of new Set([...Object.keys(t),...Object.keys(o)]))if(fe(r)){i[r]={};for(let s of new Set([...Object.keys(t[r]??{}),...Object.keys(o[r]??{})])){if(!fe(s))continue;let c=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),a=V(c(e[r]?.[s]),c(t[r]?.[s]),c(o[r]?.[s]));i[r][s]=Object.values(a).filter(l=>l.t>=n-So).sort((l,d)=>l.t-d.t).slice(-Mo)}}return i}function Ce(e,t,o,n,i=Date.now(),r=[],s={}){let c=s.ownLocal===!0,a=o!==void 0&&o===e,l=Le(e),d=a?l:Le(o??e),u=c?t:Le(t);jr(l.days,d.days);let p=!K(u.historyReset,l.historyReset),m=!K(d.historyReset,l.historyReset),g=p?u.historyReset:d.historyReset;if(p||m)for(let P of[l,...p?[d]:[u]])P.days={},P.planSamples={},P.planHourBuckets={},P.balanceRef=null;for(let P of n)m&&!p&&P.recordedAt<=(g?.at??0)||(Oe(l,P),d!==l&&Oe(d,P),m&&!p&&Oe(u,P));let k={version:1,writeReceipts:Z([...d.writeReceipts??[],...u.writeReceipts??[]]),config:V(l.config,u.config,d.config),days:Lr(l.days,u.days,d.days),balanceRef:K(l.balanceRef,u.balanceRef)?d.balanceRef:K(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:Fr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:xo(V(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:V(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:Yo(u.pricingHistory,d.pricingHistory),historyReset:g??null},O=be(u.usageCursors);for(let[P,v]of Object.entries(be(d.usageCursors)))O[P]=Math.max(O[P]??0,v);Object.keys(O).length&&(k.usageCursors=O);let C=V(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);C&&Object.keys(C).length&&(k.providerPriceHashes=C);let N=Object.keys(k.days).sort(),A=Math.max(7,Math.min(3650,Number(k.config.historyDays)||180));for(;N.length>A;)delete k.days[N.shift()];return ge(k.days).includes(k.balanceRef?.date)&&(k.balanceRef=null),Br(k,r),k}function Br(e,t){let o=(n,i)=>pe.filter(r=>r!=="apiCost").every(r=>Math.abs((Number(n?.[r])||0)-(Number(i?.[r])||0))<1e-9);for(let n of t){if(Co(e.config)!==n.fingerprint||!K(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(!fe(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]??{};K(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 ai(e,t,o){return V(e,t,o)}import{join as di}from"node:path";var pi=1,gi=180;function Kr(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 Be(e){try{let t=zr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var wn=["antigravity","claude","codex","kimi","xai","workbuddy"],$r=["sidebar","settings","both","off"],qr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Yr(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function fi(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function Gr(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(":")&&fi(c.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!fi(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 Qr(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=>Yr(c)).filter(c=>wn.includes(c)))]:wn.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(c=>Gr(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:$r.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:wn.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function Vr(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 On(){return{queryAccounts:{},peakTimeZone:"auto",locale:"auto",position:"dock",sidebar:!0,currency:"CNY",symbol:"\xA5",decimals:4,exchangeRateAuto:!0,fxRates:Ye(),exchangeRateCheckedAt:0,exchangeRateDate:"",exchangeRate:7.2,pricingCurrency:"USD",peakEnabled:!0,peakEffectiveAt:Gn,peakWindows:Qn.map(e=>({...e})),peakHolidays:[...ot],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:{},localSavings:Wt(),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(Ut.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(Ut.default),providers:Object.fromEntries(Object.entries(ne).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:{source:"auto",display:"both",refreshMinutes:5,showProgressBar:!1,showSource:!1,officialChannelOnly:!1,quickHide:!1,budgetCap:null,currency:"native",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,planAmounts:!0,promptSeen:!1},barDirections:{balance:"remaining",budget:"used",go:"used",plan:"used"},usage:{position:"cost"},planBilling:{providers:{...Vt},models:{},modelPlans:{}},historyDays:gi,fetchedAt:null,priceSource:"bundled"}}var iu=Object.keys(On());function Mn(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function Sn(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function Zr(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 Jr(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function yt(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=Jr(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 hi(e){for(let t of Object.values(e))if(yt(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))yt(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>yt(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))yt(i)===null&&delete o.byProviderModel[n]}}return e}function We(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)?We(r,i):i}return o}function Xr(e){return e==="native"||e==="display"||qe(e)}function xe(e){let t=On(),o=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{};o.prices?.currency==="CNY"&&(t.prices={...t.prices,...structuredClone(no),currency:"CNY"});let n=We(t,o);n.queryAccounts=Rn(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(([f,h])=>f.includes(":")&&f.length<=512&&Ne(h)!==null).map(([f,h])=>[f,Ne(h)])));for(let[f,h]of Object.entries(o.prices?.providers??{}))!h?.models||typeof h.models!="object"||Array.isArray(h.models)||Object.hasOwn(n.prices?.providers??{},f)&&(n.prices.providers[f].models=We({},h.models));let i=o.prices?.models;i&&typeof i=="object"&&!Array.isArray(i)&&(n.prices.models=We({},i));let r=o.prices?.default;if(r&&typeof r=="object"&&!Array.isArray(r)){let{cacheHit:f,cacheMiss:h,output:y}=t.prices.default;n.prices.default=We({cacheHit:f,cacheMiss:h,output:y},r)}let s=f=>{if(f&&typeof f=="object"&&!Ke(f))for(let h of Mt)delete f[h]};for(let f of Object.values(n.prices?.providers??{})){s(f);for(let h of Object.values(f?.models??{}))s(h)}for(let f of[...Object.values(n.prices?.models??{}),n.prices?.default])s(f);let c=f=>typeof f=="number"&&Number.isFinite(f),a=(f,h,y)=>typeof f=="string"&&h.includes(f)?f:y;for(let[f,h]of Object.entries(t)){let y=n[f],T=typeof h;T==="boolean"&&typeof y!="boolean"||T==="number"&&!c(y)||T==="string"&&typeof y!="string"?n[f]=h:T==="object"&&h!==null&&y!==null&&typeof y=="object"&&f==="gatewayQuotas"&&Array.isArray(y)||T==="object"&&h!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(h))&&(n[f]=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=Un(n.modelStatistics),n.localSavings=Wt(n.localSavings);for(let f of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","followSkinTransparency","sidebarTodayBalanceInline","sidebarTextOnly"])n[f]=n[f]===!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(f=>typeof f=="string"&&/^(balance|customBalance|today|peak|models|localSavings|go|budget|codex|(plan|gateway):[A-Za-z0-9_-]{1,100})$/.test(f)))].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(f=>typeof f=="string"&&f.length<=160))].slice(-32),n.sidebarModels=Object.fromEntries(Object.entries(t.sidebarModels).map(([f,h])=>{let y=n.sidebarModels?.[f],T={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[f];return[f,T?T.includes(y)?y:h:typeof h=="boolean"?typeof y=="boolean"?y:h:typeof y=="number"&&Number.isFinite(y)?Math.min(f==="topN"?10:60,Math.max(f==="topN"?1:10,Math.floor(y))):h]})),n.sidebarStyle=a(n.sidebarStyle,["standard","compact","summary","icons"],"standard"),n.planQuotaStyle=a(n.planQuotaStyle,["bars","gauge"],"bars"),n.priceMatchDismissed=Array.isArray(n.priceMatchDismissed)?[...new Set(n.priceMatchDismissed.filter(f=>typeof f=="string"&&f.length>0&&f.length<=512))].slice(0,1e3):[],delete n.hideAmounts,n.peakTimeZone=En(n.peakTimeZone)?n.peakTimeZone:"auto",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=q(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(f=>f!==null&&typeof f=="object"&&c(Number(f.start))&&c(Number(f.end))):n.peakWindows=t.peakWindows,Array.isArray(n.peakHolidays)?n.peakHolidays=[...new Set(n.peakHolidays.filter(f=>typeof f=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(f)&&!Number.isNaN(Date.parse(f+"T00:00:00Z"))&&new Date(f+"T00:00:00Z").toISOString().slice(0,10)===f))].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[f,h]of Object.entries(n.priceOverrides))typeof f=="string"&&typeof h=="string"&&(d[f]=h);n.priceOverrides=d;let u={};if(n.priceTableDisplay!==null&&typeof n.priceTableDisplay=="object"&&!Array.isArray(n.priceTableDisplay))for(let[f,h]of Object.entries(n.priceTableDisplay))typeof f=="string"&&(u[f]=typeof h=="boolean"?h:t.priceTableDisplay[f]===!0);n.priceTableDisplay={...t.priceTableDisplay,...u};let p=n.budget;p.enabled=p.enabled===!0,p.amount=c(p.amount)&&p.amount>=0?p.amount:100,p.period=a(p.period,["day","month","all","custom"],"month"),p.customStart=typeof p.customStart=="string"?p.customStart:null,p.customEnd=typeof p.customEnd=="string"?p.customEnd:null,p.detail=p.detail!==!1;let m=n.balance;m.display=a(m.display,["sidebar","settings","both","off"],"both"),m.source=a(m.source,["auto","account"],"auto"),m.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(m.refreshMinutes)||5))),m.showProgressBar===void 0&&(m.showProgressBar=n.customBalance?.showProgressBar!==void 0?n.customBalance.showProgressBar===!0:t.balance.showProgressBar===!0),m.showProgressBar=m.showProgressBar===!0,m.showSource=m.showSource===!0,m.officialChannelOnly=m.officialChannelOnly===!0,m.quickHide=m.quickHide===!0,m.clickHintSeen=m.clickHintSeen===!0,m.reconcile=m.reconcile!==!1,Xr(m.currency)||(m.currency="native");let g=Number(m.budgetCap);m.budgetCap=Number.isFinite(g)&&g>0?g:null;let k=n.goQuota;k.enabled=k.enabled===!0,typeof k.showInComposer!="boolean"&&delete k.showInComposer,k.display=a(k.display,["sidebar","settings","both","off"],"both"),k.refreshMinutes=Math.min(1440,Math.max(1,Math.floor(Number(k.refreshMinutes)||15))),k.apiKey=typeof k.apiKey=="string"?k.apiKey:"",k.main=a(k.main,["rolling","weekly","monthly"],"rolling"),k.detail=k.detail!==!1;let O=n.customBalance??t.customBalance,C=(f,h)=>{let y=f??{},T={...["aliyun","tokenrhythm"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:a(y.display,["sidebar","settings","both","off"],"both"),refreshMinutes:Math.min(1440,Math.max(1,Math.floor(Number(y.refreshMinutes)||15))),label:typeof y.label=="string"?y.label:h.label,labelEn:typeof y.labelEn=="string"?y.labelEn:h.labelEn,dashboardUrl:Kr(y.dashboardUrl),unit:y.adapter==="tokenrhythm"?"CNY":a(y.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))T.request={...h.request};else{let F={};for(let[D,H]of Object.entries(y.request.headers??{}))typeof D=="string"&&typeof H=="string"&&(F[D]=H);T.request={...h.request,...y.request,url:typeof y.request.url=="string"?y.request.url:"",method:typeof y.request.method=="string"?y.request.method:"GET",headers:{...h.request?.headers??{},...F}}}if(y.extract===null||typeof y.extract!="object"||Array.isArray(y.extract)?T.extract={...h.extract}:T.extract={...h.extract,...y.extract},Array.isArray(y.allowedHosts)){let F=y.allowedHosts.filter(D=>typeof D=="string"&&D.length>0);F.length>0&&(T.allowedHosts=F)}return T},N=C(O,t.customBalance);n.customBalance=N;let A=n.gatewayQuotas,P=Array.isArray(A)?A:A!==null&&typeof A=="object"&&Array.isArray(A.sources)?A.sources:[],v=[],b=new Set;for(let f of P.slice(0,4)){let h=Qr(f);!qr.test(h.id)||b.has(h.id)||h.type!=="cliproxyapi"||!Vr(h.baseURL)||(b.add(h.id),v.push(h))}n.gatewayQuotas={sources:v};let w=n.customBalances;Array.isArray(w)||(w=[]);let S=t.customBalances?.[0]??t.customBalance,E=w.slice(0,8).map(f=>C(f,S)),_=N.enabled===!0||typeof N.request?.url=="string"&&N.request.url.length>0;E.length===0&&_&&E.push(N),n.customBalances=E;let R=n.corner;for(let f of["enabled","goRolling","goWeekly","goMonthly","budget"])R[f]=R[f]===!0||R[f]!==!1&&f!=="enabled";let I=n.quotaStrip;I.enabled=I.enabled===!0,I.promptSeen=I.promptSeen===!0;for(let f of["budget","go","plans","planAmounts"])I[f]=I[f]!==!1;let M=n.barDirections!==null&&typeof n.barDirections=="object"&&!Array.isArray(n.barDirections)?n.barDirections:{};n.barDirections={balance:M.balance==="used"?"used":"remaining",budget:M.budget==="remaining"?"remaining":"used",go:M.go==="remaining"?"remaining":"used",plan:M.plan==="remaining"?"remaining":"used"};let x={};if(n.codingPlans!==null&&typeof n.codingPlans=="object"){for(let[f,h]of Object.entries(n.codingPlans))if(!(!Re.includes(f)||h===null||typeof h!="object"||Array.isArray(h))){if(x[f]={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:""},f==="minimax"){let y=Ao(h.baseUrl);x[f].baseUrl=y??"",y===null&&(x[f].enabled=!1)}if(f==="workbuddy"&&(h.accountSource!==void 0&&(x[f].accountSource=a(h.accountSource,["auto","connect","xdpool"],"auto")),x[f].accountScope=a(h.accountScope,["current","all","selected"],"current"),x[f].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(Yt))].slice(0,400):[]),f==="opendesign"){let y=Kn(h.workspaceId);x[f].workspaceId=y??"",y===null&&(x[f].enabled=!1)}if(f==="factory"){let y=mo(h.orgId);x[f].orgId=y??"",y===null&&(x[f].enabled=!1),x[f].factoryPool=a(h.factoryPool,["standard","core","both"],"standard")}if(f==="scnet"){let y=Number(h.planCredits);x[f].planCredits=Number.isFinite(y)&&y>0?y:24e4,x[f].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:""}if(f==="qwen"){x[f].quotaSource=h.quotaSource==="cli"||h.quotaSource==="bailian"?h.quotaSource:"local";let y=Number(h.planCredits);x[f].planCredits=Number.isFinite(y)&&y>0?y:5e5,x[f].planStart=typeof h.planStart=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(h.planStart)?h.planStart:"";let T=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},F={};for(let[D,H]of Object.entries(T)){if(typeof D!="string"||D.length===0||H===null||typeof H!="object")continue;let Y=Ee=>{let X=Number(Ee);return Number.isFinite(X)&&X>0?X:null},z=Y(H.input),se=Y(H.cachedInput),ce=Y(H.output);z===null||se===null||ce===null||(F[D]={input:z,cachedInput:se,output:ce})}x[f].rates=F}if(f==="volcengine"){let y=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",T=typeof h.apiKey=="string"?h.apiKey.trim():"";x[f].accessKeyId=y.length>0?y:T,x[f].secretAccessKey=typeof h.secretAccessKey=="string"?h.secretAccessKey:"",x[f].accessKeyId.length>0&&x[f].apiKey!==x[f].accessKeyId&&(x[f].apiKey=x[f].accessKeyId)}}}n.codingPlans=x;let U={};for(let f of ie){let h=n.planBilling?.providers?.[f];U[f]=["auto","plan","api"].includes(h)?h:Vt[f]??"auto"}if(n.planBilling?.providers&&typeof n.planBilling.providers=="object"&&!Array.isArray(n.planBilling.providers))for(let[f,h]of Object.entries(n.planBilling.providers))f.trim()&&!["__proto__","constructor","prototype"].includes(f)&&["auto","plan","api"].includes(h)&&(U[f]=h);let re={};if(n.planBilling?.models!==null&&typeof n.planBilling?.models=="object"&&!Array.isArray(n.planBilling?.models))for(let[f,h]of Object.entries(n.planBilling.models))typeof f=="string"&&f.length>0&&(h==="plan"||h==="api")&&(re[f]=h);let J=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([f,h])=>f.includes(":")&&ie.includes(h))),L=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(f=>ie.includes(f)):[...rt(n)])];return n.planBilling={providers:U,models:re,modelPlans:J,autoProviders:L},n}var es={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"},ru=Object.keys(es);function mi(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))vt(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function In(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=mi(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(mi)),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 kt=[{id:"provider-catalog-2026-10-03",apply:Me},{id:"provider-catalog-2026-10-15",apply:Zn},{id:"provider-catalog-2026-10-28",apply:Jn},{id:"provider-catalog-2026-11-05",apply:Xn},{id:"stepfun-catalog-2026-10-16",apply:eo},{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")}}],At=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=je(r.pricingHistory,t),this.config=t,Nn(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??po,this.writeReceipts=Z(r.writeReceipts),this.diskRevision=null,this.balanceRef=r.balanceRef??null,this.historyReset=r.historyReset??null,this.usageCursors=be(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&&ht(this.pricingHistory,t),this._config=qo(t,this.pricingHistory)}static open(){let t=di(qt(),"storages","cost-meter"),o=di(t,"ledger.json");return Fe(o,()=>e.load(o))}static load(t){let o=On(),n={},i=null,r=[...kt.map(A=>A.id),"quota-token-window-v2"],s={},c={},a={},l={},d=null,u={},p=[],m,g=!1,k=!1,O=!1;try{let A=JSON.parse(Wr(t,"utf8"));if(A===null||typeof A!="object"||Array.isArray(A))throw new Error("Unsupported ledger format");if(A!==null&&typeof A=="object")if(A.version!==pi){try{li(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u7248\u672C ${String(A.version)} \u4E0D\u53D7\u652F\u6301,\u6309\u7A7A\u8D26\u672C\u542F\u52A8`)}else{d=A.historyReset??null,u=be(A.usageCursors),p=Z(A.writeReceipts);let P=typeof A.config=="object"&&A.config!==null?A.config:{};m=je(A.pricingHistory,xe(P),void 0,!0),g=!!A.pricingHistory&&A.pricingHistory.format!==2,r=Array.isArray(A.migrations)?A.migrations.filter(w=>typeof w=="string"):[];let v=new Set(r);for(let w of kt)v.has(w.id)||(w.apply(P),r.push(w.id));o=xe(P),A.openrouterPriceHashes&&typeof A.openrouterPriceHashes=="object"&&!Array.isArray(A.openrouterPriceHashes)&&(a=A.openrouterPriceHashes),A.providerPriceHashes&&typeof A.providerPriceHashes=="object"&&!Array.isArray(A.providerPriceHashes)&&(l=A.providerPriceHashes),A.days!==null&&typeof A.days=="object"&&!Array.isArray(A.days)&&(n=hi(A.days));let b=A.balanceRef;b!==null&&typeof b=="object"&&typeof b.date=="string"&&Number.isFinite(b.total)&&Number.isFinite(b.granted)&&Number.isFinite(b.topped)&&(i={date:b.date,total:b.total,granted:b.granted,topped:b.topped,currency:typeof b.currency=="string"?b.currency:void 0,at:Number(b.at)||0,ledgerCost:Number.isFinite(b.ledgerCost)&&b.ledgerCost>=0?b.ledgerCost:void 0}),A.planSamples!==null&&typeof A.planSamples=="object"&&!Array.isArray(A.planSamples)&&(s=A.planSamples),A.planHourBuckets!==null&&typeof A.planHourBuckets=="object"&&!Array.isArray(A.planHourBuckets)?c=A.planHourBuckets:Array.isArray(A.planRecentCalls)&&(c=en(A.planRecentCalls)),k=!0}}catch(A){if(A?.code!=="ENOENT"){try{li(t,`${t}.corrupt-${Date.now()}`)}catch{}console.warn(`[dsh-cost-meter] \u8D26\u672C\u8BFB\u53D6\u5931\u8D25,\u6309\u7A7A\u8D26\u672C\u542F\u52A8: ${String(A?.message??A)}`)}}if(k)try{An(t,{config:In(o),migrations:r})}catch(A){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u5199\u5165\u5931\u8D25\uFF08${A?.code??"write error"}\uFF09`)}else try{let A=kn(t);if(A){let P=A.config;r=A.migrations;for(let v of kt)r.includes(v.id)||(v.apply(P),r.push(v.id));o=xe(P),O=!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(A){console.warn(`[dsh-cost-meter] \u914D\u7F6E\u5907\u4EFD\u4E0D\u53EF\u7528\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u914D\u7F6E\uFF08${A?.code??"invalid format"}\uFF09`)}let C=new e(o,n,t,r,{planSamples:s,planHourBuckets:c,openrouterPriceHashes:a,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:p,pricingHistory:m});C.legacyPricingHistory=g,C.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),C.quotaStatsNeedRepair&&(C.planSamples={}),(g||O)&&C.scheduleWrite();let N=ge(C.days);return N.length&&(N.includes(C.balanceRef?.date)&&(C.balanceRef=null),C.scheduleWrite()),C}account(t,o,n,i,r,s,c){if(this.closed)return;if(c!==void 0&&(!lo(c,i)||r!=="deepseek-official"||!ao(o,c)))throw new Error("Invalid official web request fee");let a=fn(this.config,i,n,`${r||"deepseek"}:${o}`),l=io(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},p=c?c.requests*c.rateCny:l.priced?Lt(t,d,i,u):0,m=Ft(p,c?"CNY":l.currency,q(a).CNY),g=this.config.planBilling,k=rt(this.config),O=c?"api":Oo(r,o,g,k,this.config.prices),C=O==="api"?m:0,N=b=>{let w=Number(b);return Number.isFinite(w)&&w>0?w:0},A={input:N(t?.input),output:N(t?.output),cacheRead:N(t?.cacheRead),cacheWrite:N(t?.cacheWrite),reasoning:N(t?.reasoning)},P=O==="plan"?Zt(r,g,o)??(Jt(r,o,this.config.prices)?"go":null):null,v={...s?{meter:s}:{},date:Mn(i),sessionId:n,atMs:i,recordedAt:Date.now(),planId:P,providerKey:`${typeof r=="string"&&r.length>0?r:"deepseek"}:${String(o??"default")}`,values:{...A,calls:1,cost:m,apiCost:C,...It(m,C,a)}};return Oe(this,v)?(this.pendingAccounts.push(v),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};Oe(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||gi)),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 Le({version:pi,config:In(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:ui(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Be(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=si(this.path);if(o===null)return null;this.legacyPricingHistory=!!o.pricingHistory&&o.pricingHistory.format!==2;let n=je(o.pricingHistory,xe(o.config),this.pricingHistory,!0);for(let i of kt)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:In(xe(o.config)),days:hi(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??en(o.planRecentCalls??[]),openrouterPriceHashes:o.openrouterPriceHashes??{},historyReset:o.historyReset??null,usageCursors:be(o.usageCursors),writeReceipts:Z(o.writeReceipts),providerPriceHashes:o.providerPriceHashes??{},pricingHistory:n}}adoptSnapshot(t){this.pricingHistory=je(t.pricingHistory,t.config),this.config=xe(ai(this.writeBase.config,this.config,t.config));for(let o of["days","balanceRef","migrations","planSamples","planHourBuckets","openrouterPriceHashes","historyReset"])this[o]=t[o];this.usageCursors=be(t.usageCursors),this.writeReceipts=Z(t.writeReceipts),this.providerPriceHashes=t.providerPriceHashes??{}}refresh(){if(!this.closed){if(this.pendingWrite){Be(this.path)!==this.diskRevision?this.flush():this.writeTimer===null&&!this.backgroundWrite&&this.scheduleWrite();return}try{let t=Be(this.path);if(t===this.diskRevision)return;let o=this.readDiskSnapshot();if(o===null)return;this.adoptSnapshot(Ce(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{Fe(this.path,()=>{ht(this.pricingHistory,this.config);let o=this.readDiskSnapshot(),n=this.snapshot(),i=ge(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:Ce(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});bt(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=Be(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();ht(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,c=ui();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(Z(u?.writeReceipts).includes(c))a={merged:u,revision:Be(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=Z(a.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=Ce(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=Sn(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,_e(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]={..._e({...Qe(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=Sn(`${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,_e(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]={..._e({...Qe(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=Mn(Date.now()),o=this.days[t];return o===void 0?Sn(t):this.copyDay(o)}todayOfficialCost(){return Zr(this.days[Mn(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{...Qe(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 bi=e=>{try{let t=ns(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:ze,base:yi,local:ye,pending:os,repairs:ki,revision:is,backupHistory:rs,transactionId:ss,now:cs,port:Cn,signal:Ai,lockId:as}=ts;try{let e=Fe(ze,()=>{let t=bi(ze)===is,o=ge(ye.days);o.includes(ye.balanceRef?.date)&&(ye.balanceRef=null);let n=t&&!ki.length&&!o.length,i=ye;if(!n){let r=new At(ye.config,{},ze,[],{pricingHistory:ye.pricingHistory});r.writeBase=yi,i=Ce(yi,ye,r.readDiskSnapshot(),os,cs,ki,{ownLocal:!0})}return i.writeReceipts=Z([...i.writeReceipts??[],ss]),bt(ze,i,rs),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:bi(ze)}},5e3,as);Cn.postMessage(e)}catch(e){Cn.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Ai,0,1),Atomics.notify(Ai,0),Cn.close()}