dsh-cost-meter 1.9.76 → 1.9.77

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 as}from"node:worker_threads";import{statSync as cs}from"node:fs";function _n(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 St=["peakWindows","peakHolidays","peakSchedule"];function he(e){return Object.fromEntries(St.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function $e(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 Ke(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 vn(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??[]),a=new Date(t+8*36e5),c=new Date(t),l=["ollama","utc-weekdays"].includes(i)?c.getUTCDay():a.getUTCDay();if(i!=="daily"&&(l===0||l===6)||s.includes(a.toISOString().slice(0,10)))return"offPeak";let d=c.getUTCHours()+c.getUTCMinutes()/60+c.getUTCSeconds()/3600+c.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 It=[["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]],Pn=It.map(([e])=>e),Ii=new Map(It.map(e=>[e[0],e]));function qe(e){return typeof e=="string"&&Ii.has(e)}function Ye(){let e={USD:1};for(let[t,,o]of It)t!=="USD"&&(e[t]=o);return e}var K=["costCny","apiCostCny","costEur","apiCostEur"],Ci=["USD","CNY","EUR"],Nn=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 Pn)n!=="USD"&&Nn(o[n])&&(t[n]=o[n]);return e?.currency!=="USD"&&qe(e?.currency)&&Nn(e?.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ge(e){let t=q(e);return Object.fromEntries(Ci.map(o=>[o,t[o]]))}function Ct(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(K.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function _e(e,t,o=1){for(let n of K)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Rn(e,t){let o=n=>{let i=Ct(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of K)(!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 Oi=["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),xi=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",Ei=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function Tn(e){let t={};if(!Ot(e))return t;for(let o of Oi){let n=e[o];if(!Ot(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!Ot(s)||!xi(s.id)||!Ei(s.label)||i.has(s.id)?!1:(i.add(s.id),!0)).slice(0,10).map(({id:s,label:a})=>({id:s,label:a.trim()}));t[o]={selected:r.some(s=>s.id===n.selected)?n.selected:"default",accounts:r}}return t}var Dn=["today","summary","budget"],Un=e=>e&&typeof e=="object"&&!Array.isArray(e);function jn(e){return Un(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Un(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Dn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Dn.some(o=>!t[o]))):{}}var xt=/^(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 Hn(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]*Hn(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 Et(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])=>!xt.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]*Hn(e,n+"."+r)))return!1}}return!0}var Ln={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 _t={"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."}}}};_t.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 vt={"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 _i="https://platform.stepfun.ai/docs/en/guides/pricing/details",ve=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:_i,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."}),Fn={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(vt)])].map(e=>[e,{models:{...Xe[e]?.models,...vt[e]?.models}}]));ee.stepfun=Fn;var Bn=structuredClone(ee);for(let[e,t]of Object.entries(_t))ee[e]={models:{...ee[e]?.models,...t.models}};var Wn=structuredClone(ee);for(let[e,t]of Object.entries(Ln))ee[e]={models:{...ee[e]?.models,...t.models}};var zn={"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 $n=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,vi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,Pi=/^(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 Pt(e,t){if(typeof t!="string"||t.length===0)return!1;if($n.test(t)){let n=t.replace(new RegExp($n.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(vi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||Pi.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",Us=et+"/public/model-prices",ke=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],js=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var Ni=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"&&Ni(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 qn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Yn({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 T=Array.isArray(w)?w.filter(x=>typeof x=="string"&&x.length>0):[],I=T.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=T.filter(J=>i(J)===x);if(U.length>0)return U.length===1?U[0]:null;let se=r(M,E,_);if(se===M.toLowerCase())return null;M=se}}let a=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),c={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 T=b.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),I=T.search(/[/:]/);if(I>0){let M=T.slice(0,I).trim().toLowerCase(),x=T.slice(I+1).trim();if(Object.hasOwn(c,M)&&(M===S||(S==="opencode-zen"||S==="opencode-go")&&(c[M].test(x)||s(x,Object.keys(M==="deepseek"?_?.models??{}:_?.providers?.[M]?.models??{}),x,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)!==null)))T=x;else if(Object.hasOwn(c,M))return null}return s(T,Object.keys(w),b,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)}function u(b,w,S,E){let _=E?.mode==="exact"?"exact":"auto",T=E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{},I=w,M=b,x=(b===""?"deepseek":b)+":"+w,U=T[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},R=e(y);return R===null?{entry:null,billingMode:"flat",priced:!1}:{entry:R,billingMode:"deepseek-peak",priced:R.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"),O(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[ae,ce]of Object.entries(S?.providers??{})){if(a.has(ae))continue;let Ee=ce?.models??{},X=d(I,Ee,ae,_,S);if(X===null)continue;let En=e(Ee[X]);if(En===null)continue;let Mt=+(X===I||i(X)===i(I));Mt>H?(D=En,H=Mt,Y=!1,z=l(Ee[X])):Mt===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 R=o(I,S),F=e(R);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&&a.has(M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&Object.hasOwn(c,M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&_==="auto"){let h=null,y=-1,R=!1,F="flat";for(let[D,H]of[["deepseek",{models:S?.models??{}}],...Object.entries(S?.providers??{})]){if(D===M||a.has(D))continue;let Y=H?.models??{},z=d(I,Y,D,_,S);if(z===null)continue;let ae=e(Y[z]);if(ae===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=ae,y=ce,R=!1,F=D==="deepseek"?"deepseek-peak":l(Y[z])):ce===y&&(R=!0)}if(R)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 T=E[_],I=e(T);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"]),C=["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 O(b,w){if(typeof b=="string"&&k.has(b))return!0;let S=typeof w=="string"?n(w):"";return C.some(E=>S.startsWith(E))}function N(b,w,S,E,_){let T=_?.[(b||"deepseek")+":"+w];if(!b||E==="exact"||typeof w!="string"||O(b,w)||["our-free-model","our-free-model-region"].includes(b)||typeof T=="string"&&T.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"},se=/^(?:dsh-)?magpie(?:$|-)/.test(b),J=Object.hasOwn(U,M)||a.has(M)||["workbuddy","workbuddy-ai","qoder","qoder-cn","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cline","copilot","vercel"].includes(M);if(!se&&(!J||Object.hasOwn(c,b)||a.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)||a.has(L)||Object.hasOwn(c,L)||Object.hasOwn(S?.providers??{},L)||O(L,x)?L:b,model:x}}function A(b,w,S,E){let _=typeof b=="string"?b.trim().toLowerCase():"",T=_.startsWith("llm-")?_.slice(4):_,I=N(T,w,S,E?.mode,E?.overrides);if(I&&(T=I.provider,w=I.model,E={...E,overrides:{}}),["our-free-model","our-free-model-region"].includes(T)&&E?.overrides?.[T+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let M=Ke(P(T,w,S,E),T,S);return["volcengine","ark"].includes(T)&&S?.volcenginePeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"volcengine"}}:T==="ollama-cloud"&&S?.ollamaPeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"&&(S?.ollamaTaggedPeak===!1?qn.has(typeof w=="string"?w.trim().toLowerCase():""):s(w,[...qn])!==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 Ri=Yn({normalizePrice:W,normalizeCustomPrice:Ne});var Qn="2026-08-01T00:00:00Z",Dt="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"],Nt="2026-09-10T04:00:00Z",Ti="2026-08-31T00:00:00Z",Gn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Di(e){if(!Number.isFinite(e)||e<Date.parse(Dt))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(Dt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ui(e,t=ot){if(!Number.isFinite(e)||e<Date.parse(Dt)||!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 ji=(e,t)=>Ui(e,t)??Di(e),Hi="2026-08-16T16:00:00Z";var Vn=[{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"}}}},Zn=Object.freeze(Object.keys(me["opencode-go"].models)),oe={...me};oe.opendesign={models:zn};for(let[e,t]of Object.entries(ee)){let o=me[e]?.models??{};oe[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(oe)){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[a,c]of Object.entries(i.models)){if(!Object.hasOwn(s,a)){Object.hasOwn(r,a)||(s[a]=structuredClone(c));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[a]&&Object.keys(s[a]).some(p=>!l.has(p)))continue;let d=W(r[a]),u=W(s[a]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[a]=structuredClone(c))}}}function Jn(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Xe[o]?.models}}]));Me(e,t)}function Xn(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Bn[o]?.models}}]));Me(e,t)}function eo(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Wn[o]?.models}}]));Me(e,t)}function to(e){Me(e,Object.fromEntries(Object.entries(oe).filter(([t])=>t!=="stepfun")))}var Li={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}}},Fi={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 Rt(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 no(e){let t=e==="CNY"?Fi:Li,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):Rt(i,e,Nt)]));return o["deepseek-v4.1-flash"]=Rt(t.models["deepseek-v4-flash-vision-exp"],e,Nt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:Rt(t.default,e,Nt)}}var jt=no("USD"),oo=no("CNY");function Ht(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 a=Date.parse(s.before);t<a&&a<n&&(o=s,n=a)}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=a=>{let c=e[a];return typeof c=="number"&&Number.isFinite(c)&&c>=0?c:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),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 a of["billingMode","sourceUrl","checkedAt","notes"])typeof e[a]=="string"&&(s[a]=e[a]);return s}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e)||!$e(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(a=>o(s[a]))||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 a of e.rateHistory){if(!a||typeof a.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(a.before)||!Number.isFinite(Date.parse(a.before))||s.has(Date.parse(a.before))||!["cacheHit","cacheMiss","output"].every(l=>typeof a[l]=="number"&&Number.isFinite(a[l])&&a[l]>=0))return null;s.add(Date.parse(a.before));let c={before:a.before,...le(a)};for(let l of["offPeak","peak"])if(a[l]!==void 0){if(!a[l]||!["cacheHit","cacheMiss","output"].every(d=>typeof a[l][d]=="number"&&Number.isFinite(a[l][d])&&a[l][d]>=0))return null;c[l]=le(a[l])}t.rateHistory.push(c)}t.rateHistory.sort((a,c)=>Date.parse(a.before)-Date.parse(c.before))}return Object.assign(t,Ve(e)),Et(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 Bi(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)),a=Number(r.slice(-4,-2)),c=Number(r.slice(-2)),l=new Date(Date.UTC(s,a-1,c));return s>=2e3&&l.getUTCFullYear()===s&&l.getUTCMonth()===a-1&&l.getUTCDate()===c?n.slice(0,i.index):n}return n.replace(/[-_./:@]latest$/,"")}function io(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 a=e.normalize("NFKC").trim(),c=2;for(;;){let l=de(a);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:c};if(/[:((]\s*(?:free|online)\b/i.test(a))return null;let u=Bi(a,n,i);if(u===a.toLowerCase())return null;a=u,c=1}}function Lt(e,t,o=e,n=!0,i=!0){return io(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 Tt(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 a=r.slice(0,s).trim().toLowerCase(),c=a==="deepseek-ai"?"deepseek":a,l=r.slice(s+1).trim();if(Object.hasOwn(ue,c)&&(c===o||["opencode-zen","opencode-go","zen","opencode","opencode-go-plus"].includes(o)&&(ue[c].test(l)||Lt(l,Object.keys(c==="deepseek"?i?.models??{}:i?.providers?.[c]?.models??{}),l,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=l;else if(Object.hasOwn(ue,c))return null}return io(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Wi(e,t,o,n,i){return Ae(e,t,o,n,i)?.id??null}function Ut(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},s=t,a=e,c=(e===""?"deepseek":e)+":"+t,l=r[c];if(l==="__custom__"){let u=Ne(o?.custom?.[c]);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?(a=l.slice(0,u).trim().toLowerCase(),s=l.slice(u+1)):s=l,a==="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(a,s)&&a!=="openrouter"){let u=o?.providers?.[a]?.models??{},p=Ae(s,u,a,i,o);if(p){let m=p.id===null?null:u[p.id],g=W(m);return{entry:g,billingMode:Tt(m),priced:g!==null&&g.unpriced!==!0}}}if(/(?:^|[-_])free(?:$|[-_])/.test(a)&&!["our-free-model","our-free-model-region"].includes(a))return{entry:null,billingMode:"flat",priced:!1};if(a!=="opencode-go"&&B.go.includes(a))return Ut("opencode-go",s,o,{...n,overrides:{}});if(ke.includes(a)&&a!=="opendesign")return Ut("opendesign",s,o,{...n,overrides:{}});if(G(a,s))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(a==="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(a)){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,C="flat";for(let[O,N]of Object.entries(o?.providers??{})){if(we.has(O))continue;let A=N?.models??{},P=Ae(s,A,O,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,C=Tt(v)):w===g&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(m!==null)return{entry:m,billingMode:C,priced:m.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}if(we.has(a))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,a)&&!d)return{entry:null,billingMode:"flat",priced:!1};if(i==="auto"){let u=null,p=-1,m=!1,g="flat";for(let[k,C]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(k===a||we.has(k))continue;let O=C?.models??{},N=Ae(s,O,k,i,o);if(!N)continue;let A=N.id,P=A===null?null:O[A],v=W(P);if(k==="mistral"&&A?.startsWith("deepseek-")&&A!==s&&!a.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":Tt(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 zi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Lt(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 $i=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),Ki=["lmstudio:","lmstudio/","ollama:","ollama/","jan:","jan/","gpt4all:","gpt4all/","koboldcpp:","koboldcpp/","llamacpp:","llamacpp/","llama-cpp:","llama-cpp/","localai:","localai/","vllm:","vllm/","sglang:","sglang/","tabbyapi:","tabbyapi/","lmdeploy:","oobabooga/","text-generation-webui/","llama-server:","gguf:","local:"];function G(e,t){if(typeof e=="string"&&$i.has(e))return!0;let o=typeof t=="string"?Pe(t):"";return Ki.some(n=>o.startsWith(n))}function qi(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(),a=s.indexOf("/");if(a<=0||a===s.length-1)return null;let c=s.slice(0,a).trim().toLowerCase().replace(/^llm-/,""),l=s.slice(a+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(c),m=Object.hasOwn(d,c)||we.has(c)||Object.hasOwn(o?.providers??{},c)||Object.values(B).some(k=>k.includes(c))||tt.includes(c)||p;if(!u&&(!m||we.has(e)||B.go.includes(e))||/(?:^|[-_])free(?:$|[-_])/.test(c)&&!p)return null;let g=Object.hasOwn(d,c)?d[c]:B.go.includes(c)?"opencode-go":c;return!u&&Object.hasOwn(ue,e)&&Object.hasOwn(ue,g)&&g!==e&&(g!=="deepseek"||!/^deepseek/i.test(Pe(l)))||Object.hasOwn(ue,g)&&Wi(l,g==="deepseek"?o?.models??{}:o?.providers?.[g]?.models??{},g,"auto",o)===null?null:{provider:m||Object.hasOwn(d,c)||we.has(g)||Object.hasOwn(ue,g)||Object.hasOwn(o?.providers??{},g)||G(g,l)?g:e,model:l}}function ro(e,t,o,n){if(o?.legacyModelMatching===!0)return Ri(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(c=>n?.overrides?.[c]==="__free__").map(c=>[c,"__free__"]));for(let c=0;c<8;c++){let l=qi(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 a=Ke(Yi(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"?{...a,entry:{...a.entry,peakSchedule:a.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?Gn.has(typeof t=="string"?t.trim().toLowerCase():""):Lt(t,[...Gn])!==null)?{...a,entry:{...a.entry,peakSchedule:a.entry.peakSchedule??"ollama"}}:a}function Yi(e,t,o,n){let i=Ut(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 a=n?.mode==="exact"?"exact":"auto";return nt(zi(s,o,a)??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 Et(o)?o:null}function Gi(e,t,o,n=ot){if(!Array.isArray(o)||o.length===0||ji(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),a=Number(r?.end);return!Number.isFinite(s)||!Number.isFinite(a)?!1:s<a?i>=s&&i<a:i>=s||i<a})}function Qi(e,t,o){let n=Ht(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(c,l="base")=>Ze(c,n,l),r=vn(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(Ti))return i(n);let c=new Date(t),l=c.getUTCDay(),d=c.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(Hi)){let c=n.legacyBase;return c===void 0?i(n):i(c,"legacyBase")}if(o?.enabled!==!0)return i(n);let a=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(Gi(t,a,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let c=n.peak;return c===void 0?i(n):i(c,"peak")}if(a!==void 0&&t>=a){let c=n.offPeak;return c===void 0?i(n):i(c,"offPeak")}return i(n)}function Ft(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),a=r(e?.output),c=r(e?.cacheRead),l=r(e?.cacheWrite),d=r(e?.reasoning);i.longContext&&s+c+l>i.longContext.aboveInputTokens&&(i=i.longContext);let u=typeof i.reasoning=="number"?i.reasoning:0,p=(s*i.cacheMiss+a*i.output+c*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(p)&&p>0?p:0}function Bt(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 Wt={enabled:!1,providerPrefix:"local",referenceModel:"deepseek-flash",priceTier:"offPeak"},Vi=["base","offPeak","peak"];var Zi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),so=e=>typeof e=="string"&&e.trim().length>0&&e.trim().length<=512;function zt(e){let t=Zi(e)?e:{};return{enabled:t.enabled===!0,providerPrefix:so(t.providerPrefix)?t.providerPrefix.trim().toLowerCase():Wt.providerPrefix,referenceModel:so(t.referenceModel)?t.referenceModel.trim():Wt.referenceModel,priceTier:Vi.includes(t.priceTier)?t.priceTier:Wt.priceTier}}import{readFileSync as Yr,renameSync as pi,statSync as Gr}from"node:fs";import{randomUUID as fi}from"node:crypto";var $t=5/1e3,Ji=Date.parse("2026-11-01T00:00:00+08:00"),ao=Date.parse("2026-11-18T12:00:00+08:00"),co=e=>e>=Ji&&e<ao?$t:0,Xi=(e,t)=>e.source==="server-tool"?co(t):e.rateCny,lo=(e,t)=>e.requests*Xi(e,t),uo=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function po(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 fo(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===co(t)||t>=ao&&e.rateCny===$t):e.source===void 0&&e.rateCny===$t}var Kt=["input","output","cacheRead","cacheWrite","reasoning","calls"],ie=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=K.filter(u=>i.every(p=>ie(p?.[u]))),a=Object.fromEntries([...Kt,"cost","apiCost",...s].map(u=>[u,0])),c=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(a)){let m=p==="apiCost"?u.apiCost??u.cost:u[p]??0;if(!ie(m)){l=!1;break}a[p]+=m}if(!l||a.apiCost>a.cost+1e-8){l=!1;break}for(let[p,m]of Object.entries(u.byProviderModel??{})){if(c.has(p)&&c.get(p)===null)continue;let g=c.get(p)??Object.fromEntries(Object.keys(a).map(C=>[C,0])),k=m!==null&&typeof m=="object";for(let C of Object.keys(g)){if(K.includes(C)&&!ie(m?.[C])){delete g[C];continue}let O=C==="apiCost"?m?.apiCost??m?.cost:m?.[C]??0;if(!ie(O)){k=!1;break}g[C]+=O}c.set(p,k?g:null)}}if(!l||!Object.values(a).every(ie)||!Kt.every(u=>ie(n[u]??0)&&a[u]===(n[u]??0)))continue;let d=Math.abs(a.cost-(n.cost??0))>1e-8||Math.abs(a.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=a.cost,n.apiCost=a.apiCost);for(let u of s)Math.abs(a[u]-(n[u]??0))>1e-8&&(n[u]=a[u],d=!0);for(let[u,p]of c){let m=n.byProviderModel?.[u];if(!(!p||!m||!p.calls||!Object.values(p).every(ie)||!Kt.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=>!ie(p[g])||Math.abs(p[g]-(m[g]??0))<=1e-8))){for(let g of s)ie(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 er,MessageChannel as tr,receiveMessageOnPort as ho}from"node:worker_threads";import{randomUUID as nr}from"node:crypto";import{unlinkSync as or,rmdirSync as ir}from"node:fs";import{join as rr}from"node:path";function mo(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new tr,s=new Int32Array(new SharedArrayBuffer(4)),a=!1,c,l,d,u=nr(),p=new Promise(C=>{c=C}),m=new er(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),g=C=>{if(!a){a=!0,clearTimeout(k);try{t(C)}finally{i.close(),m.terminate(),c()}}},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",C=>{d={error:{message:C.message,code:C.code}}}),m.on("exit",C=>{if(!a){try{or(rr(`${e.path}.lock`,`${process.pid}-${u}`)),ir(`${e.path}.lock`)}catch{}g(ho(i)?.message??l??d??{error:{message:`Ledger worker exited (${C})`}})}}),{promise:p,wait(C=8e3){let O=Date.now()+C;for(;!a;){let N=ho(i);if(N){g(N.message);break}if(Date.now()>=O)return!1;Atomics.wait(s,0,0,Math.min(50,O-Date.now()))}return!0}}}function qt(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 Xo,readdirSync as jr,writeFileSync as ii,readFileSync as ri,renameSync as Hr,unlinkSync as bt,rmdirSync as gt,statSync as Lr,copyFileSync as Fr,openSync as ei,fsyncSync as ti,closeSync as ni,constants as Br}from"node:fs";import{dirname as si,join as He}from"node:path";import{randomUUID as ai}from"node:crypto";import{isDeepStrictEqual as $}from"node:util";var go="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var bo="https://api.factory.ai/api/billing/limits";var yo=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 Yt}from"node:os";import{basename as ba,dirname as ya,join as ko,resolve as sr}from"node:path";var Ao=".dsh",ka=`~/${Ao}`,ar="DSH_HOME",cr=".agents",Aa=`~/${cr}`;function lr(){return ko(Yt(),Ao)}function ur(e){return e==="~"?Yt():e.startsWith("~/")||e.startsWith("~\\")?ko(Yt(),e.slice(2)):e}function dr(e,t,o,n){let i=t[o];return sr(ur(e??(i!==void 0&&i.trim().length>0?i:n())))}function Gt(e,t=process.env){return dr(e,t,ar,lr)}var Qt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var mr=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var Ya=672*60*60,Ga=744*60*60;var rc=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),sc=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 gr={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","ZHIPU_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(gr);var Vt="https://platform.xiaomimimo.com/api/v1",br={usage:`${Vt}/tokenPlan/usage`,detail:`${Vt}/tokenPlan/detail`,balance:`${Vt}/balance`},Kc=B.mimo;var yr="open.volcengineapi.com";var kr="2024-01-01",Ar=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var wr={"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 Mo(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var qc=Object.fromEntries(Object.entries(wr).map(([e,t])=>[Mo(e),t]));var Yc=B.scnet;var Mr={"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}},Gc=Object.fromEntries(Object.entries(Mr).map(([e,t])=>[Mo(e),t])),Qc=B.qwen;var Vc={opendesign:[et+"/workspaces/{workspaceId}/billing/preflight",et+"/workspaces/{workspaceId}/wallet/balance"],factory:[bo],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:Ar.map(e=>`https://${yr}/?Action=${e}&Version=${kr}`),mimo:[br.usage],"baidu-coding":[go],workbuddy:[]};function So(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 Sr={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"},Ir=Object.entries(Sr).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function rt(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=Ir.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),a=/coding[-_\s]*plan|编程.*套餐/.test(n);return s===a?null:s?"tencent-token":r}return r}}return null}var re=[...Re,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Zt={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"},Co=400,Oo=2160*36e5,sl=168*36e5;var Cr=840*36e5;function xo(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"||re.includes(o)||Object.values(B).some(a=>a.includes(o))||rt(e)!==null)return null;let n=t.normalize("NFKC").trim().split("/").map(a=>a.trim());if(n.some(a=>!a)||n.slice(0,-1).some(a=>/(?:^|[-_])free(?:$|[-_])/.test(a.toLowerCase())||G(a.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 a=0;a<Math.min(n.length-1,8);a++){let c=n[a].toLowerCase().replace(/^llm-/,"");if(c==="openrouter"||c==="opencode-zen"||r.includes(c)||/(?:^|[-_])free(?:$|[-_])/.test(c)||G(c,n.slice(a+1).join("/")))return null;let l=Object.hasOwn(s,c)?s[c]:null;if(l){let d=n.slice(a+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(c)||d===c)return{id:d,provider:c};if(re.includes(c))return{id:c,provider:c};if(!i&&!tt.includes(c))return null}return null}function Jt(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(re.includes(i))return i;if(n.length===0)return null;for(let[s,a]of Object.entries(B))if(a.includes(n))return s;if(re.includes(n))return n;let r=rt(e);return r!==null?r:G(n,o)||/(?:^|[-_])free(?:$|[-_])/.test(n)||n==="opencode-zen"?null:typeof o=="string"&&o.normalize("NFKC").includes("/")?xo(e,o)?.id??null:rt(e,o)}var Io=new WeakMap;function Or(e){let t=Io.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(de)),n=new Set,i=new Set(Zn.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},Io.set(e,t)}return t}function Xt(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}=Or(o);return!r.has(i)&&s.has(i)}function Eo(e,t,o,n,i){if(uo(e,t))return"api";let r=Jt(e,o,t);r===null&&Xt(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 a=o?.providers;for(let d of[e,r]){if(d==null)continue;let u=a?.[d];if(u==="plan"||u==="api")return u}if(r===null)return"api";let c=xo(e,t),l=c?.id===r?c.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 st(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>re.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 _o(e){return JSON.stringify([e?.planBilling,[...st(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function en(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]:{},a=Number(o);if(!Number.isFinite(a)||a<=0)return r;let c=Math.floor(a/36e5)*36e5,l=s[c]!==null&&typeof s[c]=="object"?s[c]:{tokens:0,cost:0};return l.tokens+=Math.max(0,Number(n)||0),l.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...s,[c]:l}}}function vo(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Cr,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},s=!1;for(let[a,c]of Object.entries(i)){if(c===null||typeof c!="object"||Array.isArray(c)){s=!0;continue}let l={};for(let[d,u]of Object.entries(c)){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[a]=l)}return s||Object.keys(r).length!==Object.keys(i).length?r:i}function tn(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=en(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as ct,readlinkSync as xr,statSync as Er}from"node:fs";import{execFileSync as Po}from"node:child_process";import{hostname as _r}from"node:os";import{join as vr}from"node:path";import{performance as Pr}from"node:perf_hooks";var Ro=_r(),lt=process.platform==="win32"?Pr.timeOrigin:Date.now()-process.uptime()*1e3,No={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},nn,on,at;function rn(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=xr(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let a=e===process.pid?lt:null;if(t&&e!==process.pid){at??=Number(Po("getconf",["CLK_TCK"],No).trim());let c=ct("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(at)&&at>0&&c&&(a=(Number(c)+Number(i)/at)*1e3)}return{platform:"linux",boot:r,namespace:s,start:i,startedAtMs:a}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(lt)),unit:"ms",startedAtMs:lt};let n=vr(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=Po(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],No).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function sn(){return nn===void 0&&(nn=rn(process.pid)),nn}function To(){let e=sn();return JSON.stringify({version:e?.unit==="ms"?2:1,host:Ro,identity:e})}function Do(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!==Ro)return!1;let a=sn();if(i?.identity?.platform==="linux"&&a?.platform==="linux"&&i.identity.boot===a.boot&&i.identity.namespace!==a.namespace)return!1}try{process.kill(t,0)}catch(a){return a.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,rn(t,n===""));let s=t===process.pid?sn():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(on===void 0&&(on=rn(t,!1,!0)),s=on),n===""){let a=t===process.pid?s?.startedAtMs??lt:s?.startedAtMs;return Number.isFinite(a)&&Er(e).mtimeMs<a-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 a=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),c=a(r),l=a(s);return!Number.isSafeInteger(c)||c<=0||!Number.isSafeInteger(l)||l<=0?!1:c<l-2e3}return r.start!==s.start}import{createHash as Rr,randomUUID as ln}from"node:crypto";import{createHash as Nr}from"node:crypto";var Q=new WeakMap,Uo=/^[a-f\d]{64}$/,Te=e=>e&&typeof e=="object"&&!Array.isArray(e),jo=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),an=e=>Nr("sha256").update(JSON.stringify(e)).digest("hex"),Ho=24;function dt(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))dt(t);return Object.freeze(e)}function Lo(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)]))jo(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)?Lo(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 Fo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=Fo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function ut(e,t,o,n){let i=o.get(n);if(i&&i.depth<Ho){let r={base:n,patch:Lo(t[n],e)},s=JSON.stringify(r).length;if(s<1024||s<JSON.stringify(e).length)return{record:dt(r),depth:i.depth+1,signature:an(r),baseValue:t[n]}}return{record:e,depth:0,signature:an(e)}}function pt(e,t,o,n){let i=Q.get(e)??new Map;Q.set(e,i),Object.hasOwn(e,t)||(e[t]=dt(o)),i.has(t)||i.set(t,ut(e[t],e,i,n))}function Bo(e={}){let t={...e};return Q.set(t,new Map(Q.get(e)??[])),t}function Wo(e,t){let o={...t,...e};return Q.set(o,new Map([...Q.get(t)??[],...Q.get(e)??[]])),o}function zo(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,ut(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function $o(e,t,o){let n={},i=new Map,r=Q.get(o),s=new Set,a=c=>{if(i.has(c))return!0;if(!Uo.test(c)||s.has(c)||s.size>Ho||!Te(e[c]))return!1;s.add(c);let l=e[c],d;if(!Te(l.prices)){if(!Uo.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(jo))||!a(l.base))return s.delete(c),!1;d=i.get(l.base)}let u=an(l),p=d?n[l.base]:void 0,m=r?.get(c);if(m&&o[c]&&(m.sourceSignature===u&&m.sourceBase===p||m.signature===u&&m.baseValue===p))n[c]=o[c],i.set(c,m);else{let g=d?n[l.base]:l;if(d)for(let C of l.patch)g=Fo(g,C[0],C);if(!Te(g?.prices))return s.delete(c),!1;n[c]=dt(t(g));let k=ut(n[c],n,i,d?l.base:void 0);i.set(c,{...k,sourceSignature:u,sourceBase:p})}return s.delete(c),!0};for(let c of Object.keys(e))a(c);if(Q.set(n,i),![...i.values()].some(c=>c.depth>0)){let c;for(let l of Object.keys(n)){let{sourceSignature:d,sourceBase:u}=i.get(l);i.set(l,{...ut(n[l],n,i,c),sourceSignature:d,sourceBase:u}),c=l}}return n}var Yo=new WeakMap,ht=new WeakMap,De=new WeakSet,Tr=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],dn=e=>Rr("sha256").update(JSON.stringify(e)).digest("hex"),Se=e=>!["__proto__","constructor","prototype"].includes(e),ft=e=>e&&typeof e=="object"&&!Array.isArray(e),Dr=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 pn(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)=>pn(e,t?.rates,()=>Array.isArray(e)?e.map(o=>Ue(o,t)):ft(e)?Object.fromEntries(Object.entries(e).filter(([o])=>Dr.has(o)||xt.test(o)).map(([o,n])=>[o,Ue(n,t)])):e),cn=(e,t)=>pn(e,t?.models,()=>Object.fromEntries(Object.entries(e??{}).filter(([o])=>Se(o)).map(([o,n])=>[o,Ue(n,t)]))),Ko=["at","before","after","days","sessions","skipped"];function Ur(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 un=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function Go(e){let t=ht.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||un(i,s)>=0)&&o.set(r,i),Array.isArray(i.unloggedResidualModels))for(let a of i.unloggedResidualModels)n.add(JSON.stringify([i.sessionId,i.date,a]))}return t={changes:Object.values(e.changes).sort(un),revisions:o,residualModels:n,fingerprint:dn([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((i,r)=>i.at-r.at||(i.sequence??0)-(r.sequence??0))},ht.set(e,t),t}function fn(e,t=!1,o){let n=structuredClone(Object.fromEntries(Tr.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,pn(s,o?.providers,()=>({...he(s),...s.currency?{currency:s.currency}:{},...s.default?{default:Ue(s.default,o)}:{},models:cn(s.models,o)}))]))},n}function qo(e,t=!1){let o=fn(e,t),n=dn(o),i={};pt(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(!ft(e?.versions)||!ft(e?.changes))return qo(t,n);let i={rates:new WeakMap,models:new WeakMap,providers:new WeakMap},r=$o(e.versions,u=>fn(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=qo({...t,prices:p},n);for(let[g,k]of Object.entries(m.versions))pt(r,g,k);s[ln()]=m.changes.initial}let a=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])),c=Object.fromEntries(Object.entries(ft(e.runs)?e.runs:{}).filter(([u,p])=>Se(u)&&Ko.every(m=>Number.isFinite(p?.[m])&&p[m]>=0)).map(([u,p])=>[u,{...Object.fromEntries([...Ko,...["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(Ur)}:{}}])),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:a,runs:c,fxChanges:l};return De.add(d),d}function mt(e,t,o=Date.now()){let n=fn(t),i=dn(n),r=Go(e),s=r.changes.at(-1),a=Ge(t),c=r.fx.at(-1),l=JSON.stringify(c?.rates)!==JSON.stringify(a);l&&(e.fxChanges??={},e.fxChanges[ln()]={at:Math.max(o,c?.at??0),sequence:(c?.sequence??0)+1,rates:a},ht.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:(pt(e.versions,i,n,s?.version),e.changes[ln()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},ht.delete(e),!0)}function Qo(e,t){return e&&t&&Yo.set(e,t),e}function hn(e,t,o="",n=""){if(e?._repriceFxConfig){let v=hn(e._repriceFxConfig,t,o,n),b=q(v);return{...e,fxRates:b,exchangeRate:b[e.currency]??e.exchangeRate}}let i=Yo.get(e);if(!i||!Number.isFinite(t))return e;let r=Go(i),s=new Date(t),a=Number.isFinite(t)?`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`:"",c=0,l=r.changes.length;for(;c<l;){let v=c+l>>>1;r.changes[v].at<=t?c=v+1:l=v}let d=r.changes[c-1],u=v=>v&&t<=v.at?v:null,p=u(r.revisions.get(JSON.stringify([o,a,""]))),m=n?u(r.revisions.get(JSON.stringify([o,a,n]))):null,g=p&&m?un(p,m)>0?p:m:p??m,k=(g??d)?.version,C=k&&i.versions[k]?{...e,...i.versions[k]}:e,O=0,N=r.fx.length;for(;O<N;){let v=O+N>>>1;r.fx[v].at<=t?O=v+1:N=v}let A=r.fx[O-1]?.rates,P=g?.preserveFx?p?.fxRates??A??q(i.versions[d?.version]??e):g?g.fxRates??q(C):A??q(C);return{...C,fxRates:P,exchangeRate:P[C.currency]??C.exchangeRate}}function Vo(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:Wo(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 Zo(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Bo(t)};return De.add(n),n}function Jo(e){return e&&{...e,format:2,versions:zo(e.versions)}}var pe=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...K],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 bn(e,t){if(j(e)){if(!j(t)){for(let o of K)delete e[o];return}for(let o of K)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))bn(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)&&bn(n,o.get(n.id))}}}function Wr(e,t){if(!j(e)||!j(t))return e;for(let[o,n]of Object.entries(e))j(n)&&bn(n,t[o]);return e}function yn(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)=>yn(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(!K.includes(n)&&!yn(e[n],t[n]))return!1;return!0}function kn(e,t,o){if(!j(e))return e;for(let n of K){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??{}))kn(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(a=>j(a)&&typeof a.id=="string").map(a=>[a.id,a])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)j(s)&&typeof s.id=="string"&&kn(s,i.get(s.id),r.get(s.id))}return e}function Le(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Zo(t)}:{}}}var zr=new Int32Array(new SharedArrayBuffer(4)),ci=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])=>ci(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=ai()){Xo(si(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=To(),a=new Map,c=Date.now()+o;for(;;)try{Xo(i);try{ii(He(i,r),s,{flag:"wx"})}catch(l){try{bt(He(i,r))}catch{}throw gt(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=jr(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(Do(He(i,d[0]),Number(u[1]),a)){bt(He(i,d[0])),gt(i);continue}}else if(d.length===0&&Date.now()-Lr(i).mtimeMs>3e4){gt(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=c)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait(zr,0,0,10)}try{return t()}finally{bt(He(i,r)),gt(i)}}function li(e){let t;try{t=ri(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 ui(e,t){let o=`${e}.${process.pid}-${ai()}.tmp`;try{let n=ei(o,"wx",384);try{ii(n,JSON.stringify(t),"utf8"),ti(n)}finally{ni(n)}if(Hr(o,e),process.platform!=="win32"){let i=ei(si(e),"r");try{ti(i)}finally{ni(i)}}}finally{try{bt(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function An(e){let t;try{t=ri(`${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 wn(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=An(e)}catch(i){if(i.code)throw i}$(n,o)||ui(`${e}.config-bak`,o)}function yt(e,t,o=!1){if(o)try{Fr(e,`${e}.pricing-history-v1.bak`,Br.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}wn(e,t),ui(e,{...t,pricingHistory:Jo(t.pricingHistory)})}var mn=()=>Object.fromEntries(pe.map(e=>[e,0]));function oi(e,t){for(let o of pe)e[o]=(Number(e[o])||0)+(t[o]??0)}function Ce(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!ci(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:a}=t;j(e.days[o])||(e.days[o]={date:o,...mn(),byProviderModel:{},sessions:[]});let c=e.days[o];Array.isArray(c.sessions)||(c.sessions=[]);let l=[c];if(typeof n=="string"&&n.length>0){let d=c.sessions.find(u=>u.id===n);d||(d={id:n,at:i,...mn(),byProviderModel:{}},c.sessions.push(d)),l.push(d)}for(let d of l){oi(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=mn();oi(u,s)}return a!==null&&(e.planHourBuckets=en(e.planHourBuckets,a,i,qt(s),s.cost)),!0}function V(e,t,o,n=!1){if($(t,e))return Ie(o);if($(o,e)||$(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 gn=e=>Object.fromEntries((e?.sessions??[]).filter(t=>fe(t.id)).map(t=>[t.id,t]));function $r(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],a=o[i];if(yn(r,s)){a!==void 0&&(n[i]=kn(Ie(a),r,s));continue}if(!s||!a){s&&(n[i]=Ie(s));continue}if($(s,a)){n[i]=Ie(a);continue}let c=V(r,s,a,!0),l=gn(r),d=gn(s),u=gn(a),p=V(l,d,u,!0),m=(g,k,C)=>Object.fromEntries(pe.map(O=>[O,(C?.[O]??0)+(k?.[O]??0)-(g?.[O]??0)]));Object.assign(c,m(r,s,a)),c.byProviderModel={};for(let g of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(a.byProviderModel??{})]))fe(g)&&(c.byProviderModel[g]=m(r?.byProviderModel?.[g],s.byProviderModel?.[g],a.byProviderModel?.[g]));for(let g of Object.keys(d))if(!(!u[g]||$(l[g],d[g])||$(l[g],u[g]))){for(let k of pe)c[k]-=(d[g][k]??0)-(l[g]?.[k]??0)-((p[g]?.[k]??0)-(u[g][k]??0));for(let[k,C]of Object.entries(d[g].byProviderModel??{}))if(!(!fe(k)||!c.byProviderModel[k]))for(let O of pe)c.byProviderModel[k][O]-=(C[O]??0)-(l[g]?.byProviderModel?.[k]?.[O]??0)-((p[g]?.byProviderModel?.[k]?.[O]??0)-(u[g].byProviderModel?.[k]?.[O]??0))}for(let g of[c,...Object.values(c.byProviderModel)])for(let k of pe)g[k]=Math.max(0,g[k]);c.sessions=Object.values(p).sort((g,k)=>(g.at??0)-(k.at??0)),n[i]=c}return n}function Kr(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 a=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),c=V(a(e[r]?.[s]),a(t[r]?.[s]),a(o[r]?.[s]));i[r][s]=Object.values(c).filter(l=>l.t>=n-Oo).sort((l,d)=>l.t-d.t).slice(-Co)}}return i}function Oe(e,t,o,n,i=Date.now(),r=[],s={}){let a=s.ownLocal===!0,c=o!==void 0&&o===e,l=Le(e),d=c?l:Le(o??e),u=a?t:Le(t);Wr(l.days,d.days);let p=!$(u.historyReset,l.historyReset),m=!$(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)||(Ce(l,P),d!==l&&Ce(d,P),m&&!p&&Ce(u,P));let k={version:1,writeReceipts:Z([...d.writeReceipts??[],...u.writeReceipts??[]]),config:V(l.config,u.config,d.config),days:$r(l.days,u.days,d.days),balanceRef:$(l.balanceRef,u.balanceRef)?d.balanceRef:$(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:Kr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:vo(V(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:V(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:Vo(u.pricingHistory,d.pricingHistory),historyReset:g??null},C=be(u.usageCursors);for(let[P,v]of Object.entries(be(d.usageCursors)))C[P]=Math.max(C[P]??0,v);Object.keys(C).length&&(k.usageCursors=C);let O=V(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);O&&Object.keys(O).length&&(k.providerPriceHashes=O);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),qr(k,r),k}function qr(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(_o(e.config)!==n.fingerprint||!$(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(a=>!o(i.byProviderModel?.[a],r.byProviderModel?.[a]))))for(let a of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!fe(a))continue;let c=e.planHourBuckets?.[a]??{},l=Object.fromEntries(Object.entries(c).filter(([u])=>+u>=n.start&&+u<n.end)),d=n.buckets[a]??{};$(l,d)||(e.planHourBuckets[a]={...Object.fromEntries(Object.entries(c).filter(([u])=>+u<n.start||+u>=n.end)),...d},e.planSamples&&delete e.planSamples[a])}}}function di(e,t,o){return V(e,t,o)}import{join as hi}from"node:path";var mi=1,ki=180;function Qr(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=Gr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Mn=["antigravity","claude","codex","kimi","xai","workbuddy"],Vr=["sidebar","settings","both","off"],Zr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Jr(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function gi(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function Xr(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),a=t.slice(r+1);return!s.includes(":")||!/^[0-9a-f:.]+$/.test(s)?!1:a===""||a.startsWith(":")&&gi(a.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!gi(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 es(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(a=>typeof a=="string").map(a=>Jr(a)).filter(a=>Mn.includes(a)))]:Mn.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(a=>Xr(a)).map(a=>a.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:o.type!=="agy-link"&&typeof o.baseURL=="string"?o.baseURL.trim().replace(/\/+$/,""):"",enabled:o.enabled!==!1,display:Vr.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:Mn.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function ts(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:Qn,peakWindows:Vn.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,hideCustomBalance:!1,hideBudget:!1,hideTodayCost:!1,modelStatistics:{},localSavings:zt(),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(jt.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(jt.default),providers:Object.fromEntries(Object.entries(oe).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:{...Zt},models:{},modelPlans:{}},historyDays:ki,fetchedAt:null,priceSource:"bundled"}}var gu=Object.keys(On());function Sn(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function In(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function ns(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 os(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function kt(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=os(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 bi(e){for(let t of Object.values(e))if(kt(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))kt(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>kt(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))kt(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 is(e){return e==="native"||e==="display"||qe(e)}function rs(e){return e?.adapter!=="openai-credits"?e:{adapter:e.adapter,enabled:e.enabled,display:e.display,refreshMinutes:e.refreshMinutes,label:e.label,labelEn:e.labelEn,unit:"USD",convertToDisplayCurrency:!1,allowInsecureHttp:!1,dashboardUrl:"https://platform.openai.com/settings/organization/billing/credit-grants",grantAmount:Number.isFinite(e.grantAmount)?Math.max(0,e.grantAmount):0,grantStart:typeof e.grantStart=="string"?e.grantStart.slice(0,10):"",grantExpiry:typeof e.grantExpiry=="string"?e.grantExpiry.slice(0,10):"",request:{url:"https://api.openai.com/v1/organization/costs",method:"GET",headers:{}},extract:{}}}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(oo),currency:"CNY"});let n=We(t,o);n.queryAccounts=Tn(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"&&!$e(f))for(let h of St)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 a=f=>typeof f=="number"&&Number.isFinite(f),c=(f,h,y)=>typeof f=="string"&&h.includes(f)?f:y;for(let[f,h]of Object.entries(t)){let y=n[f],R=typeof h;R==="boolean"&&typeof y!="boolean"||R==="number"&&!a(y)||R==="string"&&typeof y!="string"?n[f]=h:R==="object"&&h!==null&&y!==null&&typeof y=="object"&&f==="gatewayQuotas"&&Array.isArray(y)||R==="object"&&h!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(h))&&(n[f]=h)}n.locale=c(n.locale,["auto","zh","en"],"auto"),n.position=c(n.position,["dock","header","off"],"dock"),n.peakStyle=c(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=c(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=c(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=c(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=c(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=c(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=jn(n.modelStatistics),n.localSavings=zt(n.localSavings);for(let f of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","hideCustomBalance","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=c(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=c(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],R={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[f];return[f,R?R.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=c(n.sidebarStyle,["standard","compact","summary","icons"],"standard"),n.planQuotaStyle=c(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=_n(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=c(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=c(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=a(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=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:"",(!a(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(f=>f!==null&&typeof f=="object"&&a(Number(f.start))&&a(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=a(p.amount)&&p.amount>=0?p.amount:100,p.period=c(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=c(m.display,["sidebar","settings","both","off"],"both"),m.source=c(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,is(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=c(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=c(k.main,["rolling","weekly","monthly"],"rolling"),k.detail=k.detail!==!1;let C=n.customBalance??t.customBalance,O=(f,h)=>{let y=f??{},R={...["aliyun","tokenrhythm","openai-credits"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:c(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:Qr(y.dashboardUrl),unit:y.adapter==="tokenrhythm"?"CNY":c(y.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.adapter==="openai-credits")return rs({...y,...R});if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))R.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);R.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)?R.extract={...h.extract}:R.extract={...h.extract,...y.extract},Array.isArray(y.allowedHosts)){let F=y.allowedHosts.filter(D=>typeof D=="string"&&D.length>0);F.length>0&&(R.allowedHosts=F)}return R},N=O(C,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=es(f);!Zr.test(h.id)||b.has(h.id)||h.type!=="agy-link"&&(h.type!=="cliproxyapi"||!ts(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=>O(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 T=n.corner;for(let f of["enabled","goRolling","goWeekly","goMonthly","budget"])T[f]=T[f]===!0||T[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:c(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=So(h.baseUrl);x[f].baseUrl=y??"",y===null&&(x[f].enabled=!1)}if(f==="workbuddy"&&(h.accountSource!==void 0&&(x[f].accountSource=c(h.accountSource,["auto","connect","xdpool"],"auto")),x[f].accountScope=c(h.accountScope,["current","all","selected"],"current"),x[f].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(Qt))].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=yo(h.orgId);x[f].orgId=y??"",y===null&&(x[f].enabled=!1),x[f].factoryPool=c(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 R=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},F={};for(let[D,H]of Object.entries(R)){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),ae=Y(H.cachedInput),ce=Y(H.output);z===null||ae===null||ce===null||(F[D]={input:z,cachedInput:ae,output:ce})}x[f].rates=F}if(f==="volcengine"){let y=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",R=typeof h.apiKey=="string"?h.apiKey.trim():"";x[f].accessKeyId=y.length>0?y:R,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 re){let h=n.planBilling?.providers?.[f];U[f]=["auto","plan","api"].includes(h)?h:Zt[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 se={};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")&&(se[f]=h);let J=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([f,h])=>f.includes(":")&&re.includes(h))),L=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(f=>re.includes(f)):[...st(n)])];return n.planBilling={providers:U,models:se,modelPlans:J,autoProviders:L},n}var ss={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"},bu=Object.keys(ss);function yi(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))Pt(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function Cn(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=yi(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(yi)),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 At=[{id:"provider-catalog-2026-10-03",apply:Me},{id:"provider-catalog-2026-10-15",apply:Jn},{id:"provider-catalog-2026-10-28",apply:Xn},{id:"provider-catalog-2026-11-05",apply:eo},{id:"stepfun-catalog-2026-10-16",apply:to},{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")}}],wt=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=je(r.pricingHistory,t),this.config=t,Rn(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??mo,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,a])=>!["__proto__","constructor","prototype"].includes(s)&&typeof a=="string"&&/^[a-f0-9]{64}$/.test(a))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([s,a])=>s.startsWith("opendesign:")&&typeof a=="string"&&/^[a-f0-9]{64}$/.test(a))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&mt(this.pricingHistory,t),this._config=Qo(t,this.pricingHistory)}static open(){let t=hi(Gt(),"storages","cost-meter"),o=hi(t,"ledger.json");return Fe(o,()=>e.load(o))}static load(t){let o=On(),n={},i=null,r=[...At.map(A=>A.id),"quota-token-window-v2"],s={},a={},c={},l={},d=null,u={},p=[],m,g=!1,k=!1,C=!1;try{let A=JSON.parse(Yr(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!==mi){try{pi(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 At)v.has(w.id)||(w.apply(P),r.push(w.id));o=xe(P),A.openrouterPriceHashes&&typeof A.openrouterPriceHashes=="object"&&!Array.isArray(A.openrouterPriceHashes)&&(c=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=bi(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)?a=A.planHourBuckets:Array.isArray(A.planRecentCalls)&&(a=tn(A.planRecentCalls)),k=!0}}catch(A){if(A?.code!=="ENOENT"){try{pi(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{wn(t,{config:Cn(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=An(t);if(A){let P=A.config;r=A.migrations;for(let v of At)r.includes(v.id)||(v.apply(P),r.push(v.id));o=xe(P),C=!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 O=new e(o,n,t,r,{planSamples:s,planHourBuckets:a,openrouterPriceHashes:c,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:p,pricingHistory:m});O.legacyPricingHistory=g,O.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),O.quotaStatsNeedRepair&&(O.planSamples={}),(g||C)&&O.scheduleWrite();let N=ge(O.days);return N.length&&(N.includes(O.balanceRef?.date)&&(O.balanceRef=null),O.scheduleWrite()),O}account(t,o,n,i,r,s,a){if(this.closed)return;if(a!==void 0&&(!fo(a,i)||r!=="deepseek-official"||!po(o,a)))throw new Error("Invalid official web request fee");let c=hn(this.config,i,n,`${r||"deepseek"}:${o}`),l=ro(r,o,c.prices,{mode:c.priceMatch==="exact"?"exact":"auto",overrides:c.priceOverrides}),d=l.entry??{cacheHit:0,cacheMiss:0,output:0},u={enabled:["deepseek-peak","utc-peak"].includes(l.billingMode)&&c.peakEnabled===!0,effectiveAtMs:Date.parse(c.peakEffectiveAt),windows:c.peakWindows,holidays:c.peakHolidays},p=a?lo(a,i):l.priced?Ft(t,d,i,u):0,m=Bt(p,a?"CNY":l.currency,q(c).CNY),g=this.config.planBilling,k=st(this.config),C=a?"api":Eo(r,o,g,k,this.config.prices),O=C==="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=C==="plan"?Jt(r,g,o)??(Xt(r,o,this.config.prices)?"go":null):null,v={...s?{meter:s}:{},date:Sn(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:O,...Ct(m,O,c)}};return Ce(this,v)?(this.pendingAccounts.push(v),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};Ce(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||ki)),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:mi,config:Cn(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:fi(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Be(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=li(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 At)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:Cn(xe(o.config)),days:bi(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??tn(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(di(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(Oe(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,()=>{mt(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:Oe(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});yt(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();mt(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,a=fi();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:a,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},c=>{if(this.backgroundWrite=null,c.error){let u;try{u=this.readDiskSnapshot()}catch{}if(Z(u?.writeReceipts).includes(a))c={merged:u,revision:Be(this.path)};else{c.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(c.error);return}}let l=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(c.ownDisk)this.writeReceipts=Z(c.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=Oe(t,this.snapshot(),c.merged,l,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(u),this.writeBase=c.merged}this.pendingAccounts=l,this.pendingPlanHourRepairs=d,this.pendingWrite=s!==this.writeGeneration||l.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=c.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(c){return this.fallbackWrite(c),Promise.resolve()}}close(){if(this.backgroundWrite)return this.backgroundWrite.promise.then(()=>this.close());this.flush(5e3),this.closed=!0,this.writeTimer!==null&&(clearTimeout(this.writeTimer),this.writeTimer=null)}sumDays(t){let o=In(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 a=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={..._e({...Qe(a)},s),input:a.input+(s.input??0),output:a.output+(s.output??0),cacheRead:a.cacheRead+(s.cacheRead??0),cacheWrite:a.cacheWrite+(s.cacheWrite??0),reasoning:a.reasoning+(s.reasoning??0),calls:a.calls+(s.calls??0),cost:a.cost+(s.cost??0),apiCost:(a.apiCost??0)+(s.apiCost??s.cost??0)}}}return o.date=t===void 0?"total":t,o}sumRange(t,o){let n=In(`${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,a]of Object.entries(r.byProviderModel??{})){let c=n.byProviderModel[s]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[s]={..._e({...Qe(c)},a),input:c.input+(a.input??0),output:c.output+(a.output??0),cacheRead:c.cacheRead+(a.cacheRead??0),cacheWrite:c.cacheWrite+(a.cacheWrite??0),reasoning:c.reasoning+(a.reasoning??0),calls:c.calls+(a.calls??0),cost:c.cost+(a.cost??0),apiCost:(c.apiCost??0)+(a.apiCost??a.cost??0)}}}return n}today(){let t=Sn(Date.now()),o=this.days[t];return o===void 0?In(t):this.copyDay(o)}todayOfficialCost(){return ns(this.days[Sn(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 Ai=e=>{try{let t=cs(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:ze,base:wi,local:ye,pending:ls,repairs:Mi,revision:us,backupHistory:ds,transactionId:ps,now:fs,port:xn,signal:Si,lockId:hs}=as;try{let e=Fe(ze,()=>{let t=Ai(ze)===us,o=ge(ye.days);o.includes(ye.balanceRef?.date)&&(ye.balanceRef=null);let n=t&&!Mi.length&&!o.length,i=ye;if(!n){let r=new wt(ye.config,{},ze,[],{pricingHistory:ye.pricingHistory});r.writeBase=wi,i=Oe(wi,ye,r.readDiskSnapshot(),ls,fs,Mi,{ownLocal:!0})}return i.writeReceipts=Z([...i.writeReceipts??[],ps]),yt(ze,i,ds),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Ai(ze)}},5e3,hs);xn.postMessage(e)}catch(e){xn.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Si,0,1),Atomics.notify(Si,0),xn.close()}
2
+ import{workerData as cs}from"node:worker_threads";import{statSync as ls}from"node:fs";function _n(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 St=["peakWindows","peakHolidays","peakSchedule"];function he(e){return Object.fromEntries(St.filter(t=>e?.[t]!==void 0).map(t=>[t,e[t]]))}function $e(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 Ke(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 vn(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??[]),a=new Date(t+8*36e5),c=new Date(t),l=["ollama","utc-weekdays"].includes(i)?c.getUTCDay():a.getUTCDay();if(i!=="daily"&&(l===0||l===6)||s.includes(a.toISOString().slice(0,10)))return"offPeak";let d=c.getUTCHours()+c.getUTCMinutes()/60+c.getUTCSeconds()/3600+c.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 It=[["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]],Pn=It.map(([e])=>e),Ii=new Map(It.map(e=>[e[0],e]));function qe(e){return typeof e=="string"&&Ii.has(e)}function Ye(){let e={USD:1};for(let[t,,o]of It)t!=="USD"&&(e[t]=o);return e}var K=["costCny","apiCostCny","costEur","apiCostEur"],Ci=["USD","CNY","EUR"],Nn=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 Pn)n!=="USD"&&Nn(o[n])&&(t[n]=o[n]);return e?.currency!=="USD"&&qe(e?.currency)&&Nn(e?.exchangeRate)&&(t[e.currency]=e.exchangeRate),t}function Ge(e){let t=q(e);return Object.fromEntries(Ci.map(o=>[o,t[o]]))}function Ct(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(K.filter(t=>Number.isFinite(e?.[t])).map(t=>[t,e[t]]))}function _e(e,t,o=1){for(let n of K)Number.isFinite(t?.[n])&&(e[n]=(e[n]??0)+o*t[n]);return e}function Rn(e,t){let o=n=>{let i=Ct(Number(n.cost)||0,Number(n.apiCost??n.cost)||0,t);for(let r of K)(!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 Oi=["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),xi=e=>typeof e=="string"&&/^[a-z0-9][a-z0-9-]{7,63}$/.test(e)&&e!=="default",Ei=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64&&!/[\u0000-\u001f\u007f]/.test(e);function Tn(e){let t={};if(!Ot(e))return t;for(let o of Oi){let n=e[o];if(!Ot(n))continue;let i=new Set,r=(Array.isArray(n.accounts)?n.accounts:[]).filter(s=>!Ot(s)||!xi(s.id)||!Ei(s.label)||i.has(s.id)?!1:(i.add(s.id),!0)).slice(0,10).map(({id:s,label:a})=>({id:s,label:a.trim()}));t[o]={selected:r.some(s=>s.id===n.selected)?n.selected:"default",accounts:r}}return t}var Dn=["today","summary","budget"],Un=e=>e&&typeof e=="object"&&!Array.isArray(e);function jn(e){return Un(e)?Object.fromEntries(Object.entries(e).filter(([t,o])=>t.includes(":")&&t.length<=512&&Un(o)).slice(0,1e3).map(([t,o])=>[t,Object.fromEntries(Dn.map(n=>[n,o[n]!==!1]))]).filter(([,t])=>Dn.some(o=>!t[o]))):{}}var xt=/^(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 Hn(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]*Hn(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 Et(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])=>!xt.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]*Hn(e,n+"."+r)))return!1}}return!0}var Ln={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 _t={"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."}}}};_t.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 vt={"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 _i="https://platform.stepfun.ai/docs/en/guides/pricing/details",ve=(e,t,o)=>({input:e,cachedInput:t,output:o,billingMode:"flat",sourceUrl:_i,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."}),Fn={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(vt)])].map(e=>[e,{models:{...Xe[e]?.models,...vt[e]?.models}}]));ee.stepfun=Fn;var Bn=structuredClone(ee);for(let[e,t]of Object.entries(_t))ee[e]={models:{...ee[e]?.models,...t.models}};var Wn=structuredClone(ee);for(let[e,t]of Object.entries(Ln))ee[e]={models:{...ee[e]?.models,...t.models}};var zn={"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 $n=/\{\{\s*[A-Za-z_][A-Za-z0-9_]*\s*\}\}/,vi=/authorization|api[-_]?key|apikey|token|secret|cookie|session|credential|private[-_]?key/i,Pi=/^(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 Pt(e,t){if(typeof t!="string"||t.length===0)return!1;if($n.test(t)){let n=t.replace(new RegExp($n.source,"g"),"").trim();if(/^(?:(?:bearer|basic|token)\s*)?[:\s]*$/i.test(n))return!1;t=n}if(vi.test(String(e??"")))return!0;let o=t.trim();return!!(/^(bearer|basic|token)\s+\S/i.test(o)||Pi.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",js=et+"/public/model-prices",ke=["opendesign","open-design","open-design-api","amr-link.open-design.ai"],Hs=Object.freeze({invalidRequest:"invalid_request",unauthorized:"unauthorized",http:"http_error",noSubscription:"no_subscription",invalidResponse:"invalid_response",network:"network_error",identityMismatch:"identity_mismatch"});var Ni=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"&&Ni(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 qn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Yn({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 T=Array.isArray(w)?w.filter(x=>typeof x=="string"&&x.length>0):[],I=T.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=T.filter(J=>i(J)===x);if(U.length>0)return U.length===1?U[0]:null;let se=r(M,E,_);if(se===M.toLowerCase())return null;M=se}}let a=new Set(["openrouter","opencode-zen","opencode-go","opencode-go-plus","zen","opencode",...ke]),c={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 T=b.normalize("NFKC").trim().replace(/^models\/(?=gemini)/i,"google/"),I=T.search(/[/:]/);if(I>0){let M=T.slice(0,I).trim().toLowerCase(),x=T.slice(I+1).trim();if(Object.hasOwn(c,M)&&(M===S||(S==="opencode-zen"||S==="opencode-go")&&(c[M].test(x)||s(x,Object.keys(M==="deepseek"?_?.models??{}:_?.providers?.[M]?.models??{}),x,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)!==null)))T=x;else if(Object.hasOwn(c,M))return null}return s(T,Object.keys(w),b,_?.snapshotTags!==!1,_?.shortSnapshotTags!==!1)}function u(b,w,S,E){let _=E?.mode==="exact"?"exact":"auto",T=E?.overrides!==null&&typeof E?.overrides=="object"?E.overrides:{},I=w,M=b,x=(b===""?"deepseek":b)+":"+w,U=T[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},R=e(y);return R===null?{entry:null,billingMode:"flat",priced:!1}:{entry:R,billingMode:"deepseek-peak",priced:R.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"),O(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[ae,ce]of Object.entries(S?.providers??{})){if(a.has(ae))continue;let Ee=ce?.models??{},X=d(I,Ee,ae,_,S);if(X===null)continue;let En=e(Ee[X]);if(En===null)continue;let Mt=+(X===I||i(X)===i(I));Mt>H?(D=En,H=Mt,Y=!1,z=l(Ee[X])):Mt===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 R=o(I,S),F=e(R);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&&a.has(M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&Object.hasOwn(c,M))return{entry:null,billingMode:"flat",priced:!1};if(L===null&&_==="auto"){let h=null,y=-1,R=!1,F="flat";for(let[D,H]of[["deepseek",{models:S?.models??{}}],...Object.entries(S?.providers??{})]){if(D===M||a.has(D))continue;let Y=H?.models??{},z=d(I,Y,D,_,S);if(z===null)continue;let ae=e(Y[z]);if(ae===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=ae,y=ce,R=!1,F=D==="deepseek"?"deepseek-peak":l(Y[z])):ce===y&&(R=!0)}if(R)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 T=E[_],I=e(T);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"]),C=["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 O(b,w){if(typeof b=="string"&&k.has(b))return!0;let S=typeof w=="string"?n(w):"";return C.some(E=>S.startsWith(E))}function N(b,w,S,E,_){let T=_?.[(b||"deepseek")+":"+w];if(!b||E==="exact"||typeof w!="string"||O(b,w)||["our-free-model","our-free-model-region"].includes(b)||typeof T=="string"&&T.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"},se=/^(?:dsh-)?magpie(?:$|-)/.test(b),J=Object.hasOwn(U,M)||a.has(M)||["workbuddy","workbuddy-ai","qoder","qoder-cn","trae-cn","trae-global","zcode","mimo-app","commandcode-plan","cline","copilot","vercel"].includes(M);if(!se&&(!J||Object.hasOwn(c,b)||a.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)||a.has(L)||Object.hasOwn(c,L)||Object.hasOwn(S?.providers??{},L)||O(L,x)?L:b,model:x}}function A(b,w,S,E){let _=typeof b=="string"?b.trim().toLowerCase():"",T=_.startsWith("llm-")?_.slice(4):_,I=N(T,w,S,E?.mode,E?.overrides);if(I&&(T=I.provider,w=I.model,E={...E,overrides:{}}),["our-free-model","our-free-model-region"].includes(T)&&E?.overrides?.[T+":*"]==="__free__")return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},currency:"USD",priced:!0,billingMode:"flat"};let M=Ke(P(T,w,S,E),T,S);return["volcengine","ark"].includes(T)&&S?.volcenginePeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"?{...M,entry:{...M.entry,peakSchedule:M.entry.peakSchedule??"volcengine"}}:T==="ollama-cloud"&&S?.ollamaPeak!==!1&&M.entry&&M.billingMode==="deepseek-peak"&&(S?.ollamaTaggedPeak===!1?qn.has(typeof w=="string"?w.trim().toLowerCase():""):s(w,[...qn])!==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 Ri=Yn({normalizePrice:W,normalizeCustomPrice:Ne});var Qn="2026-08-01T00:00:00Z",Dt="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"],Nt="2026-09-10T04:00:00Z",Ti="2026-08-31T00:00:00Z",Gn=new Set(["deepseek-v4.1-flash","deepseek-v4-pro"]);function Di(e){if(!Number.isFinite(e)||e<Date.parse(Dt))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(Dt)),r=(n+2)*864e5-8*36e5;return{start:i,end:r}}function Ui(e,t=ot){if(!Number.isFinite(e)||e<Date.parse(Dt)||!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 ji=(e,t)=>Ui(e,t)??Di(e),Hi="2026-08-16T16:00:00Z";var Vn=[{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"}}}},Zn=Object.freeze(Object.keys(me["opencode-go"].models)),oe={...me};oe.opendesign={models:zn};for(let[e,t]of Object.entries(ee)){let o=me[e]?.models??{};oe[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(oe)){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[a,c]of Object.entries(i.models)){if(!Object.hasOwn(s,a)){Object.hasOwn(r,a)||(s[a]=structuredClone(c));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[a]&&Object.keys(s[a]).some(p=>!l.has(p)))continue;let d=W(r[a]),u=W(s[a]);d&&u&&JSON.stringify(d)===JSON.stringify(u)&&(s[a]=structuredClone(c))}}}function Jn(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Xe[o]?.models}}]));Me(e,t)}function Xn(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Bn[o]?.models}}]));Me(e,t)}function eo(e){let t=Object.fromEntries(Object.keys(oe).map(o=>[o,{models:{...o==="opencode-zen"||o==="opencode-go"?{}:me[o]?.models,...Wn[o]?.models}}]));Me(e,t)}function to(e){Me(e,Object.fromEntries(Object.entries(oe).filter(([t])=>t!=="stepfun")))}var Li={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}}},Fi={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 Rt(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 no(e){let t=e==="CNY"?Fi:Li,o=Object.fromEntries(Object.entries(t.models).map(([n,i])=>[n,n==="deepseek-v4-pro"?structuredClone(i):Rt(i,e,Nt)]));return o["deepseek-v4.1-flash"]=Rt(t.models["deepseek-v4-flash-vision-exp"],e,Nt),o["deepseek-flash"]=structuredClone(o["deepseek-v4.1-flash"]),{models:o,default:Rt(t.default,e,Nt)}}var jt=no("USD"),oo=no("CNY");function Ht(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 a=Date.parse(s.before);t<a&&a<n&&(o=s,n=a)}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=a=>{let c=e[a];return typeof c=="number"&&Number.isFinite(c)&&c>=0?c:void 0},o=t("cacheMiss")??t("input")??0,n=t("cacheHit")??t("cachedInput")??t("cacheRead")??o,i=t("output")??0,r=t("reasoning"),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 a of["billingMode","sourceUrl","checkedAt","notes"])typeof e[a]=="string"&&(s[a]=e[a]);return s}if(!("cacheHit"in e)&&!("cacheMiss"in e)&&!("output"in e)&&!("input"in e)||!$e(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(a=>o(s[a]))||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 a of e.rateHistory){if(!a||typeof a.before!="string"||!/(?:Z|[+-]\d{2}:\d{2})$/.test(a.before)||!Number.isFinite(Date.parse(a.before))||s.has(Date.parse(a.before))||!["cacheHit","cacheMiss","output"].every(l=>typeof a[l]=="number"&&Number.isFinite(a[l])&&a[l]>=0))return null;s.add(Date.parse(a.before));let c={before:a.before,...le(a)};for(let l of["offPeak","peak"])if(a[l]!==void 0){if(!a[l]||!["cacheHit","cacheMiss","output"].every(d=>typeof a[l][d]=="number"&&Number.isFinite(a[l][d])&&a[l][d]>=0))return null;c[l]=le(a[l])}t.rateHistory.push(c)}t.rateHistory.sort((a,c)=>Date.parse(a.before)-Date.parse(c.before))}return Object.assign(t,Ve(e)),Et(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 Bi(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)),a=Number(r.slice(-4,-2)),c=Number(r.slice(-2)),l=new Date(Date.UTC(s,a-1,c));return s>=2e3&&l.getUTCFullYear()===s&&l.getUTCMonth()===a-1&&l.getUTCDate()===c?n.slice(0,i.index):n}return n.replace(/[-_./:@]latest$/,"")}function io(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 a=e.normalize("NFKC").trim(),c=2;for(;;){let l=de(a);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:c};if(/[:((]\s*(?:free|online)\b/i.test(a))return null;let u=Bi(a,n,i);if(u===a.toLowerCase())return null;a=u,c=1}}function Lt(e,t,o=e,n=!0,i=!0){return io(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 Tt(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 a=r.slice(0,s).trim().toLowerCase(),c=a==="deepseek-ai"?"deepseek":a,l=r.slice(s+1).trim();if(Object.hasOwn(ue,c)&&(c===o||["opencode-zen","opencode-go","zen","opencode","opencode-go-plus"].includes(o)&&(ue[c].test(l)||Lt(l,Object.keys(c==="deepseek"?i?.models??{}:i?.providers?.[c]?.models??{}),l,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)!==null)))r=l;else if(Object.hasOwn(ue,c))return null}return io(r,Object.keys(t),e,i?.snapshotTags!==!1,i?.shortSnapshotTags!==!1)}function Wi(e,t,o,n,i){return Ae(e,t,o,n,i)?.id??null}function Ut(e,t,o,n){let i=n?.mode==="exact"?"exact":"auto",r=n?.overrides!==null&&typeof n?.overrides=="object"?n.overrides:{},s=t,a=e,c=(e===""?"deepseek":e)+":"+t,l=r[c];if(l==="__custom__"){let u=Ne(o?.custom?.[c]);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?(a=l.slice(0,u).trim().toLowerCase(),s=l.slice(u+1)):s=l,a==="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(a,s)&&a!=="openrouter"){let u=o?.providers?.[a]?.models??{},p=Ae(s,u,a,i,o);if(p){let m=p.id===null?null:u[p.id],g=W(m);return{entry:g,billingMode:Tt(m),priced:g!==null&&g.unpriced!==!0}}}if(/(?:^|[-_])free(?:$|[-_])/.test(a)&&!["our-free-model","our-free-model-region"].includes(a))return{entry:null,billingMode:"flat",priced:!1};if(a!=="opencode-go"&&B.go.includes(a))return Ut("opencode-go",s,o,{...n,overrides:{}});if(ke.includes(a)&&a!=="opendesign")return Ut("opendesign",s,o,{...n,overrides:{}});if(G(a,s))return{entry:{cacheHit:0,cacheMiss:0,cacheWrite:0,output:0,reasoning:0},billingMode:"flat",priced:!0,local:!0,currency:"USD"};if(a==="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(a)){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,C="flat";for(let[O,N]of Object.entries(o?.providers??{})){if(we.has(O))continue;let A=N?.models??{},P=Ae(s,A,O,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,C=Tt(v)):w===g&&(k=!0)}if(k)return{entry:null,billingMode:"flat",priced:!1};if(m!==null)return{entry:m,billingMode:C,priced:m.unpriced!==!0}}return{entry:null,billingMode:"flat",priced:!1}}if(we.has(a))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,a)&&!d)return{entry:null,billingMode:"flat",priced:!1};if(i==="auto"){let u=null,p=-1,m=!1,g="flat";for(let[k,C]of[["deepseek",{models:o?.models??{}}],...Object.entries(o?.providers??{})]){if(k===a||we.has(k))continue;let O=C?.models??{},N=Ae(s,O,k,i,o);if(!N)continue;let A=N.id,P=A===null?null:O[A],v=W(P);if(k==="mistral"&&A?.startsWith("deepseek-")&&A!==s&&!a.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":Tt(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 zi(e,t,o){let n=t?.models??{},i=Object.hasOwn(n,e)?e:o==="auto"?Lt(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 $i=new Set(["local","lmstudio","ollama","jan","gpt4all","koboldcpp","llamacpp","llama-cpp","localai","vllm","sglang","tabbyapi","lmdeploy","oobabooga","text-generation-webui","llama-server"]),Ki=["lmstudio:","lmstudio/","ollama:","ollama/","jan:","jan/","gpt4all:","gpt4all/","koboldcpp:","koboldcpp/","llamacpp:","llamacpp/","llama-cpp:","llama-cpp/","localai:","localai/","vllm:","vllm/","sglang:","sglang/","tabbyapi:","tabbyapi/","lmdeploy:","oobabooga/","text-generation-webui/","llama-server:","gguf:","local:"];function G(e,t){if(typeof e=="string"&&$i.has(e))return!0;let o=typeof t=="string"?Pe(t):"";return Ki.some(n=>o.startsWith(n))}function qi(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(),a=s.indexOf("/");if(a<=0||a===s.length-1)return null;let c=s.slice(0,a).trim().toLowerCase().replace(/^llm-/,""),l=s.slice(a+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(c),m=Object.hasOwn(d,c)||we.has(c)||Object.hasOwn(o?.providers??{},c)||Object.values(B).some(k=>k.includes(c))||tt.includes(c)||p;if(!u&&(!m||we.has(e)||B.go.includes(e))||/(?:^|[-_])free(?:$|[-_])/.test(c)&&!p)return null;let g=Object.hasOwn(d,c)?d[c]:B.go.includes(c)?"opencode-go":c;return!u&&Object.hasOwn(ue,e)&&Object.hasOwn(ue,g)&&g!==e&&(g!=="deepseek"||!/^deepseek/i.test(Pe(l)))||Object.hasOwn(ue,g)&&Wi(l,g==="deepseek"?o?.models??{}:o?.providers?.[g]?.models??{},g,"auto",o)===null?null:{provider:m||Object.hasOwn(d,c)||we.has(g)||Object.hasOwn(ue,g)||Object.hasOwn(o?.providers??{},g)||G(g,l)?g:e,model:l}}function ro(e,t,o,n){if(o?.legacyModelMatching===!0)return Ri(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(c=>n?.overrides?.[c]==="__free__").map(c=>[c,"__free__"]));for(let c=0;c<8;c++){let l=qi(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 a=Ke(Yi(r,t,o,n),r,o);return["volcengine","ark"].includes(r)&&o?.volcenginePeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"?{...a,entry:{...a.entry,peakSchedule:a.entry.peakSchedule??"volcengine"}}:r==="ollama-cloud"&&o?.ollamaPeak!==!1&&a.entry&&a.billingMode==="deepseek-peak"&&(o?.ollamaTaggedPeak===!1?Gn.has(typeof t=="string"?t.trim().toLowerCase():""):Lt(t,[...Gn])!==null)?{...a,entry:{...a.entry,peakSchedule:a.entry.peakSchedule??"ollama"}}:a}function Yi(e,t,o,n){let i=Ut(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 a=n?.mode==="exact"?"exact":"auto";return nt(zi(s,o,a)??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 Et(o)?o:null}function Gi(e,t,o,n=ot){if(!Array.isArray(o)||o.length===0||ji(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),a=Number(r?.end);return!Number.isFinite(s)||!Number.isFinite(a)?!1:s<a?i>=s&&i<a:i>=s||i<a})}function Qi(e,t,o){let n=Ht(e,t)??{cacheHit:0,cacheMiss:0,output:0},i=(c,l="base")=>Ze(c,n,l),r=vn(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(Ti))return i(n);let c=new Date(t),l=c.getUTCDay(),d=c.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(Hi)){let c=n.legacyBase;return c===void 0?i(n):i(c,"legacyBase")}if(o?.enabled!==!0)return i(n);let a=typeof o.effectiveAtMs=="number"&&Number.isFinite(o.effectiveAtMs)?o.effectiveAtMs:void 0;if(Gi(t,a,o.windows,n.peakSchedule==="volcengine"?[]:o.holidays)){let c=n.peak;return c===void 0?i(n):i(c,"peak")}if(a!==void 0&&t>=a){let c=n.offPeak;return c===void 0?i(n):i(c,"offPeak")}return i(n)}function Ft(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),a=r(e?.output),c=r(e?.cacheRead),l=r(e?.cacheWrite),d=r(e?.reasoning);i.longContext&&s+c+l>i.longContext.aboveInputTokens&&(i=i.longContext);let u=typeof i.reasoning=="number"?i.reasoning:0,p=(s*i.cacheMiss+a*i.output+c*i.cacheHit+l*(i.cacheWrite??i.cacheHit)+d*u)/1e6;return Number.isFinite(p)&&p>0?p:0}function Bt(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 Wt={enabled:!1,providerPrefix:"local",referenceModel:"deepseek-flash",priceTier:"offPeak"},Vi=["base","offPeak","peak"];var Zi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),so=e=>typeof e=="string"&&e.trim().length>0&&e.trim().length<=512;function zt(e){let t=Zi(e)?e:{};return{enabled:t.enabled===!0,providerPrefix:so(t.providerPrefix)?t.providerPrefix.trim().toLowerCase():Wt.providerPrefix,referenceModel:so(t.referenceModel)?t.referenceModel.trim():Wt.referenceModel,priceTier:Vi.includes(t.priceTier)?t.priceTier:Wt.priceTier}}import{readFileSync as Gr,renameSync as pi,statSync as Qr}from"node:fs";import{randomUUID as fi}from"node:crypto";var $t=5/1e3,Ji=Date.parse("2026-11-01T00:00:00+08:00"),ao=Date.parse("2026-11-18T12:00:00+08:00"),co=e=>e>=Ji&&e<ao?$t:0,Xi=(e,t)=>e.source==="server-tool"?co(t):e.rateCny,lo=(e,t)=>e.requests*Xi(e,t),uo=(e,t)=>e==="deepseek-official"&&["deepseek-web-search","deepseek-web-fetch","deepseek-search-api","deepseek-fetch-api","deepseek-search-server"].includes(t);function po(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 fo(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===co(t)||t>=ao&&e.rateCny===$t):e.source===void 0&&e.rateCny===$t}var Kt=["input","output","cacheRead","cacheWrite","reasoning","calls"],ie=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=K.filter(u=>i.every(p=>ie(p?.[u]))),a=Object.fromEntries([...Kt,"cost","apiCost",...s].map(u=>[u,0])),c=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(a)){let m=p==="apiCost"?u.apiCost??u.cost:u[p]??0;if(!ie(m)){l=!1;break}a[p]+=m}if(!l||a.apiCost>a.cost+1e-8){l=!1;break}for(let[p,m]of Object.entries(u.byProviderModel??{})){if(c.has(p)&&c.get(p)===null)continue;let g=c.get(p)??Object.fromEntries(Object.keys(a).map(C=>[C,0])),k=m!==null&&typeof m=="object";for(let C of Object.keys(g)){if(K.includes(C)&&!ie(m?.[C])){delete g[C];continue}let O=C==="apiCost"?m?.apiCost??m?.cost:m?.[C]??0;if(!ie(O)){k=!1;break}g[C]+=O}c.set(p,k?g:null)}}if(!l||!Object.values(a).every(ie)||!Kt.every(u=>ie(n[u]??0)&&a[u]===(n[u]??0)))continue;let d=Math.abs(a.cost-(n.cost??0))>1e-8||Math.abs(a.apiCost-(n.apiCost??n.cost??0))>1e-8;d&&(n.cost=a.cost,n.apiCost=a.apiCost);for(let u of s)Math.abs(a[u]-(n[u]??0))>1e-8&&(n[u]=a[u],d=!0);for(let[u,p]of c){let m=n.byProviderModel?.[u];if(!(!p||!m||!p.calls||!Object.values(p).every(ie)||!Kt.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=>!ie(p[g])||Math.abs(p[g]-(m[g]??0))<=1e-8))){for(let g of s)ie(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 er,MessageChannel as tr,receiveMessageOnPort as ho}from"node:worker_threads";import{randomUUID as nr}from"node:crypto";import{unlinkSync as or,rmdirSync as ir}from"node:fs";import{join as rr}from"node:path";function mo(e,t,{timeoutMs:o=15e3,workerUrl:n=new URL("./ledger-writer-worker.js",import.meta.url)}={}){let{port1:i,port2:r}=new tr,s=new Int32Array(new SharedArrayBuffer(4)),a=!1,c,l,d,u=nr(),p=new Promise(C=>{c=C}),m=new er(n,{workerData:{...e,signal:s,port:r,lockId:u},transferList:[r],execArgv:[]}),g=C=>{if(!a){a=!0,clearTimeout(k);try{t(C)}finally{i.close(),m.terminate(),c()}}},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",C=>{d={error:{message:C.message,code:C.code}}}),m.on("exit",C=>{if(!a){try{or(rr(`${e.path}.lock`,`${process.pid}-${u}`)),ir(`${e.path}.lock`)}catch{}g(ho(i)?.message??l??d??{error:{message:`Ledger worker exited (${C})`}})}}),{promise:p,wait(C=8e3){let O=Date.now()+C;for(;!a;){let N=ho(i);if(N){g(N.message);break}if(Date.now()>=O)return!1;Atomics.wait(s,0,0,Math.min(50,O-Date.now()))}return!0}}}function qt(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 Xo,readdirSync as Hr,writeFileSync as ii,readFileSync as ri,renameSync as Lr,unlinkSync as bt,rmdirSync as gt,statSync as Fr,copyFileSync as Br,openSync as ei,fsyncSync as ti,closeSync as ni,constants as Wr}from"node:fs";import{dirname as si,join as He}from"node:path";import{randomUUID as ai}from"node:crypto";import{isDeepStrictEqual as $}from"node:util";var go="https://console.bce.baidu.com/api/qianfan/charge/tokenPlanPersonal/resource";var bo="https://api.factory.ai/api/billing/limits";var yo=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 Yt}from"node:os";import{basename as ka,dirname as Aa,join as ko,resolve as sr}from"node:path";var Ao=".dsh",wa=`~/${Ao}`,ar="DSH_HOME",cr=".agents",Ma=`~/${cr}`;function lr(){return ko(Yt(),Ao)}function ur(e){return e==="~"?Yt():e.startsWith("~/")||e.startsWith("~\\")?ko(Yt(),e.slice(2)):e}function dr(e,t,o,n){let i=t[o];return sr(ur(e??(i!==void 0&&i.trim().length>0?i:n())))}function Gt(e,t=process.env){return dr(e,t,ar,lr)}var Qt=e=>typeof e=="string"&&/^(cn|global):[^\s\u0000-\u001f\u007f]{1,256}$/.test(e);var mr=[["rate-limit-reset-credits","/consume"].join(""),["chat","/completions"].join("")];var Ga=672*60*60,Qa=744*60*60;var sc=Object.freeze({authFiles:"/v0/management/auth-files",apiCall:"/v0/management/api-call",workbuddyCredits:"/v0/management/plugins/workbuddy/credits",workBuddyCredits:"/v0/management/plugins/workbuddy/credits"}),ac=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 br={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","ZHIPU_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(br);var Vt="https://platform.xiaomimimo.com/api/v1",yr={usage:`${Vt}/tokenPlan/usage`,detail:`${Vt}/tokenPlan/detail`,balance:`${Vt}/balance`},qc=B.mimo;var kr="open.volcengineapi.com";var Ar="2024-01-01",wr=["GetCodingPlanUsage","GetAFPUsage","GetUsageDetails","GetPersonalPlan"];var Mr={"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 Mo(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]/g,"")}var Yc=Object.fromEntries(Object.entries(Mr).map(([e,t])=>[Mo(e),t]));var Gc=B.scnet;var Sr={"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}},Qc=Object.fromEntries(Object.entries(Sr).map(([e,t])=>[Mo(e),t])),Vc=B.qwen;var Zc={opendesign:[et+"/workspaces/{workspaceId}/billing/preflight",et+"/workspaces/{workspaceId}/wallet/balance"],factory:[bo],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:wr.map(e=>`https://${kr}/?Action=${e}&Version=${Ar}`),mimo:[yr.usage],"baidu-coding":[go],workbuddy:[]};function So(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 Ir={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"},Cr=Object.entries(Ir).map(([e,t])=>[e,new RegExp("(?:^|[^a-z0-9])(?:"+t+")(?=$|[^a-z0-9])")]);function rt(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=Cr.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),a=/coding[-_\s]*plan|编程.*套餐/.test(n);return s===a?null:s?"tencent-token":r}return r}}return null}var re=[...Re,"go","codex","volcengine-agent","tencent-coding","tencent-token","antigravity","stepfun"],Zt={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"},Co=400,Oo=2160*36e5,al=168*36e5;var Or=840*36e5;function xo(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"||re.includes(o)||Object.values(B).some(a=>a.includes(o))||rt(e)!==null)return null;let n=t.normalize("NFKC").trim().split("/").map(a=>a.trim());if(n.some(a=>!a)||n.slice(0,-1).some(a=>/(?:^|[-_])free(?:$|[-_])/.test(a.toLowerCase())||G(a.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 a=0;a<Math.min(n.length-1,8);a++){let c=n[a].toLowerCase().replace(/^llm-/,"");if(c==="openrouter"||c==="opencode-zen"||r.includes(c)||/(?:^|[-_])free(?:$|[-_])/.test(c)||G(c,n.slice(a+1).join("/")))return null;let l=Object.hasOwn(s,c)?s[c]:null;if(l){let d=n.slice(a+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(c)||d===c)return{id:d,provider:c};if(re.includes(c))return{id:c,provider:c};if(!i&&!tt.includes(c))return null}return null}function Jt(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(re.includes(i))return i;if(n.length===0)return null;for(let[s,a]of Object.entries(B))if(a.includes(n))return s;if(re.includes(n))return n;let r=rt(e);return r!==null?r:G(n,o)||/(?:^|[-_])free(?:$|[-_])/.test(n)||n==="opencode-zen"?null:typeof o=="string"&&o.normalize("NFKC").includes("/")?xo(e,o)?.id??null:rt(e,o)}var Io=new WeakMap;function xr(e){let t=Io.get(e);if(t===void 0){let o=new Set(Object.keys(e?.models??{}).map(de)),n=new Set,i=new Set(Zn.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},Io.set(e,t)}return t}function Xt(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}=xr(o);return!r.has(i)&&s.has(i)}function Eo(e,t,o,n,i){if(uo(e,t))return"api";let r=Jt(e,o,t);r===null&&Xt(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 a=o?.providers;for(let d of[e,r]){if(d==null)continue;let u=a?.[d];if(u==="plan"||u==="api")return u}if(r===null)return"api";let c=xo(e,t),l=c?.id===r?c.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 st(e){if(Array.isArray(e?.planBilling?.autoProviders))return new Set(e.planBilling.autoProviders.filter(n=>re.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 _o(e){return JSON.stringify([e?.planBilling,[...st(e)],e?.prices,e?.priceOverrides,e?.priceMatch,e?.exchangeRate,e?.peakEnabled,e?.peakEffectiveAt,e?.peakWindows,e?.peakHolidays])}function en(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]:{},a=Number(o);if(!Number.isFinite(a)||a<=0)return r;let c=Math.floor(a/36e5)*36e5,l=s[c]!==null&&typeof s[c]=="object"?s[c]:{tokens:0,cost:0};return l.tokens+=Math.max(0,Number(n)||0),l.cost+=Math.max(0,Number(i)||0),{...r,[t]:{...s,[c]:l}}}function vo(e,t){let o=Number.isFinite(t)&&t>0?t:Date.now(),n=o-Or,i=e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{},r={},s=!1;for(let[a,c]of Object.entries(i)){if(c===null||typeof c!="object"||Array.isArray(c)){s=!0;continue}let l={};for(let[d,u]of Object.entries(c)){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[a]=l)}return s||Object.keys(r).length!==Object.keys(i).length?r:i}function tn(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=en(t,n,Number(o.t),o.tokens,o.cost))}return t}import{readFileSync as ct,readlinkSync as Er,statSync as _r}from"node:fs";import{execFileSync as Po}from"node:child_process";import{hostname as vr}from"node:os";import{join as Pr}from"node:path";import{performance as Nr}from"node:perf_hooks";var Ro=vr(),lt=process.platform==="win32"?Nr.timeOrigin:Date.now()-process.uptime()*1e3,No={encoding:"utf8",timeout:2e3,maxBuffer:1024,windowsHide:!0,stdio:["ignore","pipe","ignore"]},nn,on,at;function rn(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=Er(`/proc/${e}/ns/pid`);if(!/^[a-f0-9-]{36}$/.test(r)||!s)return null;let a=e===process.pid?lt:null;if(t&&e!==process.pid){at??=Number(Po("getconf",["CLK_TCK"],No).trim());let c=ct("/proc/stat","utf8").match(/^btime (\d+)$/m)?.[1];Number.isFinite(at)&&at>0&&c&&(a=(Number(c)+Number(i)/at)*1e3)}return{platform:"linux",boot:r,namespace:s,start:i,startedAtMs:a}}if(process.platform==="win32"){if(e===process.pid&&!o)return{platform:"win32",start:String(Math.round(lt)),unit:"ms",startedAtMs:lt};let n=Pr(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe"),i=Po(n,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${e} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`],No).trim();return/^\d+$/.test(i)?{platform:"win32",start:i,startedAtMs:Number(BigInt(i)/10000n-62135596800000n)}:null}}catch{}return null}function sn(){return nn===void 0&&(nn=rn(process.pid)),nn}function To(){let e=sn();return JSON.stringify({version:e?.unit==="ms"?2:1,host:Ro,identity:e})}function Do(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!==Ro)return!1;let a=sn();if(i?.identity?.platform==="linux"&&a?.platform==="linux"&&i.identity.boot===a.boot&&i.identity.namespace!==a.namespace)return!1}try{process.kill(t,0)}catch(a){return a.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,rn(t,n===""));let s=t===process.pid?sn():o.get(t);if(t===process.pid&&process.platform==="win32"&&i?.version===1&&(on===void 0&&(on=rn(t,!1,!0)),s=on),n===""){let a=t===process.pid?s?.startedAtMs??lt:s?.startedAtMs;return Number.isFinite(a)&&_r(e).mtimeMs<a-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 a=d=>d.unit==="ms"?Number(d.start):Number(BigInt(d.start)/10000n-62135596800000n),c=a(r),l=a(s);return!Number.isSafeInteger(c)||c<=0||!Number.isSafeInteger(l)||l<=0?!1:c<l-2e3}return r.start!==s.start}import{createHash as Tr,randomUUID as ln}from"node:crypto";import{createHash as Rr}from"node:crypto";var Q=new WeakMap,Uo=/^[a-f\d]{64}$/,Te=e=>e&&typeof e=="object"&&!Array.isArray(e),jo=e=>typeof e=="string"&&!["__proto__","constructor","prototype"].includes(e),an=e=>Rr("sha256").update(JSON.stringify(e)).digest("hex"),Ho=24;function dt(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))dt(t);return Object.freeze(e)}function Lo(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)]))jo(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)?Lo(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 Fo(e,t,o){if(!t.length)return o[1];let[n,...i]=t,r={...e};return i.length?r[n]=Fo(e?.[n],i,o):o.length===1?delete r[n]:r[n]=o[1],r}function ut(e,t,o,n){let i=o.get(n);if(i&&i.depth<Ho){let r={base:n,patch:Lo(t[n],e)},s=JSON.stringify(r).length;if(s<1024||s<JSON.stringify(e).length)return{record:dt(r),depth:i.depth+1,signature:an(r),baseValue:t[n]}}return{record:e,depth:0,signature:an(e)}}function pt(e,t,o,n){let i=Q.get(e)??new Map;Q.set(e,i),Object.hasOwn(e,t)||(e[t]=dt(o)),i.has(t)||i.set(t,ut(e[t],e,i,n))}function Bo(e={}){let t={...e};return Q.set(t,new Map(Q.get(e)??[])),t}function Wo(e,t){let o={...t,...e};return Q.set(o,new Map([...Q.get(t)??[],...Q.get(e)??[]])),o}function zo(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,ut(i,e,t,o)),o=n}return Object.fromEntries([...t].filter(([n])=>Object.hasOwn(e,n)).map(([n,i])=>[n,i.record]))}function $o(e,t,o){let n={},i=new Map,r=Q.get(o),s=new Set,a=c=>{if(i.has(c))return!0;if(!Uo.test(c)||s.has(c)||s.size>Ho||!Te(e[c]))return!1;s.add(c);let l=e[c],d;if(!Te(l.prices)){if(!Uo.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(jo))||!a(l.base))return s.delete(c),!1;d=i.get(l.base)}let u=an(l),p=d?n[l.base]:void 0,m=r?.get(c);if(m&&o[c]&&(m.sourceSignature===u&&m.sourceBase===p||m.signature===u&&m.baseValue===p))n[c]=o[c],i.set(c,m);else{let g=d?n[l.base]:l;if(d)for(let C of l.patch)g=Fo(g,C[0],C);if(!Te(g?.prices))return s.delete(c),!1;n[c]=dt(t(g));let k=ut(n[c],n,i,d?l.base:void 0);i.set(c,{...k,sourceSignature:u,sourceBase:p})}return s.delete(c),!0};for(let c of Object.keys(e))a(c);if(Q.set(n,i),![...i.values()].some(c=>c.depth>0)){let c;for(let l of Object.keys(n)){let{sourceSignature:d,sourceBase:u}=i.get(l);i.set(l,{...ut(n[l],n,i,c),sourceSignature:d,sourceBase:u}),c=l}}return n}var Yo=new WeakMap,ht=new WeakMap,De=new WeakSet,Dr=["prices","priceMatch","priceOverrides","exchangeRate","peakEnabled","peakEffectiveAt","peakWindows","peakHolidays"],dn=e=>Tr("sha256").update(JSON.stringify(e)).digest("hex"),Se=e=>!["__proto__","constructor","prototype"].includes(e),ft=e=>e&&typeof e=="object"&&!Array.isArray(e),Ur=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 pn(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)=>pn(e,t?.rates,()=>Array.isArray(e)?e.map(o=>Ue(o,t)):ft(e)?Object.fromEntries(Object.entries(e).filter(([o])=>Ur.has(o)||xt.test(o)).map(([o,n])=>[o,Ue(n,t)])):e),cn=(e,t)=>pn(e,t?.models,()=>Object.fromEntries(Object.entries(e??{}).filter(([o])=>Se(o)).map(([o,n])=>[o,Ue(n,t)]))),Ko=["at","before","after","days","sessions","skipped"];function jr(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 un=(e,t)=>e.at-t.at||(e.sequence??0)-(t.sequence??0)||e.version.localeCompare(t.version);function Go(e){let t=ht.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||un(i,s)>=0)&&o.set(r,i),Array.isArray(i.unloggedResidualModels))for(let a of i.unloggedResidualModels)n.add(JSON.stringify([i.sessionId,i.date,a]))}return t={changes:Object.values(e.changes).sort(un),revisions:o,residualModels:n,fingerprint:dn([e.changes,e.revisions,e.fxChanges]),fx:Object.values(e.fxChanges??{}).sort((i,r)=>i.at-r.at||(i.sequence??0)-(r.sequence??0))},ht.set(e,t),t}function fn(e,t=!1,o){let n=structuredClone(Object.fromEntries(Dr.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,pn(s,o?.providers,()=>({...he(s),...s.currency?{currency:s.currency}:{},...s.default?{default:Ue(s.default,o)}:{},models:cn(s.models,o)}))]))},n}function qo(e,t=!1){let o=fn(e,t),n=dn(o),i={};pt(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(!ft(e?.versions)||!ft(e?.changes))return qo(t,n);let i={rates:new WeakMap,models:new WeakMap,providers:new WeakMap},r=$o(e.versions,u=>fn(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=qo({...t,prices:p},n);for(let[g,k]of Object.entries(m.versions))pt(r,g,k);s[ln()]=m.changes.initial}let a=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])),c=Object.fromEntries(Object.entries(ft(e.runs)?e.runs:{}).filter(([u,p])=>Se(u)&&Ko.every(m=>Number.isFinite(p?.[m])&&p[m]>=0)).map(([u,p])=>[u,{...Object.fromEntries([...Ko,...["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(jr)}:{}}])),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:a,runs:c,fxChanges:l};return De.add(d),d}function mt(e,t,o=Date.now()){let n=fn(t),i=dn(n),r=Go(e),s=r.changes.at(-1),a=Ge(t),c=r.fx.at(-1),l=JSON.stringify(c?.rates)!==JSON.stringify(a);l&&(e.fxChanges??={},e.fxChanges[ln()]={at:Math.max(o,c?.at??0),sequence:(c?.sequence??0)+1,rates:a},ht.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:(pt(e.versions,i,n,s?.version),e.changes[ln()]={at:Math.max(o,s?.at??0),sequence:(s?.sequence??0)+1,version:i},ht.delete(e),!0)}function Qo(e,t){return e&&t&&Yo.set(e,t),e}function hn(e,t,o="",n=""){if(e?._repriceFxConfig){let v=hn(e._repriceFxConfig,t,o,n),b=q(v);return{...e,fxRates:b,exchangeRate:b[e.currency]??e.exchangeRate}}let i=Yo.get(e);if(!i||!Number.isFinite(t))return e;let r=Go(i),s=new Date(t),a=Number.isFinite(t)?`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`:"",c=0,l=r.changes.length;for(;c<l;){let v=c+l>>>1;r.changes[v].at<=t?c=v+1:l=v}let d=r.changes[c-1],u=v=>v&&t<=v.at?v:null,p=u(r.revisions.get(JSON.stringify([o,a,""]))),m=n?u(r.revisions.get(JSON.stringify([o,a,n]))):null,g=p&&m?un(p,m)>0?p:m:p??m,k=(g??d)?.version,C=k&&i.versions[k]?{...e,...i.versions[k]}:e,O=0,N=r.fx.length;for(;O<N;){let v=O+N>>>1;r.fx[v].at<=t?O=v+1:N=v}let A=r.fx[O-1]?.rates,P=g?.preserveFx?p?.fxRates??A??q(i.versions[d?.version]??e):g?g.fxRates??q(C):A??q(C);return{...C,fxRates:P,exchangeRate:P[C.currency]??C.exchangeRate}}function Vo(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:Wo(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 Zo(e){if(!e)return e;let{versions:t,...o}=e,n={...structuredClone(o),versions:Bo(t)};return De.add(n),n}function Jo(e){return e&&{...e,format:2,versions:zo(e.versions)}}var pe=["input","output","cacheRead","cacheWrite","reasoning","calls","cost","apiCost",...K],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 bn(e,t){if(j(e)){if(!j(t)){for(let o of K)delete e[o];return}for(let o of K)Number.isFinite(t[o])||delete e[o];for(let[o,n]of Object.entries(e.byProviderModel??{}))bn(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)&&bn(n,o.get(n.id))}}}function zr(e,t){if(!j(e)||!j(t))return e;for(let[o,n]of Object.entries(e))j(n)&&bn(n,t[o]);return e}function yn(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)=>yn(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(!K.includes(n)&&!yn(e[n],t[n]))return!1;return!0}function kn(e,t,o){if(!j(e))return e;for(let n of K){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??{}))kn(i,t?.byProviderModel?.[n],o?.byProviderModel?.[n]);if(Array.isArray(e.sessions)){let n=s=>new Map((Array.isArray(s)?s:[]).filter(a=>j(a)&&typeof a.id=="string").map(a=>[a.id,a])),i=n(t?.sessions),r=n(o?.sessions);for(let s of e.sessions)j(s)&&typeof s.id=="string"&&kn(s,i.get(s.id),r.get(s.id))}return e}function Le(e){let{pricingHistory:t,...o}=e;return{...structuredClone(o),...t?{pricingHistory:Zo(t)}:{}}}var $r=new Int32Array(new SharedArrayBuffer(4)),ci=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])=>ci(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=ai()){Xo(si(e),{recursive:!0});let i=`${e}.lock`,r=`${process.pid}-${n}`,s=To(),a=new Map,c=Date.now()+o;for(;;)try{Xo(i);try{ii(He(i,r),s,{flag:"wx"})}catch(l){try{bt(He(i,r))}catch{}throw gt(i),l}break}catch(l){if(!["EEXIST","EPERM"].includes(l.code))throw l;try{let d=Hr(i),u=d.length===1&&d[0].match(/^(\d+)-[a-f0-9-]+$/);if(u){if(Do(He(i,d[0]),Number(u[1]),a)){bt(He(i,d[0])),gt(i);continue}}else if(d.length===0&&Date.now()-Fr(i).mtimeMs>3e4){gt(i);continue}}catch(d){if(!["ENOENT","ENOTEMPTY","EEXIST","EPERM"].includes(d.code))throw d}if(Date.now()>=c)throw Object.assign(new Error("Ledger is busy; preserving pending changes for retry"),{code:"EBUSY"});Atomics.wait($r,0,0,10)}try{return t()}finally{bt(He(i,r)),gt(i)}}function li(e){let t;try{t=ri(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 ui(e,t){let o=`${e}.${process.pid}-${ai()}.tmp`;try{let n=ei(o,"wx",384);try{ii(n,JSON.stringify(t),"utf8"),ti(n)}finally{ni(n)}if(Lr(o,e),process.platform!=="win32"){let i=ei(si(e),"r");try{ti(i)}finally{ni(i)}}}finally{try{bt(o)}catch(n){if(n.code!=="ENOENT")throw n}}}function An(e){let t;try{t=ri(`${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 wn(e,t){let o={version:1,config:t.config,migrations:t.migrations??[]},n;try{n=An(e)}catch(i){if(i.code)throw i}$(n,o)||ui(`${e}.config-bak`,o)}function yt(e,t,o=!1){if(o)try{Br(e,`${e}.pricing-history-v1.bak`,Wr.COPYFILE_EXCL)}catch(n){if(!["EEXIST","ENOENT"].includes(n.code))throw n}wn(e,t),ui(e,{...t,pricingHistory:Jo(t.pricingHistory)})}var mn=()=>Object.fromEntries(pe.map(e=>[e,0]));function oi(e,t){for(let o of pe)e[o]=(Number(e[o])||0)+(t[o]??0)}function Ce(e,t){if(t.meter){let{source:d,seq:u}=t.meter;if(!ci(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:a}=t;j(e.days[o])||(e.days[o]={date:o,...mn(),byProviderModel:{},sessions:[]});let c=e.days[o];Array.isArray(c.sessions)||(c.sessions=[]);let l=[c];if(typeof n=="string"&&n.length>0){let d=c.sessions.find(u=>u.id===n);d||(d={id:n,at:i,...mn(),byProviderModel:{}},c.sessions.push(d)),l.push(d)}for(let d of l){oi(d,s),d.byProviderModel??={};let u=d.byProviderModel[r]??=mn();oi(u,s)}return a!==null&&(e.planHourBuckets=en(e.planHourBuckets,a,i,qt(s),s.cost)),!0}function V(e,t,o,n=!1){if($(t,e))return Ie(o);if($(o,e)||$(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 gn=e=>Object.fromEntries((e?.sessions??[]).filter(t=>fe(t.id)).map(t=>[t.id,t]));function Kr(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],a=o[i];if(yn(r,s)){a!==void 0&&(n[i]=kn(Ie(a),r,s));continue}if(!s||!a){s&&(n[i]=Ie(s));continue}if($(s,a)){n[i]=Ie(a);continue}let c=V(r,s,a,!0),l=gn(r),d=gn(s),u=gn(a),p=V(l,d,u,!0),m=(g,k,C)=>Object.fromEntries(pe.map(O=>[O,(C?.[O]??0)+(k?.[O]??0)-(g?.[O]??0)]));Object.assign(c,m(r,s,a)),c.byProviderModel={};for(let g of new Set([...Object.keys(r?.byProviderModel??{}),...Object.keys(s.byProviderModel??{}),...Object.keys(a.byProviderModel??{})]))fe(g)&&(c.byProviderModel[g]=m(r?.byProviderModel?.[g],s.byProviderModel?.[g],a.byProviderModel?.[g]));for(let g of Object.keys(d))if(!(!u[g]||$(l[g],d[g])||$(l[g],u[g]))){for(let k of pe)c[k]-=(d[g][k]??0)-(l[g]?.[k]??0)-((p[g]?.[k]??0)-(u[g][k]??0));for(let[k,C]of Object.entries(d[g].byProviderModel??{}))if(!(!fe(k)||!c.byProviderModel[k]))for(let O of pe)c.byProviderModel[k][O]-=(C[O]??0)-(l[g]?.byProviderModel?.[k]?.[O]??0)-((p[g]?.byProviderModel?.[k]?.[O]??0)-(u[g].byProviderModel?.[k]?.[O]??0))}for(let g of[c,...Object.values(c.byProviderModel)])for(let k of pe)g[k]=Math.max(0,g[k]);c.sessions=Object.values(p).sort((g,k)=>(g.at??0)-(k.at??0)),n[i]=c}return n}function qr(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 a=l=>Object.fromEntries((Array.isArray(l)?l:[]).filter(d=>d&&Number.isFinite(d.t)).map(d=>[d.t,d])),c=V(a(e[r]?.[s]),a(t[r]?.[s]),a(o[r]?.[s]));i[r][s]=Object.values(c).filter(l=>l.t>=n-Oo).sort((l,d)=>l.t-d.t).slice(-Co)}}return i}function Oe(e,t,o,n,i=Date.now(),r=[],s={}){let a=s.ownLocal===!0,c=o!==void 0&&o===e,l=Le(e),d=c?l:Le(o??e),u=a?t:Le(t);zr(l.days,d.days);let p=!$(u.historyReset,l.historyReset),m=!$(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)||(Ce(l,P),d!==l&&Ce(d,P),m&&!p&&Ce(u,P));let k={version:1,writeReceipts:Z([...d.writeReceipts??[],...u.writeReceipts??[]]),config:V(l.config,u.config,d.config),days:Kr(l.days,u.days,d.days),balanceRef:$(l.balanceRef,u.balanceRef)?d.balanceRef:$(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:qr(l.planSamples,u.planSamples,d.planSamples,i),planHourBuckets:vo(V(l.planHourBuckets,u.planHourBuckets,d.planHourBuckets,!0),i),openrouterPriceHashes:V(l.openrouterPriceHashes,u.openrouterPriceHashes,d.openrouterPriceHashes),pricingHistory:Vo(u.pricingHistory,d.pricingHistory),historyReset:g??null},C=be(u.usageCursors);for(let[P,v]of Object.entries(be(d.usageCursors)))C[P]=Math.max(C[P]??0,v);Object.keys(C).length&&(k.usageCursors=C);let O=V(l.providerPriceHashes,u.providerPriceHashes,d.providerPriceHashes);O&&Object.keys(O).length&&(k.providerPriceHashes=O);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),Yr(k,r),k}function Yr(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(_o(e.config)!==n.fingerprint||!$(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(a=>!o(i.byProviderModel?.[a],r.byProviderModel?.[a]))))for(let a of new Set([...Object.keys(e.planHourBuckets??{}),...Object.keys(n.buckets)])){if(!fe(a))continue;let c=e.planHourBuckets?.[a]??{},l=Object.fromEntries(Object.entries(c).filter(([u])=>+u>=n.start&&+u<n.end)),d=n.buckets[a]??{};$(l,d)||(e.planHourBuckets[a]={...Object.fromEntries(Object.entries(c).filter(([u])=>+u<n.start||+u>=n.end)),...d},e.planSamples&&delete e.planSamples[a])}}}function di(e,t,o){return V(e,t,o)}import{join as hi}from"node:path";var mi=1,ki=180;function Vr(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=Qr(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}}var Mn=["antigravity","claude","codex","kimi","xai","workbuddy"],Zr=["sidebar","settings","both","off"],Jr=/^[a-z0-9][a-z0-9_-]{0,47}$/;function Xr(e){let t=typeof e=="string"?e.trim().toLowerCase():e;return t==="anthropic"?"claude":t}function gi(e){if(e===void 0)return!0;let t=Number(e);return/^\d{1,5}$/.test(e)&&t>=1&&t<=65535}function es(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),a=t.slice(r+1);return!s.includes(":")||!/^[0-9a-f:.]+$/.test(s)?!1:a===""||a.startsWith(":")&&gi(a.slice(1))}let o=t.match(/^(.*?)(?::(\d{1,5}))?$/);if(o===null||!gi(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 ts(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(a=>typeof a=="string").map(a=>Xr(a)).filter(a=>Mn.includes(a)))]:Mn.slice(),r=Array.isArray(o.allowedHosts)?[...new Set(o.allowedHosts.filter(a=>es(a)).map(a=>a.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:o.type!=="agy-link"&&typeof o.baseURL=="string"?o.baseURL.trim().replace(/\/+$/,""):"",enabled:o.enabled!==!1,display:Zr.includes(o.display)?o.display:"both",refreshMinutes:Number.isInteger(s)?Math.min(1440,Math.max(1,s)):15,includeProviders:i.length>0?i:Mn.slice(),allowedHosts:r,allowInsecureHttp:o.allowInsecureHttp===!0,antigravityOnlyGemini:o.antigravityOnlyGemini===!0}}function ns(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:Qn,peakWindows:Vn.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,hideCustomBalance:!1,hideBudget:!1,hideTodayCost:!1,modelStatistics:{},localSavings:zt(),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(jt.models).map(([e,t])=>[e,structuredClone(t)])),default:structuredClone(jt.default),providers:Object.fromEntries(Object.entries(oe).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:{...Zt},models:{},modelPlans:{}},historyDays:ki,fetchedAt:null,priceSource:"bundled"}}var bu=Object.keys(On());function Sn(e){let t=new Date(e),o=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${o(t.getMonth()+1)}-${o(t.getDate())}`}function In(e){return{date:e,input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0,byProviderModel:{},sessions:[]}}function os(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 is(e){let t=Number(e);return Number.isFinite(t)&&t>0?t:0}function kt(e){if(e===null||typeof e!="object")return null;for(let o of["input","output","cacheRead","cacheWrite","reasoning","calls","cost"])e[o]=is(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 bi(e){for(let t of Object.values(e))if(kt(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))kt(n)===null&&delete t.byProviderModel[o];if(!Array.isArray(t.sessions)){t.sessions=[];continue}t.sessions=t.sessions.filter(o=>kt(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))kt(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 rs(e){return e==="native"||e==="display"||qe(e)}function ss(e){return e?.adapter!=="openai-credits"?e:{adapter:e.adapter,enabled:e.enabled,display:e.display,refreshMinutes:e.refreshMinutes,label:e.label,labelEn:e.labelEn,unit:"USD",convertToDisplayCurrency:!1,allowInsecureHttp:!1,dashboardUrl:"https://platform.openai.com/settings/organization/billing/credit-grants",grantAmount:Number.isFinite(e.grantAmount)?Math.max(0,e.grantAmount):0,grantStart:typeof e.grantStart=="string"?e.grantStart.slice(0,10):"",grantExpiry:typeof e.grantExpiry=="string"?e.grantExpiry.slice(0,10):"",request:{url:"https://api.openai.com/v1/organization/costs",method:"GET",headers:{}},extract:{}}}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(oo),currency:"CNY"});let n=We(t,o);n.queryAccounts=Tn(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"&&!$e(f))for(let h of St)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 a=f=>typeof f=="number"&&Number.isFinite(f),c=(f,h,y)=>typeof f=="string"&&h.includes(f)?f:y;for(let[f,h]of Object.entries(t)){let y=n[f],R=typeof h;R==="boolean"&&typeof y!="boolean"||R==="number"&&!a(y)||R==="string"&&typeof y!="string"?n[f]=h:R==="object"&&h!==null&&y!==null&&typeof y=="object"&&f==="gatewayQuotas"&&Array.isArray(y)||R==="object"&&h!==null&&(y===null||typeof y!="object"||Array.isArray(y)!==Array.isArray(h))&&(n[f]=h)}n.locale=c(n.locale,["auto","zh","en"],"auto"),n.position=c(n.position,["dock","header","off"],"dock"),n.peakStyle=c(n.peakStyle,["compact","classic","progress"],"compact"),n.peakTimeDisplay=c(n.peakTimeDisplay,["both","countdown","switch"],"both"),n.priceMatch=c(n.priceMatch,["auto","exact"],"auto"),n.pricingCurrency=c(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=c(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=c(n.sessionListCostPeriod,["total","today"],"total"),n.hideOfficialBalance=n.hideOfficialBalance===!0,n.hideBudget=n.hideBudget===!0,n.hideTodayCost=n.hideTodayCost===!0,n.modelStatistics=jn(n.modelStatistics),n.localSavings=zt(n.localSavings);for(let f of["hideSessionCostHeader","hideSessionCostDock","hideTurnCost","hideCustomBalance","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=c(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=c(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],R={period:["today","history"],summary:["total","top"],position:["first","afterBalance","last"]}[f];return[f,R?R.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=c(n.sidebarStyle,["standard","compact","summary","icons"],"standard"),n.planQuotaStyle=c(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=_n(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=c(n.peakAlertTarget,["peak","offpeak","both"],"both"),n.peakAlertPosition=c(n.peakAlertPosition,["corner","center"],"corner"),n.peakAlertWebNotify=n.peakAlertWebNotify===!0,n.legacyAutoImportedAt=a(Number(n.legacyAutoImportedAt))&&Number(n.legacyAutoImportedAt)>0?Number(n.legacyAutoImportedAt):0,n.exchangeRateAuto=n.exchangeRateAuto!==!1,n.fxRates=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:"",(!a(n.exchangeRate)||n.exchangeRate<=0)&&(n.exchangeRate=t.exchangeRate),Array.isArray(n.peakWindows)?n.peakWindows=n.peakWindows.filter(f=>f!==null&&typeof f=="object"&&a(Number(f.start))&&a(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=a(p.amount)&&p.amount>=0?p.amount:100,p.period=c(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=c(m.display,["sidebar","settings","both","off"],"both"),m.source=c(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,rs(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=c(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=c(k.main,["rolling","weekly","monthly"],"rolling"),k.detail=k.detail!==!1;let C=n.customBalance??t.customBalance,O=(f,h)=>{let y=f??{},R={...["aliyun","tokenrhythm","openai-credits"].includes(y.adapter)?{adapter:y.adapter}:{},enabled:y.enabled===!0,display:c(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:Vr(y.dashboardUrl),unit:y.adapter==="tokenrhythm"?"CNY":c(y.unit,["USD","CNY","EUR","CREDITS"],h.unit),convertToDisplayCurrency:y.convertToDisplayCurrency===!0,allowInsecureHttp:y.allowInsecureHttp===!0};if(y.adapter==="openai-credits")return ss({...y,...R});if(y.request===null||typeof y.request!="object"||Array.isArray(y.request))R.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);R.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)?R.extract={...h.extract}:R.extract={...h.extract,...y.extract},Array.isArray(y.allowedHosts)){let F=y.allowedHosts.filter(D=>typeof D=="string"&&D.length>0);F.length>0&&(R.allowedHosts=F)}return R},N=O(C,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=ts(f);!Jr.test(h.id)||b.has(h.id)||h.type!=="agy-link"&&(h.type!=="cliproxyapi"||!ns(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=>O(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 T=n.corner;for(let f of["enabled","goRolling","goWeekly","goMonthly","budget"])T[f]=T[f]===!0||T[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:c(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=So(h.baseUrl);x[f].baseUrl=y??"",y===null&&(x[f].enabled=!1)}if(f==="workbuddy"&&(h.accountSource!==void 0&&(x[f].accountSource=c(h.accountSource,["auto","connect","xdpool"],"auto")),x[f].accountScope=c(h.accountScope,["current","all","selected"],"current"),x[f].accountIds=Array.isArray(h.accountIds)?[...new Set(h.accountIds.filter(Qt))].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=yo(h.orgId);x[f].orgId=y??"",y===null&&(x[f].enabled=!1),x[f].factoryPool=c(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 R=h.rates!==null&&typeof h.rates=="object"&&!Array.isArray(h.rates)?h.rates:{},F={};for(let[D,H]of Object.entries(R)){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),ae=Y(H.cachedInput),ce=Y(H.output);z===null||ae===null||ce===null||(F[D]={input:z,cachedInput:ae,output:ce})}x[f].rates=F}if(f==="volcengine"){let y=typeof h.accessKeyId=="string"?h.accessKeyId.trim():"",R=typeof h.apiKey=="string"?h.apiKey.trim():"";x[f].accessKeyId=y.length>0?y:R,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 re){let h=n.planBilling?.providers?.[f];U[f]=["auto","plan","api"].includes(h)?h:Zt[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 se={};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")&&(se[f]=h);let J=Object.fromEntries(Object.entries(n.planBilling?.modelPlans??{}).filter(([f,h])=>f.includes(":")&&re.includes(h))),L=[...new Set(Array.isArray(n.planBilling?.autoProviders)?n.planBilling.autoProviders.filter(f=>re.includes(f)):[...st(n)])];return n.planBilling={providers:U,models:se,modelPlans:J,autoProviders:L},n}var as={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"},yu=Object.keys(as);function yi(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))Pt(r,s)?(i[r]="",n=!0):i[r]=s;return n?{...e,request:{...t,headers:i}}:e}function Cn(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=yi(t.customBalance)),Array.isArray(t.customBalances)&&(t.customBalances=t.customBalances.map(yi)),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 At=[{id:"provider-catalog-2026-10-03",apply:Me},{id:"provider-catalog-2026-10-15",apply:Jn},{id:"provider-catalog-2026-10-28",apply:Xn},{id:"provider-catalog-2026-11-05",apply:eo},{id:"stepfun-catalog-2026-10-16",apply:to},{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")}}],wt=class e{constructor(t,o,n,i=[],r={}){this.pricingHistory=je(r.pricingHistory,t),this.config=t,Rn(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??mo,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,a])=>!["__proto__","constructor","prototype"].includes(s)&&typeof a=="string"&&/^[a-f0-9]{64}$/.test(a))),this.providerPriceHashes=Object.fromEntries(Object.entries(r.providerPriceHashes??{}).filter(([s,a])=>s.startsWith("opendesign:")&&typeof a=="string"&&/^[a-f0-9]{64}$/.test(a))),this.writeBase=this.snapshot()}get config(){return this._config}set config(t){this.pricingHistory&&mt(this.pricingHistory,t),this._config=Qo(t,this.pricingHistory)}static open(){let t=hi(Gt(),"storages","cost-meter"),o=hi(t,"ledger.json");return Fe(o,()=>e.load(o))}static load(t){let o=On(),n={},i=null,r=[...At.map(A=>A.id),"quota-token-window-v2"],s={},a={},c={},l={},d=null,u={},p=[],m,g=!1,k=!1,C=!1;try{let A=JSON.parse(Gr(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!==mi){try{pi(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 At)v.has(w.id)||(w.apply(P),r.push(w.id));o=xe(P),A.openrouterPriceHashes&&typeof A.openrouterPriceHashes=="object"&&!Array.isArray(A.openrouterPriceHashes)&&(c=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=bi(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)?a=A.planHourBuckets:Array.isArray(A.planRecentCalls)&&(a=tn(A.planRecentCalls)),k=!0}}catch(A){if(A?.code!=="ENOENT"){try{pi(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{wn(t,{config:Cn(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=An(t);if(A){let P=A.config;r=A.migrations;for(let v of At)r.includes(v.id)||(v.apply(P),r.push(v.id));o=xe(P),C=!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 O=new e(o,n,t,r,{planSamples:s,planHourBuckets:a,openrouterPriceHashes:c,providerPriceHashes:l,balanceRef:i,historyReset:d,usageCursors:u,writeReceipts:p,pricingHistory:m});O.legacyPricingHistory=g,O.quotaStatsNeedRepair=!r.includes("quota-token-window-v2"),O.quotaStatsNeedRepair&&(O.planSamples={}),(g||C)&&O.scheduleWrite();let N=ge(O.days);return N.length&&(N.includes(O.balanceRef?.date)&&(O.balanceRef=null),O.scheduleWrite()),O}account(t,o,n,i,r,s,a){if(this.closed)return;if(a!==void 0&&(!fo(a,i)||r!=="deepseek-official"||!po(o,a)))throw new Error("Invalid official web request fee");let c=hn(this.config,i,n,`${r||"deepseek"}:${o}`),l=ro(r,o,c.prices,{mode:c.priceMatch==="exact"?"exact":"auto",overrides:c.priceOverrides}),d=l.entry??{cacheHit:0,cacheMiss:0,output:0},u={enabled:["deepseek-peak","utc-peak"].includes(l.billingMode)&&c.peakEnabled===!0,effectiveAtMs:Date.parse(c.peakEffectiveAt),windows:c.peakWindows,holidays:c.peakHolidays},p=a?lo(a,i):l.priced?Ft(t,d,i,u):0,m=Bt(p,a?"CNY":l.currency,q(c).CNY),g=this.config.planBilling,k=st(this.config),C=a?"api":Eo(r,o,g,k,this.config.prices),O=C==="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=C==="plan"?Jt(r,g,o)??(Xt(r,o,this.config.prices)?"go":null):null,v={...s?{meter:s}:{},date:Sn(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:O,...Ct(m,O,c)}};return Ce(this,v)?(this.pendingAccounts.push(v),this.prune(),this.scheduleWrite(),!0):!1}advanceUsageCursor(t){let o={meter:t,skip:!0,recordedAt:Date.now()};Ce(this,o)&&(this.pendingAccounts.push(o),this.scheduleWrite())}prune(){let t=Math.max(7,Math.min(3650,Number(this.config.historyDays)||ki)),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:mi,config:Cn(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:fi(),at:Date.now()},this.scheduleWrite()}readDiskSnapshot(){let t=Be(this.path);if(t&&t===this.diskRevision)return this.writeBase;let o=li(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 At)(o.migrations??[]).includes(i.id)||i.apply(o.config??{});return{...o,config:Cn(xe(o.config)),days:bi(o.days??{}),balanceRef:o.balanceRef??null,migrations:o.migrations??[],planSamples:o.planSamples??{},planHourBuckets:o.planHourBuckets??tn(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(di(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(Oe(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,()=>{mt(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:Oe(this.writeBase,n,o,this.pendingAccounts,Date.now(),this.pendingPlanHourRepairs,{ownLocal:!0});yt(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();mt(this.pricingHistory,this.config);let t=this.snapshot(),o=this.pendingAccounts,n=o.length,i=this.pendingPlanHourRepairs,r=i.length,s=this.writeGeneration,a=fi();try{return this.backgroundWrite=this.startWrite({path:this.path,base:this.writeBase,local:t,transactionId:a,now:Date.now(),pending:o.slice(),repairs:i.slice(),revision:this.diskRevision,backupHistory:this.legacyPricingHistory},c=>{if(this.backgroundWrite=null,c.error){let u;try{u=this.readDiskSnapshot()}catch{}if(Z(u?.writeReceipts).includes(a))c={merged:u,revision:Be(this.path)};else{c.error.code==="EBUSY"?this.closed||this.scheduleWrite():this.fallbackWrite(c.error);return}}let l=this.pendingAccounts===o?o.slice(n):this.pendingAccounts,d=this.pendingPlanHourRepairs===i?i.slice(r):this.pendingPlanHourRepairs;if(c.ownDisk)this.writeReceipts=Z(c.writeReceipts),t.writeReceipts=this.writeReceipts.slice(),this.writeBase=t;else{let u=Oe(t,this.snapshot(),c.merged,l,Date.now(),d,{ownLocal:!0});this.adoptSnapshot(u),this.writeBase=c.merged}this.pendingAccounts=l,this.pendingPlanHourRepairs=d,this.pendingWrite=s!==this.writeGeneration||l.length>0||d.length>0,this.legacyPricingHistory=!1,this.diskRevision=c.revision,this.pendingWrite&&!this.closed&&this.scheduleWrite()}),this.backgroundWrite.promise}catch(c){return this.fallbackWrite(c),Promise.resolve()}}close(){if(this.backgroundWrite)return this.backgroundWrite.promise.then(()=>this.close());this.flush(5e3),this.closed=!0,this.writeTimer!==null&&(clearTimeout(this.writeTimer),this.writeTimer=null)}sumDays(t){let o=In(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 a=o.byProviderModel[r]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};o.byProviderModel[r]={..._e({...Qe(a)},s),input:a.input+(s.input??0),output:a.output+(s.output??0),cacheRead:a.cacheRead+(s.cacheRead??0),cacheWrite:a.cacheWrite+(s.cacheWrite??0),reasoning:a.reasoning+(s.reasoning??0),calls:a.calls+(s.calls??0),cost:a.cost+(s.cost??0),apiCost:(a.apiCost??0)+(s.apiCost??s.cost??0)}}}return o.date=t===void 0?"total":t,o}sumRange(t,o){let n=In(`${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,a]of Object.entries(r.byProviderModel??{})){let c=n.byProviderModel[s]??{input:0,output:0,cacheRead:0,cacheWrite:0,reasoning:0,calls:0,cost:0,apiCost:0};n.byProviderModel[s]={..._e({...Qe(c)},a),input:c.input+(a.input??0),output:c.output+(a.output??0),cacheRead:c.cacheRead+(a.cacheRead??0),cacheWrite:c.cacheWrite+(a.cacheWrite??0),reasoning:c.reasoning+(a.reasoning??0),calls:c.calls+(a.calls??0),cost:c.cost+(a.cost??0),apiCost:(c.apiCost??0)+(a.apiCost??a.cost??0)}}}return n}today(){let t=Sn(Date.now()),o=this.days[t];return o===void 0?In(t):this.copyDay(o)}todayOfficialCost(){return os(this.days[Sn(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 Ai=e=>{try{let t=ls(e,{bigint:!0});return`${t.ino}:${t.mtimeNs}:${t.size}`}catch(t){if(t.code==="ENOENT")return null;throw t}},{path:ze,base:wi,local:ye,pending:us,repairs:Mi,revision:ds,backupHistory:ps,transactionId:fs,now:hs,port:xn,signal:Si,lockId:ms}=cs;try{let e=Fe(ze,()=>{let t=Ai(ze)===ds,o=ge(ye.days);o.includes(ye.balanceRef?.date)&&(ye.balanceRef=null);let n=t&&!Mi.length&&!o.length,i=ye;if(!n){let r=new wt(ye.config,{},ze,[],{pricingHistory:ye.pricingHistory});r.writeBase=wi,i=Oe(wi,ye,r.readDiskSnapshot(),us,hs,Mi,{ownLocal:!0})}return i.writeReceipts=Z([...i.writeReceipts??[],fs]),yt(ze,i,ps),{ownDisk:n,...n?{}:{merged:i},writeReceipts:i.writeReceipts,revision:Ai(ze)}},5e3,ms);xn.postMessage(e)}catch(e){xn.postMessage({error:{message:String(e?.message??e),code:e?.code}})}finally{Atomics.store(Si,0,1),Atomics.notify(Si,0),xn.close()}