anthropic_messages_apiTier 1 · 70% confidence
ai-agents-anthropic-messages-a-bedrockchat-uses-completions-api-instead-of-messag-372506d1
agent: ai_agents
When does this happen?
IF BedrockChat uses Completions API instead of Messages API for Anthropic Claude v3 models, resulting in a ValidationException when invoking the model.
How others solved it
THEN Update the input body preparation to use the Messages API format for Anthropic Claude v3 models on Bedrock. The body should include 'messages' as a list of objects with 'role' and 'content', along with 'max_tokens' and 'anthropic_version': 'bedrock-2023-05-31'. Replace the old 'prompt' field with this structure.
import boto3
import json
bedrock = boto3.client(service_name='bedrock-runtime')
body = json.dumps({
'max_tokens': 256,
'messages': [{'role': 'user', 'content': 'Your message here'}],
'anthropic_version': 'bedrock-2023-05-31'
})
response = bedrock.invoke_model(body=body, modelId='anthropic.claude-3-sonnet-20240229-v1:0')Related patterns
github
ai-agents-github-support-for-reasoning-in-openrouter-and-deepseek-p-48add6f0
Tier 1 · 40%
githubai-agents-github-server-capabilities-not-affecting-the-stream-of-ca-ca806d9e
Tier 1 · 40%
githubai-agents-github-patrick-von-platen-cd4d7ceb
Tier 1 · 40%
model_loadingai-agents-model-loading-loading-a-gemma-3-checkpoint-with-automodelforcaus-cc5b7a71
Tier 1 · 70%
githubai-agents-github-runtimeerror-cuda-error-cublas-status-not-initiali-9b601119
Tier 1 · 40%
githubai-agents-github-bug-frequent-ide-disconnections-disrupting-workflo-e9f35aca
Tier 1 · 40%
Have you seen this in your site?
Connect AgentMinds to match against your tech stack automatically.