Skip to main content

AWS Bedrock Target adapter for Waken — routes waken Events to any Bedrock-hosted model via the Converse API.

Project description

waken-bedrock

CI License: MIT

An AWS Bedrock Target adapter for Waken — "nginx for AI agents." Routes waken Events to any model hosted on Bedrock via the unified converse API and returns the result as a waken Response.

Install

pip install waken-bedrock

Usage

from waken import Runtime
from waken_bedrock import BedrockAdapter

runtime = Runtime()
runtime.target("bedrock", BedrockAdapter(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0"))
runtime.run()

model_id is required — Bedrock hosts models from several providers behind one API, and there's no sensible default across them. This is also the whole point of this adapter: it's one Target that can reach Anthropic, Meta, Amazon, Mistral, or any other model family Bedrock hosts, just by changing the string:

runtime.target("claude-on-bedrock", BedrockAdapter(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0"))
runtime.target("llama-on-bedrock", BedrockAdapter(model_id="meta.llama3-1-70b-instruct-v1:0"))

Credentials

Unlike sibling adapters that read a single named API key (ANTHROPIC_API_KEY, GEMINI_API_KEY), Bedrock has no equivalent — boto3 authenticates through the standard AWS credential chain: env vars (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN), AWS_PROFILE and ~/.aws/credentials, or an EC2/ECS/Lambda instance role, resolved in that order by boto3 itself. BedrockAdapter never reads or touches credentials directly. Pass region_name, profile_name, or explicit credential keywords through **client_kwargs, which go straight to boto3.client("bedrock-runtime", ...):

runtime.target(
    "bedrock",
    BedrockAdapter(
        model_id="anthropic.claude-3-5-sonnet-20241022-v2:0",
        region_name="us-east-1",
        profile_name="my-aws-profile",
    ),
)

Sessions

Bedrock's converse API is stateless per call, the same client-managed- history shape as the Gemini/Mistral/Cohere sibling adapters: there's no server-side session id to resume, so the whole conversation is resent on every turn. BedrockAdapter maps a waken session_id to a growing list of Bedrock-shaped messages and replays it in full each call. An Event with no session_id is a one-off exchange and is never stored.

boto3 is a synchronous SDK — the blocking converse() call runs on the default executor (loop.run_in_executor) rather than blocking the event loop directly.

SDK exceptions (throttling, validation errors, access-denied, ...) propagate unchanged; this adapter doesn't wrap or swallow them.

Development

git clone https://github.com/WakenHQ/waken-bedrock
cd waken-bedrock
pip install -e ".[dev]"
pytest

Tests mock boto3.client entirely — no AWS credentials or network access needed to run the suite.

License

MIT

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

waken_bedrock-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

waken_bedrock-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file waken_bedrock-0.1.0.tar.gz.

File metadata

  • Download URL: waken_bedrock-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waken_bedrock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4d0472107686e3e9f7ef7dd91ab4b28c7303c92707b6440f198c2643a6d1ee6c
MD5 f7dd31bfc7d57f6ad4a2268340ff63cf
BLAKE2b-256 239aa00b131e78e1514b31a3f38cfe024b20827c2069c12e311dc9c1f5a28009

See more details on using hashes here.

Provenance

The following attestation bundles were made for waken_bedrock-0.1.0.tar.gz:

Publisher: publish.yml on WakenHQ/waken-bedrock

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

File details

Details for the file waken_bedrock-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: waken_bedrock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waken_bedrock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97f1f3af29fc564d9ed9b31e27db31748e994ebbf53c7f472e00efcd81147a00
MD5 e5bc50178f15022fc0f2bf809c775b0f
BLAKE2b-256 392c7d955df53737d83df8a8a3ba318e636578c5296a83a309316412ebc00ba8

See more details on using hashes here.

Provenance

The following attestation bundles were made for waken_bedrock-0.1.0-py3-none-any.whl:

Publisher: publish.yml on WakenHQ/waken-bedrock

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