SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
14 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
1.4 KB · 26 lines python
Raw Blame History
1#!/usr/bin/env python32# STATUS: UNVERIFIED — no cloud credentials in this atlas; snippet follows official docs verbatim-ish3# Source: https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock (retrieved 2026-09-18)4# Install: pip install -U "anthropic[bedrock]"5# Auth: standard AWS credential chain (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN, profile, SSO, IMDS).6# Region: AWS_REGION (e.g. us-east-1). No secrets in this file.7import os89from anthropic import AnthropicBedrockMantle1011# Claude in Amazon Bedrock (Messages API at /anthropic/v1/messages, SSE streaming).12client = AnthropicBedrockMantle(aws_region=os.environ.get("AWS_REGION", "us-east-1"))1314message = client.messages.create(15    model="anthropic.claude-haiku-4-5",  # cheapest Haiku 4.5 id on the Bedrock Messages-API endpoint16    max_tokens=8,17    messages=[{"role": "user", "content": "Reply with OK."}],18)19print(next(block.text for block in message.content if block.type == "text"))2021# Legacy InvokeModel integration (ARN-versioned ids, AWS EventStream) — not run here:22#   from anthropic import AnthropicBedrock23#   AnthropicBedrock(aws_region="us-west-2").messages.create(24#       model="us.anthropic.claude-haiku-4-5-20251001-v1:0",  # inference-profile prefix required (global./us./eu.)25#       max_tokens=8, messages=[{"role": "user", "content": "Reply with OK."}])26