#!/usr/bin/env python3 # STATUS: UNVERIFIED — no cloud credentials in this atlas; snippet follows official docs verbatim-ish # Source: https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock (retrieved 2026-09-18) # Install: pip install -U "anthropic[bedrock]" # Auth: standard AWS credential chain (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN, profile, SSO, IMDS). # Region: AWS_REGION (e.g. us-east-1). No secrets in this file. import os from anthropic import AnthropicBedrockMantle # Claude in Amazon Bedrock (Messages API at /anthropic/v1/messages, SSE streaming). client = AnthropicBedrockMantle(aws_region=os.environ.get("AWS_REGION", "us-east-1")) message = client.messages.create( model="anthropic.claude-haiku-4-5", # cheapest Haiku 4.5 id on the Bedrock Messages-API endpoint max_tokens=8, messages=[{"role": "user", "content": "Reply with OK."}], ) print(next(block.text for block in message.content if block.type == "text")) # Legacy InvokeModel integration (ARN-versioned ids, AWS EventStream) — not run here: # from anthropic import AnthropicBedrock # AnthropicBedrock(aws_region="us-west-2").messages.create( # model="us.anthropic.claude-haiku-4-5-20251001-v1:0", # inference-profile prefix required (global./us./eu.) # max_tokens=8, messages=[{"role": "user", "content": "Reply with OK."}])