provider-cost-comparison
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrice Your Real Usage Mix Against Other Providers
将您的真实用量组合与其他提供商进行比价
Price-card comparisons lie by omission: a provider that halves the per-token price and lacks cache discounts can cost more on a cache-heavy coding workload. This skill prices the user's own month of usage, with its real input/output/cache mix, under each candidate. It is read-only on the platform. Locally it writes a trace export while it works and deletes it again, and leaves one report file behind.
仅比较价格表往往会因遗漏而失真:将单 Token 价格减半却没有缓存折扣的提供商,在 cache 密集型编程工作负载上反而可能成本更高。本 skill 会使用用户自己当月的真实 input/output/cache 组合,按照每个候选提供商的价格重新计价。它在平台上为只读操作。在本地工作时,它会写入一份 trace 导出文件,完成后再次删除,并最终保留一个报告文件。
Step 1: Set up the LangWatch CLI
第 1 步:设置 LangWatch CLI
Use the CLI for everything: documentation (, ) and platform operations (prompts, scenarios, evaluators, datasets, monitors, traces, analytics). Install it once with , then run the binary directly; an unpinned re-resolves the package from the registry on every run.
langwatchlangwatch docs ...langwatch scenario-docs ...npm install -g langwatchlangwatchnpx langwatchPersonal coding-agent usage needs ; a team or application project needs on the read commands.
langwatch login --device--project <slug>Use to read documentation as Markdown. Some useful entry points:
langwatch docs <path>bash
langwatch docs # Docs index
langwatch docs integration/python/guide # Python integration
langwatch docs integration/typescript/guide # TypeScript integration
langwatch docs prompt-management/cli # Prompts CLI
langwatch scenario-docs # Scenario docs indexDiscover commands with and . List and get commands accept for machine-readable output. Every list command takes to cap the rows and to read part of the answer. A paginated list answers with an envelope, so count its rows through the row array (), and read how many there are in all at . Bare counts the fields of the envelope, not the rows. Read the docs first instead of guessing SDK APIs or CLI flags.
langwatch --helplangwatch <subcommand> --help--format json--limit <n>--jq <expr>--jq '.traces | length'.pagination.total--jq lengthIf no shell is available, fetch the same Markdown over plain HTTP. Append to any docs path (e.g. https://langwatch.ai/docs/integration/python/guide.md). Index: https://langwatch.ai/docs/llms.txt. Scenario index: https://langwatch.ai/scenario/llms.txt
.mdIf anything fails or confuses you while following this skill (broken commands, docs that do not match reality, errors you had to work around), ask the user for permission and run with a and (or ) to send it to the LangWatch team, and it directly shapes what gets fixed. No login or API key needed. Nothing is sent without , and prints the exact payload without sending anything. The title, summary and transcript are scrubbed locally first, by pattern: secrets and API keys, plus email addresses, phone numbers, card numbers and public IPv4 addresses. Anything no pattern matches is sent as written, including a contact address passed with . With , always run first and let the user read the payload, because a transcript carries content they never reviewed. explains the options.
npx --yes langwatch report --user-approved--title--summary--session <transcript.jsonl>--user-approved--dry-run--email--session--dry-runnpx --yes langwatch report --help所有操作都使用 CLI:文档(、)和平台操作(prompts、scenarios、evaluators、datasets、monitors、traces、analytics)。只需安装一次 ,然后直接运行 binary;未固定版本的 每次运行都会从 registry 重新解析软件包。
langwatchlangwatch docs ...langwatch scenario-docs ...npm install -g langwatchlangwatchnpx langwatch个人 coding-agent 使用场景需要执行 ;团队或应用项目则需在只读命令中加上 。
langwatch login --device--project <slug>使用 以 Markdown 格式阅读文档。常用入口包括:
langwatch docs <path>bash
langwatch docs # Docs index
langwatch docs integration/python/guide # Python integration
langwatch docs integration/typescript/guide # TypeScript integration
langwatch docs prompt-management/cli # Prompts CLI
langwatch scenario-docs # Scenario docs index使用 和 查找命令。list 和 get 命令接受 ,可获得机器可读的结果。所有 list 命令都接受 来限制返回行数,并接受 来读取结果的一部分。分页 list 会返回一个外层封装,因此应通过 row 数组统计行数(),并通过 读取总行数。单独使用 统计的是外层封装的字段数,而不是行数。请先阅读文档,不要靠猜测来推断 SDK API 或 CLI flag。
langwatch --helplangwatch <subcommand> --help--format json--limit <n>--jq <expr>--jq '.traces | length'.pagination.total--jq length如果没有可用的 shell,可以通过普通 HTTP 获取相同的 Markdown。给任意文档路径追加 (例如 https://langwatch.ai/docs/integration/python/guide.md)。索引:https://langwatch.ai/docs/llms.txt。Scenario 索引:https://langwatch.ai/scenario/llms.txt
.md如果执行此 skill 的过程中出现任何失败或令人困惑的情况(命令失效、文档与实际情况不符、需要绕过错误),请先征得用户许可,然后运行 ,并提供 和 (或 ),将问题发送给 LangWatch 团队;这会直接影响后续修复的内容。无需登录或使用 API key。没有 就不会发送任何内容,而 会在不发送的情况下打印确切的 payload。title、summary 和 transcript 会先在本地依据模式进行清理,包括 secrets、API keys、email 地址、电话号码、卡号和公开 IPv4 地址。任何未匹配到模式的内容都会原样发送,包括通过 传入的联系地址。使用 时,务必先运行 并让用户阅读 payload,因为 transcript 可能包含他们从未审查过的内容。 会说明各个选项。
npx --yes langwatch report --user-approved--title--summary--session <transcript.jsonl>--user-approved--dry-run--email--session--dry-runnpx --yes langwatch report --helpStep 2: Export the Real Mix
第 2 步:导出真实用量组合
Settle two things before running anything, and hold both for the whole analysis.
The window. and both default to the last 7 days, so a report about a month has to state the window itself. Compute one start date and one end date, 30 days back to now unless the user names another window, and pass the same pair to every command.
analytics querytrace exportThe scope. covers the whole project and has no origin filter, while takes . Mixing them silently compares application traffic in the totals against coding-agent traffic in the breakdown. When the question is about coding-agent usage, scope the export with and build every priced number from that export. Use the analytics calls only as a project-wide cross-check, and label them that way in the report. When the question is about the whole project, drop and the two agree by construction.
analytics querytrace export--origin--origin coding_agent--originbash
langwatch analytics query --metric total-tokens --group-by metadata.model --format json \
--start-date <start> --end-date <end>
langwatch analytics query --metric total-cost --group-by metadata.model --format json \
--start-date <start> --end-date <end>
langwatch trace export --format jsonl --origin coding_agent --limit 20000 \
--start-date <start> --end-date <end> -o traces.jsonl--limitExported 20000 traces (48213 total)--limitDelete once the analysis is done.
traces.jsonlCollect the distinct values from the export and pull the per-call rows, because the cache split lives there:
metadata.thread_idbash
langwatch session events <sessionId> --format jsonCompute, per model: input tokens, output tokens, cache-read tokens, cache-creation tokens, and the totals over the window you exported. The cache-read share is the single most important number of the whole analysis; on coding agents it is often the large majority of all input.
开始运行前先确定两件事,并在整个分析过程中保持一致。
时间窗口。 和 默认都使用最近 7 天,因此有关一个月的报告必须明确说明时间窗口。计算一个开始日期和一个结束日期;除非用户指定了其他窗口,否则使用从现在向前推 30 天,并将同一对日期传递给每个命令。
analytics querytrace export范围。 覆盖整个项目,且没有 origin filter,而 接受 。如果混用两者,就会悄无声息地将总量中的应用流量与明细中的 coding-agent 流量进行比较。当问题关注 coding-agent 用量时,应使用 限定导出范围,并基于该导出文件计算所有定价数字。Analytics 调用只能作为项目级交叉验证,并在报告中明确标注。当问题关注整个项目时,省略 ,这样两者按定义就是一致的。
analytics querytrace export--origin--origin coding_agent--originbash
langwatch analytics query --metric total-tokens --group-by metadata.model --format json \
--start-date <start> --end-date <end>
langwatch analytics query --metric total-cost --group-by metadata.model --format json \
--start-date <start> --end-date <end>
langwatch trace export --format jsonl --origin coding_agent --limit 20000 \
--start-date <start> --end-date <end> -o traces.jsonl--limitExported 20000 traces (48213 total)--limit分析完成后删除 。
traces.jsonl从导出文件中收集不同的 值,并获取每次调用的明细行,因为 cache 拆分信息就在其中:
metadata.thread_idbash
langwatch session events <sessionId> --format json按模型计算 input Token、output Token、cache-read Token、cache-creation Token,以及导出时间窗口内的总量。cache-read 占比是整个分析中最重要的数字;在 coding agent 中,它通常占全部 input 的绝大多数。
Step 3: Fetch Current Prices
第 3 步:获取当前价格
Fetch the candidates' price pages at analysis time and cite them; never price from memory, the numbers churn monthly. For each candidate record: input price, output price, cache-read price, cache-write price (some providers price a write above fresh input, some price it the same, some offer no caching at all), the cache-storage price and its unit if the candidate bills cache residency by time, the default cache lifetime, and the context window.
Cache pricing has three shapes and they do not reprice the same way: a write premium and no storage charge, a storage charge by token-hour with a cheap or free write, or no cache at all. Record which shape each candidate uses, because Step 4 needs it.
Candidates come from the user; when they name none, take the current obvious ones for the workload's model class and say why those.
在分析时获取候选提供商的价格页面并引用;绝不能凭记忆定价,因为这些数字每月都会变化。对每个候选记录:input 价格、output 价格、cache-read 价格、cache-write 价格(有些提供商的 write 价格高于全新 input,有些与其相同,有些则完全不支持 cache)、cache-storage 价格及其计费单位(如果候选按时间对 cache 驻留收费)、默认 cache 生命周期以及上下文窗口。
Cache 定价有三种形式,它们的重新计价方式各不相同:write 溢价但不收取存储费、按 token-hour 收取存储费且 write 价格很低或免费,以及完全不支持 cache。记录每个候选采用的形式,因为第 4 步需要使用这些信息。
候选项由用户提供;如果用户没有指定,则选择当前该工作负载所属模型类别下显而易见的候选,并说明选择理由。
Step 4: Reprice and Compare
第 4 步:重新计价并比较
For each candidate, reprice the same mix:
- Direct repricing: the same tokens at the candidate's rates, cache split preserved where the candidate has caching. A candidate that bills cache residency by time needs a storage line as well, because tokens alone do not price it: estimate the residency of each session from its own call timestamps, from the first call that writes the cache to the last call that reads it, cap each stretch at the candidate's cache lifetime, and multiply the cached token count by the elapsed time and the storage rate. State the residency assumption next to the number. When the exported rows carry no usable timestamps, do not publish a direct row that silently omits a real charge: fall back to the no-cache row for that candidate and label it as an upper bound.
- No-cache degradation: for a candidate without caching, cache reads and cache writes both rebill as fresh input, because the candidate is sent the same context in full on every call. Add the two together, do not price the writes at a write rate the candidate does not have, and state this row separately; it is the row a sticker-price comparison leaves out.
- Sensitivity: recompute at the observed cache-hit share, at half of it, and at zero, so the conclusion survives a workload change.
- The non-price caveats, named not judged: a different model is a different model. State window differences and any capability constraint the user's workload obviously depends on (tool calling, long context), and leave the quality judgment to the user; this is a cost analysis.
对每个候选,使用相同的用量组合重新计价:
- 直接重新计价:按照候选提供商的费率计算相同 Token;如果候选支持 cache,则保留 cache 拆分。对于按时间收取 cache 驻留费用的候选,还需要增加存储费用项,因为仅靠 Token 数量无法计算该费用:根据每个 session 自身的调用时间戳估算驻留时间,从首次写入 cache 的调用到最后一次读取 cache 的调用;将每段驻留时间截断至候选的 cache 生命周期上限;再用缓存 Token 数乘以经过时间和存储费率。将驻留时间假设写在对应数字旁。当导出行没有可用时间戳时,不要发布一个悄悄遗漏真实费用的“直接重新计价”行:应回退到该候选的“无 cache”行,并将其标记为上限。
- 无 cache 降级:对于不支持 cache 的候选,cache read 和 cache write 都应按全新的 input 重新计费,因为每次调用都会把完整上下文发送给候选。将两者相加,不要按候选并不存在的 write 费率给写入计费;并单独标明这一行;这正是仅比较标价时会遗漏的一行。
- 敏感性:在观察到的 cache-hit 占比、其一半和零的情况下分别重新计算,使结论在工作负载发生变化后仍然成立。
- 明确指出但不评判非价格因素:不同模型就是不同模型。说明时间窗口差异,以及用户工作负载明显依赖的任何能力限制(tool calling、long context),并将质量判断留给用户;这是一项成本分析。
Step 5: Report
第 5 步:编写报告
Write a single self-contained in the project root (inline CSS, no external assets) with:
provider-cost-report.html- The answer first: "your usage from to
<start>cost $X; under the candidate the same usage prices at $Y" with the exported window and the cache assumption named in the same sentence<end> - The mix table: tokens per model per kind (input, output, cache read, cache write)
- The comparison table: one row per candidate, direct and no-cache columns, with the price-page links and their fetch date
- The sensitivity chart or table across cache-hit shares
- A short "what would have to be true" closing: the conditions under which switching saves the claimed amount
State the headline numbers directly in the conversation too.
在项目根目录编写一个自包含的 (使用内联 CSS,不引用外部资源),其中包括:
provider-cost-report.html- 先给出答案:“您在 至
<start>期间的用量花费 $X;按照该候选提供商的价格,相同用量的价格为 $Y”,并在同一句中注明导出的时间窗口和 cache 假设<end> - 用量组合表:按模型和类型列示 Token 数量(input、output、cache read、cache write)
- 比较表:每个候选占一行,包含直接重新计价和无 cache 两列,并附价格页面链接及获取日期
- 不同 cache-hit 占比下的敏感性图表
- 以“需要满足哪些条件”简短收尾:说明切换后要节省所称金额需要满足的条件
也要在对话中直接说明核心数字。
Common Mistakes
常见错误
- Do NOT compare on input and output prices alone; on coding agents the cache columns decide the answer.
- Do NOT use remembered prices; fetch the price page and cite it with a date.
- Do NOT present the repriced number as the migration outcome; it prices the same usage, and a different model changes the usage. Say so once, clearly.
- Do NOT ignore cache-write pricing; providers that bill writes above fresh input make rebuild-heavy workloads more expensive, not less.
- Do NOT price a cache on token rates alone when the candidate charges for residency by time. A storage charge does not appear in the token mix, so leaving it out makes that candidate look cheaper than it is.
- Do NOT mix application traffic and coding-agent traffic in one mix when the question is about one of them. The export scopes with ; the analytics totals cannot, so never take a priced number from an analytics call while the export is scoped.
--origin - If the CLI returns an error, report the user-facing consequence, not the raw error text.
- 不要只比较 input 和 output 价格;在 coding agent 中,cache 列决定了最终结果。
- 不要使用记忆中的价格;应获取价格页面,并连同日期一起引用。
- 不要把重新计价后的数字呈现为迁移结果;它计算的是相同用量,而更换模型会改变用量。请明确说明一次即可。
- 不要忽略 cache-write 定价;对于将 write 价格设为高于全新 input 的提供商,大量重建 cache 的工作负载会变得更贵,而不是更便宜。
- 当候选按时间收取 cache 驻留费用时,不要只按 Token 费率给 cache 定价。存储费用不会出现在 Token 用量组合中,因此忽略它会让候选显得比实际更便宜。
- 当问题关注某一种流量时,不要把应用流量和 coding-agent 流量混入同一个用量组合。Export 可通过 限定范围,而 analytics 总量无法限定,因此绝不能在 export 已限定范围时使用 analytics 调用中的数字进行定价。
--origin - 如果 CLI 返回错误,应报告对用户造成的影响,而不是原始错误文本。