codex-cost.html 4.46 KB
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Codex API 等价费用估算</title>
<style>:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --border: #d8dee9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.page {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}
.hero { padding: 8px 0 18px; }
h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: 0;
}
.hero p {
  margin: 8px 0 18px;
  color: var(--muted);
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.meta-grid div,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.meta-grid div {
  padding: 12px;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 700;
}
.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-bottom: 5px;
}
.panel {
  padding: 18px;
  margin-top: 18px;
}
h2 {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: 0;
}
.chart {
  width: 100%;
  height: auto;
  display: block;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
th:first-child, td:first-child { text-align: left; }
.notes {
  color: var(--muted);
  margin: 0;
}
.notes li { margin: 6px 0; }
@media (max-width: 760px) {
  .page { width: min(100vw - 20px, 1080px); padding-top: 18px; }
  .meta-grid { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}</style>
</head>
<body>
<main class="page">
<header class="hero">
<h1>Codex API 等价费用估算</h1>
<p>时间窗口: 2026-05-20T00:00:00+08:00 -> 2026-05-20T10:02:06.956313+08:00</p>
<div class="meta-grid">
<div><span>API 等价金额</span>$3.56</div>
<div><span>Codex Credits</span>88.91</div>
<div><span>Total Tokens</span>4,778,002</div>
<div><span>Reasoning</span>2,308</div>
<div><span>数据来源</span>/Users/yuehu/.codex</div>
<div><span>Generated</span>2026-05-20T10:02:07+08:00</div>
</div>
</header>
<section class="panel"><h2>费用构成</h2><svg class="chart" viewBox="0 0 920 230" role="img" aria-label="费用构成">
<text x="22" y="50" fill="#1f2937" font-size="15">非缓存 input</text>
<rect x="150" y="28" width="172.91" height="30" rx="4" fill="#0f766e" />
<text x="334.91" y="49" fill="#1f2937" font-size="15">$0.57</text>
<text x="22" y="108" fill="#1f2937" font-size="15">Cached input</text>
<rect x="150" y="86" width="700.00" height="30" rx="4" fill="#2563eb" />
<text x="862.00" y="107" fill="#1f2937" font-size="15">$2.32</text>
<text x="22" y="166" fill="#1f2937" font-size="15">Output</text>
<rect x="150" y="144" width="199.79" height="30" rx="4" fill="#f59e0b" />
<text x="361.79" y="165" fill="#1f2937" font-size="15">$0.66</text>
</svg>
<div class="legend"><span><i style="background:#0f766e"></i>非缓存 input: 16.1%</span><span><i style="background:#2563eb"></i>Cached input: 65.3%</span><span><i style="background:#f59e0b"></i>Output: 18.6%</span></div></section>
<section class="panel"><h2>明细</h2><table>
<thead><tr><th>类型</th><th>Tokens</th><th>单价</th><th>美元估算</th><th>Codex Credits</th></tr></thead>
<tbody>
<tr><td>非缓存 input</td><td>114,644</td><td>$5 / 1M</td><td>$0.57</td><td>14.33</td></tr>
<tr><td>Cached input</td><td>4,641,280</td><td>$0.5 / 1M</td><td>$2.32</td><td>58.02</td></tr>
<tr><td>Output</td><td>22,078</td><td>$30 / 1M</td><td>$0.66</td><td>16.56</td></tr>
<tr><td><strong>合计</strong></td><td><strong>4,778,002</strong></td><td>-</td><td><strong>$3.56</strong></td><td><strong>88.91</strong></td></tr>
</tbody>
</table></section>
<section class="panel"><h2>说明:</h2><ul class="notes">
<li>这是基于本机 Codex token_count 日志的 API 等价估算,不代表订阅真实账单。</li>
<li>Reasoning token 只做展示,已经包含在 output 口径里,不重复计费。</li>
<li>模型或 rate card 变化时,可以通过费率参数调整单价。</li>
</ul></section>
</main>
</body>
</html>