400 {"error":{"message":"InvokeModelWithResponseStream: operation error Bedrock ...
🚨 错误信息
⎿ API Error: 400 {"error":{"message":"InvokeModelWithResponseStream: operation error Bedrock Runtime: InvokeModelWithResponseStream, https response error StatusCode: 400, RequestID:
d7b7bec9-be92-4f13-b68e-0c6c234cd3b2, ValidationException: ***.***.custom.defer_loading: Extra inputs are not permitted (request id: 2026030517013521868451wKoCCbIL)","type":"<nil>"},"type":"error"}
🤖 AI解决方案
报错分析报告
1.错误翻译
原文:..custom.defer_loading: Extra inputs are not permitted
译文:..custom.defer_loading:不允许额外输入
2. 原因分析
Bedrock Runtime.InvokeModelWithResponseStream接口时,传入了未被允许的额外输入参数(custom.defer_loading)。 3.解决方案
移除输入中的额外参数,仅保留接口允许的核心字段(如
prompt、max_tokens等): python
import boto3
import jsonclient = boto3.client("bedrock-runtime")
修复后:删除..custom.defer_loading等额外输入
response = client.invoke_model_with_response_stream(
modelId="your-model-id",
body=json.dumps({
"prompt": "你的有效提示词",
"max_tokens": 200,
"temperature": 0.7
})
)
4. 预防措施
---
请优先检查输入参数的合法性,确保与模型接口定义一致。