sub2api
sub2api copied to clipboard
Token counting returns not_found_error on unsupported platform
问题描述
通过 Sub2API 调用时,请求返回如下错误:
{
"error": {
"message": "Token counting is not supported for this platform",
"type": "not_found_error"
},
"type": "error"
}
看起来是当前请求链路中启用了 token-counting-2024-11-01 相关能力,但目标 platform/backend 不支持 token counting,最终返回了 not_found_error。
复现情况
目前观察到的响应为上述 JSON 错误。建议检查以下场景是否会触发:
- Sub2API 自动添加或转发了
anthropic-beta: token-counting-2024-11-01 - 当前配置的 platform/provider 不支持 token counting
- 客户端请求中没有显式使用 token counting,但 Sub2API 在构造 beta header 时默认带上了该 beta
预期行为
如果目标 platform 不支持 token counting,希望 Sub2API 能够:
- 不要默认为该 platform 添加
token-counting-2024-11-01;或 - 在转发前过滤掉不兼容的 beta header;或
- 返回更明确的配置错误,说明当前 platform 不支持 token counting。
实际行为
返回:
{
"error": {
"message": "Token counting is not supported for this platform",
"type": "not_found_error"
},
"type": "error"
}
可能相关点
搜索已有 issues,没有找到完全相同的报错。相关但不相同的问题:#643 中提到了 Sub2API 的 beta header 组合里包含:
claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,token-counting-2024-11-01
因此怀疑本问题可能也和 beta header 的默认注入、替换或合并逻辑有关。
希望协助确认
想请维护者确认:
- Sub2API 是否会在某些请求中默认添加
token-counting-2024-11-01? - 是否可以按 platform/provider 判断并跳过不支持的 token counting beta?
- 是否有配置项可以关闭 token counting beta header?
环境信息
- Sub2API 版本:v0.1.123
- 部署方式:docker compose
- platform/provider:Codex
- 模型:GPT-5.5
- 认证方式:Oauth