You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Bedrock的Claude Sonet模型时遭遇请求格式错误求助

解决Amazon Bedrock Claude Sonet模型的请求格式错误

错误原因

你的请求JSON存在语法错误:"system": "act as a coder"这一行末尾缺少逗号,JSON中相邻键值对必须用逗号分隔,这个遗漏导致请求格式不合法,触发了ValidationException。

修正后的请求格式

{
    "anthropic_version": "bedrock-2023-05-31",
    "max_tokens": 4096,
    "temperature": 0.5,
    "system": "act as a coder",
    "messages": [{
        "role": "user",
        "content": [
            {
                 "type": "text",
                 "text": "print hello in java"
            }
           ]
    }]
}

额外检查要点

  • 确保所有JSON键值对(除了最后一个)末尾都添加逗号
  • 提交前验证JSON格式的完整性,避免类似语法遗漏
  • 确认anthropic_version参数值与Claude Sonet模型要求匹配(当前使用的bedrock-2023-05-31是正确的)

内容的提问来源于stack exchange,提问作者Tanishka Garg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 23:03:13