Skip to content

Commit e5bbcae

Browse files
committed
docs: add bedrock tracing cookbook
1 parent ed4ae4d commit e5bbcae

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
from anthropic import AnthropicBedrock
4+
from dotenv import load_dotenv
5+
6+
from parea import Parea
7+
8+
load_dotenv()
9+
10+
client = AnthropicBedrock(
11+
# Authenticate by either providing the keys below or use the default AWS credential providers, such as
12+
# using ~/.aws/credentials or the "AWS_SECRET_ACCESS_KEY" and "AWS_ACCESS_KEY_ID" environment variables.
13+
aws_access_key="<access key>",
14+
aws_secret_key="<secret key>",
15+
# Temporary credentials can be used with aws_session_token.
16+
# Read more at https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html.
17+
aws_session_token="<session_token>",
18+
# aws_region changes the aws region to which the request is made. By default, we read AWS_REGION,
19+
# and if that's not present, we default to us-east-1. Note that we do not read ~/.aws/config for the region.
20+
aws_region="us-west-2",
21+
)
22+
23+
24+
p = Parea(api_key=os.getenv("PAREA_API_KEY"))
25+
p.wrap_anthropic_client(client)
26+
27+
message = client.messages.create(model="anthropic.claude-3-5-sonnet-20240620-v1:0", max_tokens=256, messages=[{"role": "user", "content": "Hello, world"}])
28+
print(message.content)

0 commit comments

Comments
 (0)