fix(gateway): Antigravity 账户 count_tokens 返回估算值
Antigravity 不支持 count_tokens 转发,直接返回估算值, 与 Antigravity-Manager 和 proxycast 实现保持一致。 修复 count_tokens 请求选择到 Antigravity 账户时导致 401 的问题。
This commit is contained in:
@@ -1145,6 +1145,13 @@ func (s *GatewayService) RecordUsage(ctx context.Context, input *RecordUsageInpu
|
||||
// ForwardCountTokens 转发 count_tokens 请求到上游 API
|
||||
// 特点:不记录使用量、仅支持非流式响应
|
||||
func (s *GatewayService) ForwardCountTokens(ctx context.Context, c *gin.Context, account *Account, body []byte) error {
|
||||
// Antigravity 账户不支持 count_tokens 转发,返回估算值
|
||||
// 参考 Antigravity-Manager 和 proxycast 实现
|
||||
if account.Platform == PlatformAntigravity {
|
||||
c.JSON(http.StatusOK, gin.H{"input_tokens": 100})
|
||||
return nil
|
||||
}
|
||||
|
||||
// 应用模型映射(仅对 apikey 类型账号)
|
||||
if account.Type == AccountTypeApiKey {
|
||||
var req struct {
|
||||
|
||||
Reference in New Issue
Block a user