Skip to main content

AWS Bedrock provider for lmux

Project description

lmux-aws-bedrock

AWS Bedrock provider for lmux. Uses boto3, aiobotocore, and the Converse API.

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]: async support via aiobotocore

Auth

Uses boto3's default credential chain (env vars, AWS config, instance metadata). 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

Requires the [async] extra. All methods have async variants: achat, achat_stream, aembed.

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

Constructor Options

BedrockProvider(
    auth=...,          # AuthProvider, default: BedrockEnvAuthProvider()
    region=...,        # AWS region
    endpoint_url=...,  # Custom endpoint URL
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmux_aws_bedrock-0.2.0.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmux_aws_bedrock-0.2.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file lmux_aws_bedrock-0.2.0.tar.gz.

File metadata

  • Download URL: lmux_aws_bedrock-0.2.0.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lmux_aws_bedrock-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1c12fb9c9bd14639aa5e37a991ae443d1d0a9d9052c4c21b86dce6d9e50acb20
MD5 86a2e6d86d54183999275e15faea7fa9
BLAKE2b-256 d2f698231b36f9613edd6137f25f66838a7d307849e2c9410c5a90ce362e6c22

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_aws_bedrock-0.2.0.tar.gz:

Publisher: publish.yml on cluebbehusen/lmux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lmux_aws_bedrock-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lmux_aws_bedrock-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1749026269a9128e9d06e4d9acf8263d6a58bf84f63a911e4aa41a62c16c3c7e
MD5 ffe04178ec18ddafc157f2f1770ee714
BLAKE2b-256 9836f0efd64ac8cad43b39fe63a8e8b347fc11d3ef1998d19ec515856c8506b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmux_aws_bedrock-0.2.0-py3-none-any.whl:

Publisher: publish.yml on cluebbehusen/lmux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page