fix: 使用转换后的模型名计费

计费时使用 requestBody.model(转换后的实际模型名)而不是原始请求的模型名,
这样定价表只需配置后端实际模型的价格即可。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
dreamhunter2333andClaude Opus 4.5 committed 2026-01-31 15:08:53 +08:00
1 parent c75dade7df
commit a374078966
1 file changed
+4 -2
+4 -2
View File
@@ -176,7 +176,8 @@ class ProxyEndpoint extends OpenAPIRoute {
return proxyFetch(c, targetChannelConfig, requestBody,
async (usage: Usage) => {
try {
await TokenUtils.processUsage(c, apiKey, model, targetChannelKey, targetChannelConfig, usage);
// 使用转换后的模型名计费
await TokenUtils.processUsage(c, apiKey, requestBody.model, targetChannelKey, targetChannelConfig, usage);
} catch (error) {
console.error('Error processing usage:', error);
}
@@ -284,7 +285,8 @@ class ResponsesProxyEndpoint extends OpenAPIRoute {
return proxyFetch(c, targetChannelConfig, requestBody,
async (usage: Usage) => {
try {
await TokenUtils.processUsage(c, apiKey, model, targetChannelKey, targetChannelConfig, usage);
// 使用转换后的模型名计费
await TokenUtils.processUsage(c, apiKey, requestBody.model, targetChannelKey, targetChannelConfig, usage);
} catch (error) {
console.error('Error processing usage:', error);
}