SAM Doctor

ERROR REFERENCE

Bedrock says the messages field is required

The selected Anthropic Claude request reached Bedrock, but its model-specific body omitted the required messages field. Correct the request shape before changing model access or IAM.

WHAT IT MEANS

The model body does not match the Messages API

operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 400, ValidationException: messages: Field required

Bedrock model invocation bodies are model-specific. For the Anthropic Claude Messages API, messages is a required array of conversation turns; the field is separate from the top-level modelId request member.

NEXT CHECK

Send the body format the selected model expects

  1. Confirm the model and operation. Check that the selected model supports the Anthropic Claude Messages API and that the code is calling InvokeModel with its native body format rather than an OpenAI-style prompt.
  2. Add the required fields. For Claude Messages, include anthropic_version: "bedrock-2023-05-31", a positive max_tokens, and a messages array whose turns contain role and content.
  3. Check the serialized payload. Log only the request keys and sanitized values, then verify that middleware or an adapter did not rename or drop messages before sending.
  4. Retry the same call. Investigate model access or IAM only after the request body passes the model's schema.

AUTOMATE THE TRIAGE

Keep the check in your normal workflow

SAM Doctor recognizes the Bedrock messages: Field required marker with medium confidence and points at the model-specific request body. Runs locally; no AWS access, no log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED

OFFICIAL REFERENCE

Anthropic Claude Messages API

Request and response parameters - AWS lists messages as required for a Claude Messages request.