Bedrock provider for Stache AI
Project description
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
Project details
Release history Release notifications | RSS feed
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 stache_ai_bedrock-0.1.2.tar.gz.
File metadata
- Download URL: stache_ai_bedrock-0.1.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d9f6b730745112f18b497b5b2c5a76af24a6837249f749837c672e185656565
|
|
| MD5 |
c121245eab15e156439e3cc0ca33f363
|
|
| BLAKE2b-256 |
cb7a8731023efa84a848826e5f71999637cf714dcab0028bc87058d8c721ec07
|
File details
Details for the file stache_ai_bedrock-0.1.2-py3-none-any.whl.
File metadata
- Download URL: stache_ai_bedrock-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eaa7e10d19d7af34da2b8c4c52e4fe5fd110389f614b849b9b96dfc1da1d3bc
|
|
| MD5 |
9a99b0d07d0184ef96f0ac7828303c79
|
|
| BLAKE2b-256 |
a946713406a94c0aa2ab0027a38f8fd4bf1dcbcff52eed4d570bad56fa9fe77a
|