narev-update-llm-pricing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUpdate LLM pricing in the local repo
更新本地仓库中的LLM价格
This skill is not a second API spec — it describes what you can implement using the listing API that documents (): paginate, map each row to your schema, and write a committed file. For path/query/body contracts, /, and calculate, use . You do not need the Narev SDK or Vercel AI SDK — any HTTP client and file I/O in the repo's language is enough.
lookup-llm-pricingGET https://www.narev.ai/api/models/pricing402404POSTlookup-llm-pricing该技能不是第二个API规范——它描述了如何使用文档中介绍的列表API()来实现功能:分页查询,将每一行映射到你的 schema,并写入一个已提交的文件。关于路径/查询/请求体约定、/状态码以及**计算功能,请使用。你不需要**Narev SDK或Vercel AI SDK——只需仓库所用语言中的任意HTTP客户端和文件I/O即可。
lookup-llm-pricingGET https://www.narev.ai/api/models/pricing402404POSTlookup-llm-pricingWhen to use this skill
何时使用该技能
- "Update LLM model price snapshot present in your project"
- "Refresh committed pricing registry with the latest rates (find where the project stores rates, or add a file or script if nothing exists yet)."
If the user only needs how the API works or cost for one call ( calculate), point them at .
POSTlookup-llm-pricing- "更新项目中现有的LLM模型价格快照"
- "用最新费率刷新已提交的定价注册表(查找项目存储费率的位置,如果尚未存在则添加文件或脚本)。"
如果用户仅需要了解API的工作方式或单次调用的成本(计算),请引导他们使用。
POSTlookup-llm-pricingInputs you need
所需输入
The Narev pricing API is public. No API key or bearer token is required.
- Target file path and format (TypeScript object, JSON, YAML, Python module, etc.). Confirm before overwriting.
- Scope: which values to refresh (API slugs), or the full catalog. Use the
providerquery parameter; omit it to fetch everything (paginate untilprovider).page > meta.total_pages - Local units: the API returns USD per token. Some codebases store USD per million tokens — multiply by only when writing that shape, and document it in the script.
1_000_000
Narev定价API是公开的,不需要API密钥或Bearer令牌。
- 目标文件路径和格式(TypeScript对象、JSON、YAML、Python模块等)。覆盖前请确认。
- 范围:要刷新的值(API别名),或完整目录。使用
provider查询参数;省略该参数则获取所有内容(分页直到provider)。page > meta.total_pages - 本地单位:API返回的是每令牌美元价格。有些代码库存储的是每百万令牌美元价格——仅当需要写入这种格式时才乘以,并在脚本中记录这一点。
1_000_000
API response shape (what you read)
API响应结构(读取内容)
Paginate with , (max ), and optional , , , . Response: .
pagelimit1000providermodel_idsearchsubprovider{ data: ModelPricingEntry[], meta: { total_pages, ... } }Each row has , , , and . When is , skip the row (enterprise-only or unavailable).
model_idprovidersubproviderpricingpricingnullUseful fields (snake_case, USD per unit unless noted):
pricing| Field | Meaning |
|---|---|
| Input token |
| Output token |
| Cached input tokens |
| Reasoning tokens |
| Flat per request |
| Per web-search invocation |
| Fraction |
price_imageprice_audioprice_input_audio_cache使用、(最大值)以及可选的、、、进行分页。响应格式:。
pagelimit1000providermodel_idsearchsubprovider{ data: ModelPricingEntry[], meta: { total_pages, ... } }每一行包含、、和。当为时,跳过该行(仅限企业版或不可用)。
model_idprovidersubproviderpricingpricingnull实用的字段(蛇形命名法,除非特别说明,否则单位为每令牌美元):
pricing| 字段 | 含义 |
|---|---|
| 输入令牌 |
| 输出令牌 |
| 缓存输入令牌 |
| 推理令牌 |
| 每次请求固定费用 |
| 每次网页搜索调用费用 |
| 折扣比例 |
可能会出现、、等字段——仅当本地注册表支持时才保留这些字段。
price_imageprice_audioprice_input_audio_cacheMapping to your registry (default path)
映射到你的注册表(默认路径)
-
Inspect the repo: find the existing pricing map or config and match key style (only vs
model_id), units (per token vs per 1M tokens), and which fields the app reads.provider/model_id -
Implement a script in the project's language (,
scripts/update-pricing.ts, etc.) that:scripts/update_pricing.py- Loops pages until done.
- Optionally filters by one or more query values per run (or omit for full catalog).
provider - Merges or replaces according to product needs: common pattern is merge — keep unrelated providers in file, overwrite keys returned by this fetch.
- Writes a generated-file banner when the format allows.
- Exits non-zero on HTTP errors so CI can fail visibly.
-
Document the run command in a comment or README snippet (,
pnpm tsx scripts/..., etc.).uv run python scripts/...
-
检查仓库:找到现有的定价映射或配置,匹配键样式(仅vs
model_id)、单位(每令牌 vs 每百万令牌)以及应用读取的字段。provider/model_id -
用项目所用语言实现一个脚本(、
scripts/update-pricing.ts等),该脚本需:scripts/update_pricing.py- 循环分页直到完成。
- 可选地按每次运行的一个或多个查询值进行过滤(或省略以获取完整目录)。
provider - 根据产品需求进行合并或替换:常见模式是合并——保留文件中无关的提供商,覆盖此次获取返回的键。
- 若格式允许,写入生成文件的注释头。
- HTTP错误时返回非零退出码,以便CI可以明显地失败。
-
在注释或README片段中记录运行命令(、
pnpm tsx scripts/...等)。uv run python scripts/...
Reference pattern: merge into an existing TS registry (strip + regenerate block)
参考模式:合并到现有TS注册表(剥离并重新生成块)
Repos like Mission Control sometimes keep in TypeScript with / . Adapt paths and regex to the real file:
MODEL_PRICINGinputPerMTokoutputPerMTok- Fetch with repeated per catalog you care about, or no
providerfor full catalog.provider - Convert API per-token rates to per-million: , same for completion.
inputPerMTok = price_prompt * 1_000_000 - Key both and
'model_id'if the app resolves either style.'provider/model_id' - Parse the existing block, merge new rows into the dict, sort keys if you want stable diffs, replace the block with , write the file.
String.replace
This is illustrative — match the project's exact types and formatting.
像Mission Control这样的仓库有时会在TypeScript中保留,包含 / 。根据实际文件调整路径和正则表达式:
MODEL_PRICINGinputPerMTokoutputPerMTok- 按你关心的每个目录重复使用进行获取,或不指定
provider以获取完整目录。provider - 将API的每令牌费率转换为每百万令牌:,完成令牌同理。
inputPerMTok = price_prompt * 1_000_000 - 如果应用支持两种解析方式,同时使用和
'model_id'作为键。'provider/model_id' - 解析现有块,将新行合并到字典中,若需要稳定的差异则对键排序,用替换块,写入文件。
String.replace
这只是示例——请匹配项目的确切类型和格式。
Reference pattern: @ai-billing/core
offline resolver (optional)
@ai-billing/core参考模式:@ai-billing/core
离线解析器(可选)
@ai-billing/coreIf the user already uses the Narev SDK, expects in USD per token (do not multiply to per-million for the SDK map). Map API → SDK like this:
createObjectPriceResolverModelPricingNarev API ( | SDK ( |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
Output keyed by how the app resolves models (see multi-provider note below). Then:
Record<string, ModelPricing>ts
import { createObjectPriceResolver } from "@ai-billing/core";
import { pricing } from "./pricing";
export const priceResolver = createObjectPriceResolver(pricing);如果用户已经在使用Narev SDK,期望的是以每令牌美元为单位的(不要为SDK映射乘以百万)。按如下方式将API映射到SDK:
createObjectPriceResolverModelPricingNarev API ( | SDK ( |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
输出以应用解析模型的方式为键的(见下文多提供商说明)。然后:
Record<string, ModelPricing>ts
import { createObjectPriceResolver } from "@ai-billing/core";
import { pricing } from "./pricing";
export const priceResolver = createObjectPriceResolver(pricing);Workflow (agent checklist)
工作流程(代理检查清单)
1. Confirm scope and target file
1. 确认范围和目标文件
Providers, model subset (if any), output path, and whether units are per token or per 1M in the file.
确认提供商、模型子集(如有)、输出路径,以及文件中的单位是每令牌还是每百万令牌。
2. Add or update a snapshot script
2. 添加或更新快照脚本
Use the repo's language and dependencies ( / / / ). Paginate . Transform into the local schema. Prefer idempotent writes and small, reviewable diffs.
fetchhttpxrequestsurllibGET https://www.narev.ai/api/models/pricing使用仓库的语言和依赖( / / / )。分页调用。转换为本地schema。优先使用幂等写入和易于审核的小差异。
fetchhttpxrequestsurllibGET https://www.narev.ai/api/models/pricing3. Run it
3. 运行脚本
Use the project's package runner. Do not assume or — check , , etc. Inspect the diff before committing.
pnpmtsxpackage.jsonpyproject.toml使用项目的包运行器。不要假设使用或——检查、等。提交前检查差异。
pnpmtsxpackage.jsonpyproject.toml4. Wire into the app (only if applicable)
4. 接入应用(仅适用于相关场景)
For custom registries, point the app at the updated file or import. For , swap for as above.
@ai-billing/corecreateNarevPriceResolvercreateObjectPriceResolver对于自定义注册表,将应用指向更新后的文件或导入。对于,按上述方式将替换为。
@ai-billing/corecreateNarevPriceResolvercreateObjectPriceResolver5. Schedule refreshes (optional)
5. 定期刷新(可选)
CI on a schedule that runs the script and opens a PR keeps rates fresh with human review.
通过CI定期运行脚本并创建PR,可以在人工审核的前提下保持费率更新。
Constraints and edge cases
约束和边缘情况
- Multi-provider models share a . If you need per-provider rates, key with
model_id(and align lookup). Otherwise last write wins for bareprovider/model_id.model_id - Skip .
pricing: null - is a fraction (
pricing_discount= 10% off). Pass through if your registry supports it; many simple token maps ignore it.0.1 - API = USD per token. Scale to per-1M (or per-1K) only in your script when the destination format requires it — do not double-scale.
- Snapshot drift. Re-run before releases that depend on accurate math.
- Generated files. Banner comment + formatter ignore if needed.
- 多提供商模型共享同一个。如果需要按提供商区分费率,使用
model_id作为键(并对齐查找方式)。否则,最后写入的内容将覆盖裸provider/model_id的条目。model_id - 跳过的行。
pricing: null - 是比例值(
pricing_discount= 10%折扣)。如果你的注册表支持则保留;许多简单的令牌映射会忽略它。0.1 - API返回的是每令牌美元价格。仅当目标格式要求时才在脚本中转换为每百万(或每千)令牌价格——不要重复转换。
- 快照偏差。在依赖准确计算的版本发布前重新运行脚本。
- 生成文件。若需要,添加注释头并设置格式化工具忽略该文件。
Reference
参考资料
- List pricing API:
/platform/api-reference/endpoint/pricing/list-model-pricing - SDK overview (optional):
/sdk/ai-billing/index - :
createObjectPriceResolver/sdk/ai-billing/reference/core/typedoc/functions/createObjectPriceResolver - (live):
createNarevPriceResolver/sdk/ai-billing/reference/core/typedoc/functions/createNarevPriceResolver - :
ModelPricing/sdk/ai-billing/reference/core/typedoc/interfaces/ModelPricing
- 列表定价API:
/platform/api-reference/endpoint/pricing/list-model-pricing - SDK概述(可选):
/sdk/ai-billing/index - :
createObjectPriceResolver/sdk/ai-billing/reference/core/typedoc/functions/createObjectPriceResolver - (实时):
createNarevPriceResolver/sdk/ai-billing/reference/core/typedoc/functions/createNarevPriceResolver - :
ModelPricing/sdk/ai-billing/reference/core/typedoc/interfaces/ModelPricing