s:invoke app failed: request failed with status code: 400 and respond with: {"co...

2026年01月20日 14:25 状态: processing

🚨 错误信息

Errors:invoke app failed: request failed with status code: 400 and respond with: {"code":"invalid_param","message":"req_id: 4ad662dd21 PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"Unknown parameter: 'chat_template_kwargs'.\",\"type\":\"rix_api_error\",\"param\":\"chat_template_kwargs\",\"code\":\"unknown_parameter\"}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"Unknown parameter: 'chat_template_kwargs'.\",\"type\":\"rix_api_error\",\"param\":\"chat_template_kwargs\",\"code\":\"unknown_parameter\"}}"}","status":400}

🤖 AI解决方案

代码报错分析报告

---

1. 错误翻译


text
原文:{"error":{"message":"Unknown parameter: 'chat_template_kwargs'.", "type":"rix_api_error", "param":"chat_template_kwargs", "code":"unknown_parameter"}}
译文:{"error":{"message":"未知参数: 'chat_template_kwargs'。", "type":"rix_api_error", "param":"chat_template_kwargs", "code":"unknown_parameter"}}

---

2. 原因分析


此错误是一个参数不被识别的API调用错误。根本原因是在向大语言模型(LLM)API(推测为OpenAI或其兼容API)发送请求时,在请求参数中包含了该API当前版本或服务端不支持的字段 chat_template_kwargs。该参数可能来自特定的模型调用封装库或自定义的提示词模板设置。

---

3. 解决方案


需要从你的模型调用代码中移除不被识别的 chat_template_kwargs 参数。检查你的代码中调用模型的部分。

假设你使用的是类似 openai 库的 Python 代码:

python

❌ 错误示例 - 包含了不被支持的参数


response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello"}],
chat_template_kwargs={...} # 此行导致错误
# ... 其他参数
)

✅ 修复后的代码 - 移除无效参数


response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello"}],
# 移除了 chat_template_kwargs 参数
# ... 其他有效参数
)

如果你的代码使用了其他库或框架(如 litellm, langchain 等),请在其模型调用参数中查找并移除 chat_template_kwargs

---

4. ️ 预防措施


  • 查阅官方文档:调用任何外部API前,务必查阅其最新官方文档,确认所有请求参数的有效性和格式。不同模型提供商和API版本支持的参数可能不同。

  • 参数验证与日志:在开发过程中,开启详细的请求日志,或者在发送请求前对参数进行验证,过滤掉目标API不支持的所有字段,避免因参数不兼容导致整个请求失败。