Home / File/ bedrock.py — anthropic-sdk-python Source File

bedrock.py — anthropic-sdk-python Source File

Architecture documentation for bedrock.py, a python file in the anthropic-sdk-python codebase. 1 imports, 0 dependents.

File python AnthropicClient SyncAPI 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  871e7374_d14c_c620_e6da_d4dfceb15d13["bedrock.py"]
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  871e7374_d14c_c620_e6da_d4dfceb15d13 --> d10c5377_2939_0f0b_cc44_8759393f2853
  style 871e7374_d14c_c620_e6da_d4dfceb15d13 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

#!/usr/bin/env -S poetry run python

# Note: you must have installed `anthropic` with the `bedrock` extra
# e.g. `pip install -U anthropic[bedrock]`

from anthropic import AnthropicBedrock

# Note: this assumes you have AWS credentials configured.
#
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
client = AnthropicBedrock()

print("------ standard response ------")
message = client.messages.create(
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": "Hello!",
        }
    ],
    model="anthropic.claude-sonnet-4-5-20250929-v1:0",
)
print(message.model_dump_json(indent=2))

print("------ streamed response ------")

with client.messages.stream(
    max_tokens=1024,
    messages=[
        {
            "role": "user",
            "content": "Say hello there!",
        }
    ],
    model="anthropic.claude-sonnet-4-5-20250929-v1:0",
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
    print()

    # you can still get the accumulated final message outside of
    # the context manager, as long as the entire stream was consumed
    # inside of the context manager
    accumulated = stream.get_final_message()
    print("accumulated message: ", accumulated.model_dump_json(indent=2))

Subdomains

Functions

Dependencies

  • anthropic

Frequently Asked Questions

What does bedrock.py do?
bedrock.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in bedrock.py?
bedrock.py defines 1 function(s): text.
What does bedrock.py depend on?
bedrock.py imports 1 module(s): anthropic.
Where is bedrock.py in the architecture?
bedrock.py is located at examples/bedrock.py (domain: AnthropicClient, subdomain: SyncAPI, directory: examples).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free