] Model claude-sonnet-5 failed: Error code: 400 - {'error': {'message': 'InvokeM...
错误信息
[API Error] Model claude-sonnet-5 failed: Error code: 400 - {'error': {'message': 'InvokeModel: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 400, RequestID: 8e9629f8-ba6f-4e7d-8f84-a2a173e79434, api error ValidationException: `temperature` is deprecated for this model. (request id: 202607130615274647893598268d9d6dJmS38dt) (request id: 202607130615274092129898268d9d6aPexcPI9) (request id: 202607130615261599427620VmZ843S)', 'type': '<nil>', 'param': '', 'code': None}}
AI 解决方案
🔍 报错分析
1. 🌐 错误翻译
原文:[API Error] Model claude-sonnet-5 failed: Error code: 400 - {'error': {'message': 'InvokeModel: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 400, RequestID: 8e9629f8-ba6f-4e7d-8f84-a2a173e79434, api error ValidationException: `temperature` is deprecated for this model. (request id: 202607130615274647893598268d9d6dJmS38dt) (request id: 202607130615274092129898268d9d6aPexcPI9) (request id: 202607130615261599427620VmZ843S)', 'type': '<nil>', 'param': '', 'code': None}}
译文:[API 错误] Model claude-sonnet-5 失败:错误代码:400 - {'error': {'message': 'InvokeModel: 操作错误 Bedrock Runtime: InvokeModel,https 响应错误 StatusCode: 400, RequestID: 8e9629f8-ba6f-4e7d-8f84-a2a173e79434, api 错误 ValidationException: `temperature` 参数对于此模型已弃用。(请求 id: 202607130615274647893598268d9d6dJmS38dt)(请求 id: 202607130615274092129898268d9d6aPexcPI9)(请求 id: 202607130615261599427620VmZ843S)', 'type': '<nil>', 'param': '', 'code': None}}
2. 🎯 原因分析
核心原因:调用 Claude Sonnet 5 模型时,请求参数中包含已弃用的
temperature 参数。错误细节:
ValidationException(验证异常)InvokeModel 操作temperature 参数对该模型已不再支持,属于无效参数3. 💡 解决方案
移除请求中的
temperature 参数即可。以下是修复后的请求示例(以常用调用方式为例):// 移除 temperature 参数后的请求配置示例
const requestConfig = {
modelId: 'anthropic.claude-sonnet-5',
body: JSON.stringify({
prompt: '你的提示词内容',
max_tokens: 4096,
// 以下参数根据实际需求保留,仅移除 temperature
// temperature: 0.7, // 这一行需要删除
// 其他允许的参数...
}),
contentType: 'application/json',
};
// 发起请求(示例,具体调用方式根据你使用的SDK调整)
bedrockRuntimeClient.invokeModel(requestConfig).then(response => {
// 处理响应
}).catch(error => {
console.error('请求失败:', error);
});