[设计讨论] 自定义 Provider 的成本计费:按 Anthropic 价格虚高,是否需要让用户自定义价格?
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 401
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
## 背景
使用自定义 Provider(如 DeepSeek)时,Cindy 显示的成本与实际 API 费用存在巨大差距(实测 ~60 倍)。
### 数据
| 来源 | Token 用量 | 成本 |
|------|-----------|------|
| Cindy 显示 | input 91K, output 38K, cache_read 843万 | **$5.64** |
| API 后台实际 | 真实调用 | **0.68 RMB** (~$0.09) |
### 根因
Cindy 的成本计算链路(`resolveTurnCost` → `computeGatewayTurnCost` → fallback 到 `sdk-fallback`):
1. 自定义 Provider 的模型不在 Anthropic 白名单里
2. 也不在订阅直连定价表(`SUBSCRIPTION_DIRECT_VALUE_PRICING`)里
3. 网关也查不到定价(`model_group/info` 无数据)
4. **最终 fallback:用 SDK(Claude Code)内部计算的成本 × multiplier**
5. SDK 内部按 Anthropic 价格算 Token,同时把上下文压缩产生的 `cache_read_tokens` 也计费
结果就是用 Claude 的价格去算 DeepSeek 的 Token。
## 讨论方向
这不是一个 bug(逻辑上是按设计运行的),但产品体验上存在改进空间。几种可能的处理方式:
### 选项 A:搁置不管
- 理由:Cindy 的定位是 Claude 前端,自定义 Provider 是高级功能。成本显示不准是可以接受的 trade-off
- 风险:用户看到 $5 vs 0.68 RMB 会困惑,但不影响实际使用
### 选项 B:让用户自定义价格
- 在自定义 Provider 的模型编辑界面中,增加价格配置字段(input/output/cache read 的 $/MTok)
- 或者提供一个「成本倍数」滑块,让用户粗略调整
- 优点:灵活,用户自行负责准确性
- 缺点:增加了 UI 复杂度
### 选项 C:从 modelsUrl 自动获取(理想但不可靠)
- 通过 Provider 配置的 `modelsUrl` 端点获取模型定价信息
- 问题:大多数 API 的 `/models` 端点不返回价格信息
### 选项 D:禁用自定义 Provider 的成本显示
- 当模型没有可靠定价数据时,直接不显示成本或显示 "N/A"
- 避免误导
---
个人倾向于 **A 或 B 都可以接受**,看团队的设计方向。
Contributor guide
Research direction
Start by tracing resolveTurnCost through computeGatewayTurnCost and the sdk-fallback path, then inspect SUBSCRIPTION_DIRECT_VALUE_PRICING and the model_group/info lookup. Review how custom Provider models and modelsUrl are represented before choosing a pricing behavior. Done means the team has selected and specified one supported approach, including its user-visible cost behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100