允许 [[custom_models]] 的价格声明人民币币种
Before you start
- [x] I searched existing issues and this is not a duplicate. 我已搜索过现有 issue。
What problem does this solve? 要解决什么问题?
概述
[[custom_models]] 允许用户通过 cost 为具体模型声明每百万 token 的价格,
但这些费率始终被按美元(USD)解释。
- 直接填人民币数值会被当成美元计费(
8变成$8.00); - 设置
cost_currency = "cny"时,费用估算仍然为空,因为自定义报价只携带 美元费率,显示层会回退到美元。
复现步骤
- 把 OpenAI 兼容 provider 指向人民币计价的网关:
[providers.openai]
base_url = "https://token.sensenova.cn/v1"
model = "deepseek-flash"
2. 按网关实际(人民币)价格声明:
[[custom_models]]
provider = "openai"
base_url = "https://token.sensenova.cn/v1"
id = "deepseek-flash"
cost = { input = 2.0, output = 8.0, cache_read = 0.04 }
3. 使用该模型,然后执行 /cost(或 /tokens)。
结果:估算把 2 / 8 / 0.04 当作每百万 token 的美元价(放大约一个汇率量级),
而 cost_currency = "cny" 时显示的是美元或"未定价",而不是人民币。
### What should Codewhale do? 希望 Codewhale 怎么做?
- 支持声明 custom_models.cost 的币种,例如 cost_currency = "cny",
默认 usd,并在加载时校验(未知币种应报错,而不是静默按美元处理)。
- /cost、/tokens 和状态栏按声明的币种估算,不能把人民币数字标成美元。
- 目录投影(以美元数值展示)不应把人民币费率显示成美元。
### Where? 在哪里?
_No response_
### Workarounds or other tools (optional)
_No response_
### Contributing
- [ ] I would like to open a pull request for this, once we agree on the shape. 我愿意在方案确定后提交 PR。
感谢 @w1w218 的建议。cbf83f3c152 已合入 main:[[custom_models]] 的价格现在可以用 cost_currency 声明人民币(CNY)。该字段在加载配置时校验;声明为 CNY 时不再显示美元换算,/cost 直接按人民币显示。
这项改动已在 main 和 0.10.3 候选版本中,但尚未正式发布(当前最新发布版仍是 v0.10.2)。0.10.3 发布后请您确认是否符合预期,在那之前这个 issue 保持打开。
Thanks for the request — custom model prices can declare CNY via cost_currency as of cbf83f3c152 on main; it ships with 0.10.3, which is not published yet.
感谢 @w1w218 提出让 [[custom_models]] 的价格声明人民币币种的建议。该功能已随 v0.10.3 发布(cbf83f3c15):设置 cost_currency = "cny" 后,/cost、/tokens 和状态栏按人民币估算,未知币种会在加载配置时报错。升级命令:npm install -g [email protected]。如果升级后仍不符合预期,欢迎重新打开这个 issue。
English: custom model prices can declare CNY via cost_currency; this shipped in v0.10.3 (cbf83f3c15). Upgrade with npm install -g [email protected] and reopen if it still misbehaves.