快速结论:JWT team auth 在 /v1/messages 端点失败,返回 No team has access to the requested model,除非显式传递 x-litellm-team-id。原因是 LiteLLM_JWTAuth.team_allowed_routes 默认列表中缺少 anthropic_routes,优先排查该类配置并添加。
适用环境:LiteLLM 1.89.0,启用 enable_jwt_auth 且配置了 team_ids_jwt_field(示例中为 litellm_groups),使用 Anthropic-compatible /v1/messages 路由。
最快修复方案:在 litellm/proxy/_types.py 的 LiteLLM_JWTAuth 类中,将 team_allowed_routes 的默认值改为:["openai_routes", "anthropic_routes", "info_routes", "mcp_routes"]。该更改已由社区验证有效。
注意事项:此修复仅影响 JWT auth 对 Anthropic 路由的团队权限检查;其他路由(如 /v1/models、/v1/responses)不受影响。如果自行修改源码,注意备份或版本管理。
问题场景
用户在 LiteLLM 中使用 JWT 认证,通过 team_ids_jwt_field(如 litellm_groups)从 JWT 声明中提取团队 ID。当调用 Anthropic 兼容的 /v1/messages 端点时,即使 JWT 中的团队在 LiteLLM 后台有对应的模型访问组权限,请求也会被拒绝(403),除非在请求头中显式添加 x-litellm-team-id。而 /v1/models 和 /v1/responses 端点在相同 JWT 下工作正常。
报错原文
{
"error": {
"message": "No team has access to the requested model: claude-sonnet-4-6. Checked teams={'LITELLM_Coding_High'}. Check `/models` to see all available models.",
"type": "auth_error",
"param": "None",
"code": "403"
}
}
原因分析
根因在 litellm/proxy/_types.py 中 LiteLLM_JWTAuth 类的 team_allowed_routes 属性。其默认值为 ["openai_routes", "info_routes", "mcp_routes"],缺少 "anthropic_routes"。当 JWT 解析出团队后,认证流程会调用 find_team_with_model_access 函数,该函数内部对每个团队执行 allowed_routes_check。对于 /v1/messages 路径,路由类型为 anthropic_routes,而团队没有该路由的权限,导致所有候选团队均返回 is_allowed = False,最终触发 403 错误。
而显式提供 x-litellm-team-id 头时,认证流程走的是独立的早期返回路径(在 auth_builder 中),该路径会绕过 find_team_with_model_access,因此可以正常通过。
环境排查
- LiteLLM 版本:确认是否为
1.89.0或包含该 bug 的版本(社区已确认1.89.0存在此问题)。 - 配置项:检查
general_settings.litellm_jwtauth中是否正确配置了team_ids_jwt_field,并与 JWT 声明的字段匹配。 - 路由行为:测试
/v1/models和/v1/responses是否正常工作,以确认问题仅限于/v1/messages(或整个anthropic_routes)。 - 自定义
team_allowed_routes:如果用户自定义了LiteLLM_JWTAuth中的team_allowed_routes,检查是否误删了anthropic_routes或未添加。
解决步骤
- 定位到
litellm/proxy/_types.py文件,找到LiteLLM_JWTAuth类。 - 将
team_allowed_routes的默认值由["openai_routes", "info_routes", "mcp_routes"]修改为["openai_routes", "anthropic_routes", "info_routes", "mcp_routes"]。 - 保存文件并重启 LiteLLM 代理服务。
- (可选)如果不想直接修改源代码,也可以通过在配置中显式设置
team_allowed_routes来覆盖默认值(具体配置方式需参考 LiteLLM 文档,Issue 未验证该替代方法)。 - 如果无法修改源代码,临时 workaround 是在调用
/v1/messages时始终添加x-litellm-team-id头(值为 JWT 中对应的团队 ID)。
验证方法
使用相同的 JWT 和请求体,重复调用 /v1/messages 端点:
- 不加
x-litellm-team-id头:应返回 200 和正常响应,而非 403 错误。 - 同时确认
/v1/models和/v1/responses仍然工作正常。
如果修复生效,认证日志中不会出现 "No team has access" 的 403 错误。
参考来源
BerriAI/litellm #31189(社区讨论及根因分析)
AI 工具推荐
想把多个 AI 模型放在一个入口?
GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。
推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。
这个方案解决了吗?
可以继续搜索完整报错,或查看同一工具的其他排查指南。
![[Question]: [MinerU] Output directory](https://www.chat-gpts.plus/wp-content/uploads/2026/07/11691-e87e0a36-768x403.jpg)
![[Question]:](https://www.chat-gpts.plus/wp-content/uploads/2026/07/12522-01ebd777-768x403.jpg)
![[Question]: Mineru Chunking](https://www.chat-gpts.plus/wp-content/uploads/2026/07/12591-095b89af-768x403.jpg)