[Bug]: Vertex AI claude-opus-5-5 rejects response_format json_schema: LiteLLM sends the deprecated `output_format` instead of `output_config

这个报错通常出现在通过 LiteLLM 代理对 Vertex AI 上的 Claude 模型(如 vertex_ai/claude-opus-5-5 )发起带 response_format: json_schema 的 /v1/chat/completions 请求时,LiteLLM 仍把结构化输

快速结论:这个报错通常出现在通过 LiteLLM 代理对 Vertex AI 上的 Claude 模型(如 vertex_ai/claude-opus-5-5)发起带 response_format: json_schema 的 /v1/chat/completions 请求时,LiteLLM 仍把结构化输出写成已弃用的顶层字段 output_format,被 Vertex 以 400 拒绝。优先排查并升级 LiteLLM 版本。

适用环境:LiteLLM 1.104.0(Proxy 模式)确认复现;同一请求在 1.107.0rc2 上复测通过。模型为 vertex_ai/claude-opus-5-5,Vertex 区域 eu。Issue 未提供操作系统、Python、CUDA、显卡等环境信息。

最快修复方案:升级到包含该修复的 LiteLLM 版本,Issue 中已验证 1.107.0rc2 可正常返回 schema-valid JSON。

注意事项:1.104.0 复测仍报 output_format 弃用错误,说明修复未进入该版本;1.107.0rc2 为候选版本,生产环境升级前建议先在测试代理上回归。Issue 中关于“所有 provider 都能受益”的改法属于提出者的推测,不代表已发布的实现范围。

问题场景

用户在 LiteLLM Proxy 中配置 vertex_ai/claude-opus-5-5(vertex_project 为实际项目、vertex_location: eu),通过 /v1/chat/completions 携带 response_format(type: json_schema,strict: true)请求结构化 JSON 输出。每次调用都收到 Vertex 返回的 400;去掉 response_format 后同一请求成功。

报错原文

litellm.BadRequestError: Vertex_aiException BadRequestError - {"type":"error","error":{"type":"invalid_request_error","message":"output_format: This field is deprecated. Use 'output_config.format' instead. See https://platform.claude.com/docs/en/build-with-claude/structured-outputs for more information."}}

原因分析

该模型在模型映射中标记了 supports_native_structured_output,因此 AnthropicConfig.map_openai_params 会把 response_format 映射为 optional_params["output_format"](Issue 指出 1.104.0、1.106.0 及 main 的 litellm/llms/anthropic/chat/transformation.py 中 param == "response_format" 分支均如此),后续没有把该字段转换为 output_config.format,导致请求体携带了已弃用的顶层字段。Anthropic 直连 API 目前仍容忍该字段,但 Vertex 会拒绝,Bedrock 也会拒绝(相关 #44598)。

修复方向是在 Vertex 侧做 sanitize,将 output_format 折叠进 output_config.format;Issue 最后确认该修复已在 1.107.0rc2 中生效。

环境排查

  • 确认 LiteLLM 版本:1.104.0 确认存在问题;1.106.0 与 main 的发出代码在 Issue 讨论时未变更。
  • 确认模型配置为 vertex_ai/claude-opus-5-5,并核对 vertex_project、vertex_location。
  • 确认请求确实带有 response_format 且类型为 json_schema,可对比不带该字段的请求是否成功。
  • 抓取或记录发往 Vertex 的请求体,检查是否仍出现顶层 output_format,以及是否已生成 output_config.format。
  • 若同时设置了 output_config.effort,检查合并后 output_config 是否被覆盖或丢失字段。

解决步骤

  1. 记录当前 LiteLLM 版本,并保留复现请求(带 json_schema 的 curl 或客户端调用)。
  2. 将 LiteLLM 升级到 1.107.0rc2 或更新的、包含该修复的版本。可优先尝试在测试环境先行升级。
  3. 重启代理,用原请求重测 vertex_ai/claude-opus-5-5(eu 区域)。
  4. 若仍失败,检查请求体中 output_format 是否仍为顶层字段;这通常说明当前版本未包含 Vertex sanitization 修复。
  5. 确认升级后 additional_drop_params 等原有 LiteLLM 参数仍按预期生效,避免其他参数被误改写。

验证方法

在同一代理配置下,对 vertex_ai/claude-opus-5-5 连续发送多次 json_schema 请求,应全部返回 200 且响应体符合所给 schema(Issue 中 1.107.0rc2 复测为三次全部通过);同时确认不再出现 output_format: This field is deprecated 的 400 错误。

参考来源

BerriAI/litellm #47563

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

这个方案解决了吗?

celebrityanime
celebrityanime
文章: 29602

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注