lmux-aws-bedrock
AWS Bedrock provider for lmux. Talks to the Bedrock Converse and InvokeModel REST endpoints directly over httpx, using boto3 only to resolve AWS credentials for request signing.
Supports chat completions, streaming, and embeddings.
Part of the lmux ecosystem: standardized interface, cost tracking on every response, and registry-based routing across providers.
Optional Extras
lmux-aws-bedrock[async]:aiobotocorefor async AWS credential resolution in the auth providers. Not required forachat/aembed/achat_streamthemselves.
Auth
Two authentication modes are supported, resolved on the first request:
- Bedrock API key (simplest): set
AWS_BEARER_TOKEN_BEDROCKand each request is sent with anAuthorization: Bearer <token>header — no signing required. - SigV4 (fallback): otherwise AWS credentials are resolved through boto3's default credential chain (env vars, AWS config, instance metadata) and each request is SigV4-signed. No extra setup needed if your AWS credentials are already configured.
from lmux_aws_bedrock import BedrockProvider
provider = BedrockProvider()
# Or specify a region
provider = BedrockProvider(region="us-east-1")
For explicit session configuration:
from lmux_aws_bedrock import BedrockSessionAuthProvider
provider = BedrockProvider(auth=BedrockSessionAuthProvider(profile_name="my-profile"))
Usage
Chat
from lmux import UserMessage
response = provider.chat("anthropic.claude-sonnet-4-20250514-v1:0", [UserMessage(content="Hello")])
print(response.content)
print(response.cost)
Streaming
for chunk in provider.chat_stream("anthropic.claude-sonnet-4-20250514-v1:0", [UserMessage(content="Hello")]):
if chunk.delta:
print(chunk.delta, end="")
Embeddings
response = provider.embed("amazon.titan-embed-text-v2:0", "Hello")
print(response.embeddings)
Async
All methods have async variants: achat, achat_stream, aembed. These run over httpx's async client; credentials are resolved synchronously (via boto3) even on the async path.
Bedrock also supports lmux response_format, mapped to Converse outputConfig.textFormat.
Registry
Use with the lmux registry to route across multiple providers:
from lmux import Registry
registry = Registry()
registry.register("bedrock", provider)
response = registry.chat("bedrock/anthropic.claude-sonnet-4-20250514-v1:0", messages)
Provider Params
from lmux_aws_bedrock import BedrockParams, GuardrailConfig
response = provider.chat(
"anthropic.claude-sonnet-4-20250514-v1:0",
messages,
provider_params=BedrockParams(
guardrail_config=GuardrailConfig(
guardrail_identifier="my-guardrail",
guardrail_version="1",
),
),
)
| Parameter | Type | Description |
|---|---|---|
guardrail_config |
GuardrailConfig |
Bedrock guardrail to apply |
additional_model_request_fields |
dict |
Extra fields passed to the model |
additional_model_response_field_paths |
list[str] |
Extra response fields to return |
pricing_as_of |
datetime.date |
Override the date used for dated pricing; defaults to the current date |
Prompt Caching
Place CachePointContent parts in UserMessage content to emit Converse cachePoint blocks marking the end of a stable prompt prefix. A cache point with no preceding block in its message is placed after whatever came before it (the prior message, or the system blocks). Markers with nothing cacheable before them are dropped, and adjacent duplicates are coalesced — the first marker wins.
from lmux import CachePointContent, TextContent, UserMessage
messages = [
UserMessage(content=[TextContent(text=big_stable_context), CachePointContent()]),
UserMessage(content="What changed since yesterday?"),
]
Cache points are emitted for whatever model the request targets; models without prompt-caching support reject them at request validation. Cache reads/writes are reported on response.usage (cache_read_tokens, cache_creation_tokens, and the per-TTL cache_creation_tokens_by_ttl breakdown from cacheDetails) and priced into response.cost, including per-TTL write rates where the pricing data carries them.
Constructor Options
BedrockProvider(
auth=..., # AuthProvider, default: BedrockEnvAuthProvider()
region=..., # AWS region
endpoint_url=..., # Custom endpoint URL (overrides region/FIPS host selection)
use_fips=..., # bool, default False: target the FIPS 140-3 endpoint (bedrock-runtime-fips.<region>.amazonaws.com)
timeout=..., # request timeout in seconds
max_retries=..., # retry count for transient failures
transport=..., # Optional httpx.BaseTransport for the sync client (proxies, testing)
async_transport=..., # Optional httpx.AsyncBaseTransport for the async client
)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lmux_aws_bedrock-0.11.0.tar.gz.
File metadata
- Download URL: lmux_aws_bedrock-0.11.0.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8110b0a6c948feb5d8d3edfed1bf0f67a1e0d3f7d9a67d3f14c2083fcbd65ad
|
|
| MD5 |
fbb324ddeea8720ac19a6c167f3a3399
|
|
| BLAKE2b-256 |
3ee30af3babfb6da3ae9bcbb5624d1273a5ba1fc4df57f44e080fa60e99d23c7
|
Provenance
The following attestation bundles were made for lmux_aws_bedrock-0.11.0.tar.gz:
Publisher:
publish.yml on cluebbehusen/lmux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmux_aws_bedrock-0.11.0.tar.gz -
Subject digest:
a8110b0a6c948feb5d8d3edfed1bf0f67a1e0d3f7d9a67d3f14c2083fcbd65ad - Sigstore transparency entry: 2189586401
- Sigstore integration time:
-
Permalink:
cluebbehusen/lmux@5aefb4b51c0c370750bc90aa7e34febc05414002 -
Branch / Tag:
refs/tags/lmux-aws-bedrock-v0.11.0 - Owner: https://github.com/cluebbehusen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5aefb4b51c0c370750bc90aa7e34febc05414002 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lmux_aws_bedrock-0.11.0-py3-none-any.whl.
File metadata
- Download URL: lmux_aws_bedrock-0.11.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3822f1b9692a312be5f24d908b5e97885a6fb2b3e8bc23441e40418a89551eb7
|
|
| MD5 |
7ad721c067f96ddb4416bf4db6a9c5ad
|
|
| BLAKE2b-256 |
3a5633742b40b41e2b81bb7345794b69bc9f1c03aa15605b430ce3ff196dbf6a
|
Provenance
The following attestation bundles were made for lmux_aws_bedrock-0.11.0-py3-none-any.whl:
Publisher:
publish.yml on cluebbehusen/lmux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lmux_aws_bedrock-0.11.0-py3-none-any.whl -
Subject digest:
3822f1b9692a312be5f24d908b5e97885a6fb2b3e8bc23441e40418a89551eb7 - Sigstore transparency entry: 2189586432
- Sigstore integration time:
-
Permalink:
cluebbehusen/lmux@5aefb4b51c0c370750bc90aa7e34febc05414002 -
Branch / Tag:
refs/tags/lmux-aws-bedrock-v0.11.0 - Owner: https://github.com/cluebbehusen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5aefb4b51c0c370750bc90aa7e34febc05414002 -
Trigger Event:
push
-
Statement type: