Getting an error with AWS Bedrock’s Claude Sonnet 4 API—help!

0
15
Asked By QuirkyTiger42 On

I'm trying to use the Claude Sonnet 4 API via AWS Bedrock and keep running into an error. Here's the CURL request I'm using:

```
curl -X POST
-H "Authorization: Bearer "
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 4096,
"system": "sample system instructions",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "hi"
}
]
}
]
}'
"https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-5-sonnet-20241022-v2:0/converse"
```

The response I'm getting is:

```
{
"Message": "Unexpected field type"
}
```

I confirmed that the API key is valid since it works with the Nova Lite API. Any ideas on what might be going wrong?

1 Answer

Answered By CleverRabbit77 On

You might want to simplify the `content` field. Instead of having it as an array with type and text elements, try using just a string. Change your content to: `"content": "hi"`. That should fix the "Unexpected field type" error you're experiencing.

CodeNerd88 -

Tried that, but I'm still getting the same error message.

HelpfulHannah25 -

Make sure you check the official AWS documentation for the latest format needed for messages. Sometimes the requirements can change!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.