stache-ai-bedrock
Amazon Bedrock provider for Stache AI - LLM and embedding support via AWS Bedrock.
Installation
pip install stache-ai-bedrock
Usage
Install the package and configure the provider in your settings:
from stache_ai.config import Settings
settings = Settings(
llm_provider="bedrock",
embedding_provider="bedrock",
bedrock_model_id="anthropic.claude-sonnet-4-20250514-v1:0", # Optional
bedrock_embedding_model_id="cohere.embed-english-v3", # Optional
)
The provider will be automatically discovered via entry points.
Environment Variables
| Variable | Description | Default |
|---|---|---|
LLM_PROVIDER |
Set to bedrock for LLM |
- |
EMBEDDING_PROVIDER |
Set to bedrock for embeddings |
- |
BEDROCK_MODEL_ID |
LLM model ID | anthropic.claude-sonnet-4-20250514-v1:0 |
BEDROCK_EMBEDDING_MODEL_ID |
Embedding model ID | cohere.embed-english-v3 |
AWS_REGION |
AWS region | us-east-1 |
Supported Models
LLM Models
The provider supports all Bedrock-available models including:
| Provider | Models | Tier |
|---|---|---|
| Anthropic | Claude Opus 4, Claude Sonnet 4, Claude Sonnet 3.5 v2, Claude Haiku 3.5 | Premium/Balanced/Fast |
| Amazon | Nova Pro, Nova Lite, Nova Micro, Titan Text | Balanced/Fast |
| Meta | Llama 3.1 405B, Llama 3.2 90B, Llama 3 70B/8B | Premium/Balanced/Fast |
| Mistral | Mistral Large, Mixtral 8x7B, Mistral 7B | Premium/Balanced/Fast |
| Cohere | Command R+, Command R | Premium/Balanced |
| AI21 | Jamba 1.5 Large, Jamba 1.5 Mini | Premium/Balanced |
Embedding Models
| Model ID | Dimensions | Description |
|---|---|---|
cohere.embed-english-v3 |
1024 | English text (recommended) |
cohere.embed-multilingual-v3 |
1024 | Multilingual text |
amazon.titan-embed-text-v2:0 |
1024 | Amazon Titan embeddings |
IAM Permissions
The Bedrock provider requires specific IAM permissions for model invocation.
Minimum Required Permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream",
"bedrock:Converse"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"aws-marketplace:ViewSubscriptions",
"aws-marketplace:Subscribe"
],
"Resource": "*"
}
]
}
Why Resource: "*"?
Bedrock uses cross-region inference profiles for some models, which require wildcard resource permissions. Specific model ARNs (e.g., arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-*) will fail for cross-region requests.
SAM Template Example
Resources:
StacheFunction:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
LLM_PROVIDER: bedrock
EMBEDDING_PROVIDER: bedrock
BEDROCK_MODEL_ID: anthropic.claude-sonnet-4-20250514-v1:0
BEDROCK_EMBEDDING_MODEL_ID: cohere.embed-english-v3
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- bedrock:InvokeModel
- bedrock:InvokeModelWithResponseStream
- bedrock:Converse
Resource: '*'
- Effect: Allow
Action:
- aws-marketplace:ViewSubscriptions
- aws-marketplace:Subscribe
Resource: '*'
Terraform Example
data "aws_iam_policy_document" "bedrock" {
statement {
effect = "Allow"
actions = [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream",
"bedrock:Converse"
]
resources = ["*"]
}
statement {
effect = "Allow"
actions = [
"aws-marketplace:ViewSubscriptions",
"aws-marketplace:Subscribe"
]
resources = ["*"]
}
}
resource "aws_iam_role_policy" "bedrock" {
name = "bedrock-access"
role = aws_iam_role.lambda.id
policy = data.aws_iam_policy_document.bedrock.json
}
Important Notes
Model Access
Before using a model, you must enable access in the AWS Bedrock console:
- Go to AWS Console → Bedrock → Model access
- Request access to the models you want to use
- Wait for access approval (usually instant for most models)
Converse API
This provider uses the Bedrock Converse API (not the legacy InvokeModel API for chat). This requires the bedrock:Converse permission - bedrock:InvokeModel alone is not sufficient for LLM chat operations.
Embeddings
Embeddings use bedrock:InvokeModel with the embedding model. The Cohere embed models return 1024-dimensional vectors by default.
Requirements
- Python >= 3.10
- stache-ai >= 0.1.0
- boto3 >= 1.34.0
Metadata
Release files for stache-ai-bedrock 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stache_ai_bedrock-0.2.0.tar.gz | 20.7 kB | Without provenance | Details for stache_ai_bedrock-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stache_ai_bedrock-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for stache_ai_bedrock-0.2.0-py3-none-any.whl |
Total release size: 33.6 kB
Release files / stache_ai_bedrock-0.2.0.tar.gz
| Download URL | stache_ai_bedrock-0.2.0.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98589ede97d5e272c624601ee89d72228fb20e1007f59c707b1b056371ca16d5
|
|
BLAKE2b-256 checksum How to use checksums |
a9f232ed2922c44cd7e02297da41b38547c88f995ac35077586b42c14e1c81b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / stache_ai_bedrock-0.2.0-py3-none-any.whl
| Download URL | stache_ai_bedrock-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdca060bc361918129b7ef9d30674e7618cb71fd9e3b0f0b185df526fd6ff506
|
|
BLAKE2b-256 checksum How to use checksums |
773b10e65d74792f0e1c11a3b6413a6defc2f33b1248602df56e9305805bd43d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for stache-ai-bedrock 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.