File size: 553 Bytes
de886b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import requests
import json
from requests_auth_aws_sigv4 import AWSSigV4
REGION = 'us-east-1'
aws_auth = AWSSigV4('bedrock', region=REGION) # If not provided, check for AWS Credentials from Environment Variables
body = json.dumps({
"max_tokens": 4096,
"messages": [{"role": "user", "content": "Hello, world"}],
"anthropic_version": "bedrock-2023-05-31"
})
r = requests.request(
'POST',
f'https://bedrock-runtime.{REGION}.amazonaws.com/model/anthropic.claude-3-sonnet-20240229-v1:0/invoke',
data=body,
auth=aws_auth)
print(r.text) |