Skip to main content

stache-ai-s3vectors

S3 Vectors provider for Stache AI - serverless vector database using Amazon S3 Vectors.

Installation

pip install stache-ai-s3vectors

Usage

Install the package and configure the provider in your settings:

from stache_ai.config import Settings

settings = Settings(
    vectordb_provider="s3vectors",
    s3vectors_bucket_name="my-vector-bucket",  # Required
    s3vectors_region="us-east-1",              # Optional, defaults to AWS_REGION
)

The provider will be automatically discovered via entry points.

Environment Variables

Variable Description Default
VECTORDB_PROVIDER Set to s3vectors Required
S3VECTORS_BUCKET_NAME S3 Vectors bucket name Required
S3VECTORS_REGION AWS region for S3 Vectors us-east-1
AWS_REGION Fallback region us-east-1

IAM Permissions

The S3 Vectors provider requires specific IAM permissions. Note that S3 Vectors uses its own service namespace (s3vectors:), not the standard S3 namespace.

Minimum Required Permissions

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3vectors:GetVectorBucket"
      ],
      "Resource": "arn:aws:s3vectors:REGION:ACCOUNT:vector-bucket/BUCKET_NAME"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3vectors:CreateIndex",
        "s3vectors:GetIndex",
        "s3vectors:ListIndexes",
        "s3vectors:PutVectors",
        "s3vectors:QueryVectors",
        "s3vectors:ListVectors",
        "s3vectors:DeleteVectors",
        "s3vectors:GetVectors"
      ],
      "Resource": "arn:aws:s3vectors:REGION:ACCOUNT:vector-bucket/BUCKET_NAME/index/*"
    }
  ]
}

SAM Template Example

Resources:
  S3VectorsBucket:
    Type: AWS::S3Vectors::VectorBucket
    Properties:
      VectorBucketName: !Sub '${AWS::StackName}-vectors'

  StacheFunction:
    Type: AWS::Serverless::Function
    Properties:
      Environment:
        Variables:
          VECTORDB_PROVIDER: s3vectors
          S3VECTORS_BUCKET_NAME: !GetAtt S3VectorsBucket.VectorBucketName
      Policies:
        - Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Action:
                - s3vectors:GetVectorBucket
              Resource:
                - !GetAtt S3VectorsBucket.VectorBucketArn
            - Effect: Allow
              Action:
                - s3vectors:CreateIndex
                - s3vectors:GetIndex
                - s3vectors:ListIndexes
                - s3vectors:PutVectors
                - s3vectors:QueryVectors
                - s3vectors:ListVectors
                - s3vectors:DeleteVectors
                - s3vectors:GetVectors
              Resource:
                - !Sub '${S3VectorsBucket.VectorBucketArn}/index/*'

Terraform Example

data "aws_iam_policy_document" "s3vectors" {
  statement {
    effect = "Allow"
    actions = [
      "s3vectors:GetVectorBucket"
    ]
    resources = [
      "arn:aws:s3vectors:${var.region}:${data.aws_caller_identity.current.account_id}:vector-bucket/${var.bucket_name}"
    ]
  }

  statement {
    effect = "Allow"
    actions = [
      "s3vectors:CreateIndex",
      "s3vectors:GetIndex",
      "s3vectors:ListIndexes",
      "s3vectors:PutVectors",
      "s3vectors:QueryVectors",
      "s3vectors:ListVectors",
      "s3vectors:DeleteVectors",
      "s3vectors:GetVectors"
    ]
    resources = [
      "arn:aws:s3vectors:${var.region}:${data.aws_caller_identity.current.account_id}:vector-bucket/${var.bucket_name}/index/*"
    ]
  }
}

Important Notes

Bucket Name vs ARN

The provider uses the bucket name (not the ARN) for API calls, but IAM policies require the full ARN format:

  • Environment variable: S3VECTORS_BUCKET_NAME=my-vectors-bucket (just the name)
  • IAM Resource: arn:aws:s3vectors:us-east-1:123456789012:vector-bucket/my-vectors-bucket (full ARN)

S3 Vectors bucket names are globally unique across AWS, so include your account ID or a unique prefix:

# SAM template example
VectorBucketName: !Sub '${AWS::StackName}-vectors-${AWS::AccountId}'

Metadata Limits

S3 Vectors has metadata size limits:

  • Filterable metadata: 2KB limit (used in query filters)
  • Non-filterable metadata: Part of 40KB total (returned but can't filter)

When creating indexes, specify large fields like text as non-filterable:

aws s3vectors create-index \
  --vector-bucket-name my-bucket \
  --index-name my-index \
  --dimension 1024 \
  --distance-metric cosine \
  --metadata-configuration 'nonFilterableMetadataKeys=["text"]'

list_vectors Limitation

The list_vectors API does NOT support metadata filtering - only query_vectors supports filtering. For operations that need to filter without a query vector, the provider lists all vectors and filters client-side.

Requirements

  • Python >= 3.10
  • stache-ai >= 0.1.0
  • boto3 >= 1.34.0

Metadata

Release files for stache-ai-s3vectors 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stache-ai-s3vectors 0.2.0
File Size Uploaded Provenance Actions
stache_ai_s3vectors-0.2.0.tar.gz 22.3 kB Without provenance Details for stache_ai_s3vectors-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stache-ai-s3vectors 0.2.0
File Interpreter ABI Platform Actions
stache_ai_s3vectors-0.2.0-py3-none-any.whl Python 3 none any Details for stache_ai_s3vectors-0.2.0-py3-none-any.whl

Total release size: 33.5 kB

Release files / stache_ai_s3vectors-0.2.0.tar.gz

Download URL stache_ai_s3vectors-0.2.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e77d6132151237d5aa81e07f19e65bf53887e0e26c32ff448af0a41fbce0c68e
BLAKE2b-256 checksum
How to use checksums
e38e3f3e09560b7651e8898891cc1cda1bb50c6e336fe0ddfab38b21bdd0c631
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_s3vectors-0.2.0-py3-none-any.whl

Download URL stache_ai_s3vectors-0.2.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06c568ea9b0e029705a64c64f640babde1209d10346e07b12c9b0a64d2444e0d
BLAKE2b-256 checksum
How to use checksums
0b1bd0a37f37cf22cbe060819ccc6e5826c10a4a16bfc95b2417d20a78ca9b5b
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-s3vectors 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page