mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: 适配gpt-5-codex模型
This commit is contained in:
@@ -242,6 +242,14 @@ class CostCalculator {
|
||||
* @returns {Object} 定价信息
|
||||
*/
|
||||
static getModelPricing(model = 'unknown') {
|
||||
// 特殊处理:gpt-5-codex 回退到 gpt-5(如果没有专门定价)
|
||||
if (model === 'gpt-5-codex' && !MODEL_PRICING['gpt-5-codex']) {
|
||||
const gpt5Pricing = MODEL_PRICING['gpt-5']
|
||||
if (gpt5Pricing) {
|
||||
console.log(`Using gpt-5 pricing as fallback for ${model}`)
|
||||
return gpt5Pricing
|
||||
}
|
||||
}
|
||||
return MODEL_PRICING[model] || MODEL_PRICING['unknown']
|
||||
}
|
||||
|
||||
@@ -285,7 +293,7 @@ class CostCalculator {
|
||||
* @returns {Object} 节省信息
|
||||
*/
|
||||
static calculateCacheSavings(usage, model = 'unknown') {
|
||||
const pricing = this.getModelPricing(model)
|
||||
const pricing = this.getModelPricing(model) // 已包含 gpt-5-codex 回退逻辑
|
||||
const cacheReadTokens = usage.cache_read_input_tokens || 0
|
||||
|
||||
// 如果这些token不使用缓存,需要按正常input价格计费
|
||||
|
||||
Reference in New Issue
Block a user