
Store and Query Vectors
OfficialFreeEfficiently manage vector embeddings with Amazon S3 Vectors.
Free · Opens the source repo
What Store and Query Vectors does
Amazon S3 Vectors is a specialized AWS service designed for the storage and querying of vector embeddings at scale. This service is optimized for long-term storage, providing subsecond latency for cold queries and as low as 100ms for warm queries. It is particularly suited for applications that require cost-effective storage solutions for infrequently accessed data, making it a strong choice for scenarios involving retrieval-augmented generation (RAG) and similarity searches.
With S3 Vectors, users can create vector buckets and indexes, store embeddings, and perform semantic searches. The service allows for the integration of metadata filtering, enabling users to enhance their queries with relevant context. The workflow involves verifying dependencies, creating a vector bucket, establishing a vector index, and then storing or querying vectors as needed. Each step is guided, ensuring that users can effectively manage their vector data without ambiguity.
This skill is ideal for developers and data scientists who need to handle vector embeddings efficiently, especially in use cases where real-time querying is not the primary requirement. It is not intended for high-frequency query scenarios, such as those requiring hundreds or thousands of sustained queries per second, where alternatives like OpenSearch would be more appropriate. Users should also consider the limitations regarding querying tabular data, as this is not within the scope of S3 Vectors.
In summary, Amazon S3 Vectors provides a robust framework for storing and querying vector embeddings, making it a valuable tool for projects that require effective management of vector data without the overhead of high-frequency querying demands.
When to use it
Use this skill when you need to store and query vector embeddings infrequently and cost-effectively, especially for RAG or similarity search applications.
When not to use it
Avoid this skill for high-frequency queries or when working with tabular data, as it is not designed for those scenarios.
What you can build with it
Storing Infrequent Vector Data
Use S3 Vectors to store embeddings that are accessed infrequently, optimizing costs while maintaining accessibility.
Performing Semantic Searches
Leverage the querying capabilities of S3 Vectors to conduct semantic searches on your stored vector embeddings.
Integrating with RAG Applications
Utilize S3 Vectors in retrieval-augmented generation (RAG) applications where embedding storage is critical.
How to install Store and Query Vectors
View source1. Install with the skills CLI
npx skills add aws/agent-toolkit-for-aws/storing-and-querying-vectors --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by awsStore and Query Vectors with Amazon S3 Vectors
Overview
Amazon S3 Vectors is a cost-effective AWS service for storing and querying vector embeddings at scale. Optimized for long-term storage with subsecond latency for cold queries, as low as 100ms for warm queries.
Decision Guide
- Hundreds/thousands of sustained queries per second (QPS): Wrong tool. Recommend OpenSearch.
- Hybrid search, aggregations, faceted search: Recommend OpenSearch with S3 Vectors as storage engine. For OpenSearch integration, search AWS docs for
"Using S3 Vectors with OpenSearch Service". - Tiered (bulk + hot): S3 Vectors for storage + OpenSearch Serverless for real-time. See
references/limits-and-patterns.md. - Cost-effective storage, infrequent queries, RAG: S3 Vectors is the right fit. Proceed.
For latest guidance, search AWS docs for "S3 Vectors best practices".
Common Tasks
Classify the request before starting:
- Simple query: Existing index, skip to Step 6
- Standard: You MUST list existing indexes first and suggest reusing if relevant. Else, new index + store vectors, follow Steps 2-6
- Migration or multi-tenant: Read
references/limits-and-patterns.mdfirst, then Steps 2-6
You MUST execute commands using AWS MCP server tools when connected. Fall back to AWS CLI only if AWS MCP is unavailable. You MUST explain each step to the user before executing.
1. Verify Dependencies
Constraints:
- You MUST check whether AWS MCP tools or AWS CLI is available and inform user if missing
- You MUST confirm target AWS region
2. Create a Vector Bucket
You MUST confirm bucket name with user. Names: 3-63 chars, lowercase letters, numbers, hyphens only. Encryption (SSE-S3 default or SSE-KMS for compliance) is immutable after creation.
aws s3vectors create-vector-bucket \
--vector-bucket-name <BUCKET_NAME>
Constraints:
- You MUST explain encryption cannot be changed after creation
- For SSE-KMS, KMS key policy MUST grant
kms:GenerateDataKeyandkms:Decryptto the S3 Vectors service principalindexing.s3vectors.amazonaws.com. You MUST use full KMS key ARN (not alias). Seereferences/limits-and-patterns.mdfor command example.
3. Create a Vector Index
Every parameter is immutable after creation.
Pre-flight checklist (confirm ALL with user):
- Dimension (required, integer 1-4096) -- MUST match embedding model output
- Distance metric (required) --
cosineoreuclidean. Use embedding model's recommended metric; - Non-filterable metadata keys (optional, max 10, 1-63 chars) -- Declare at creation or lose forever. For Bedrock Knowledge Bases integration, search AWS docs for
"S3 Vectors Bedrock Knowledge Bases prerequisites"to get the required key names. - Encryption (optional) -- Inherits from bucket. Override per-index if needed.
aws s3vectors create-index \
--vector-bucket-name <BUCKET_NAME> \
--index-name <INDEX_NAME> \
--dimension <DIM> \
--distance-metric <cosine|euclidean> \
--data-type float32 \
--metadata-configuration '{"nonFilterableMetadataKeys":["<KEY1>","<KEY2>"]}'
Omit --metadata-configuration if no non-filterable keys are needed.
Index names: 3-63 chars, lowercase, numbers, hyphens, dots. Unique within bucket. Filterable metadata: 2 KB limit. Total metadata (filterable + non-filterable combined): 40 KB. See references/metadata-filtering.md.
4. Generate Embeddings (if needed)
Skip to Step 5 (store) or Step 6 (query) if user already has embeddings.
Constraints:
- You MUST ask which embedding model to use if not specified
- You MUST NOT assume a default model
- Dimension MUST match Step 3
- You MUST use the same model for both storing and querying
Generate embeddings with Bedrock invoke-model:
aws bedrock-runtime invoke-model \
--model-id <MODEL_ID> \
--content-type application/json \
--cli-binary-format raw-in-base64-out \
--body '{"inputText": "your text"}' \
invoke-model-output.json
You MUST use --cli-binary-format raw-in-base64-out for CLI v2. Output file is required for CLI. The response key is model-dependent (e.g., embedding for Titan, embeddings for Cohere). For Titan, parse with json.load(open('invoke-model-output.json'))['embedding']. Use embedding array as float32 in put-vectors or query-vectors. For batch embedding generation, use AWS SDK or CLI.
5. Put Vectors
aws s3vectors put-vectors \
--vector-bucket-name <BUCKET_NAME> \
--index-name <INDEX_NAME> \
--vectors '[{"key":"<ID>","data":{"float32":[<EMBEDDING>]},"metadata":{"topic":"science"}}]'
Constraints:
- You MUST NOT exceed 500 vectors per call
- You SHOULD batch vectors for cost optimization
- For bulk operations, You SHOULD use an SDK instead of CLI -- vector payloads may be too large for shell arguments
- You MUST implement retry with backoff on
429 TooManyRequestsException - See
references/limits-and-patterns.mdfor batch patterns
6. Query Vectors
Generate embedding if needed (Step 4), then query:
aws s3vectors query-vectors \
--vector-bucket-name <BUCKET_NAME> \
--index-name <INDEX_NAME> \
--query-vector '{"float32":[<EMBEDDING>]}' \
--top-k 10 \
--return-distance
Optional: add --return-metadata and/or --filter '{"topic":{"$eq":"science"}}' (both require GetVectors permission). See references/metadata-filtering.md.
Example response body: {"vectors": [{"key": "id1", "distance": 0.45, "metadata": {"topic": "science"}}, ...], "distanceMetric": "cosine"}
Constraints:
- Using
--filteror--return-metadatarequires boths3vectors:QueryVectorsANDs3vectors:GetVectorsIAM permissions. Without GetVectors, these options return 403.
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
DimensionMismatch | Dims don't match index | Use matching model, or delete/recreate index (confirm with user -- destroys all vectors). |
403 Forbidden with --filter or --return-metadata | Missing s3vectors:GetVectors | Add s3vectors:GetVectors to IAM policy. |
Fewer results than --top-k | Few vectors match filter | Expected -- filtering is inline. Broaden filter. |
429 TooManyRequestsException | Exceeded per-index rate limits | Retry with backoff. Shard across indexes for sustained throughput. Search AWS docs for "S3 Vectors limitations and restrictions" for current limits. |
AccessDeniedException | Missing s3vectors:* IAM actions | S3 Vectors uses s3vectors:* namespace, not s3:*. Update IAM policy. |
RequestTimeoutException or service unavailable | Request timeout or region not supported | Retry request. For regional availability, search AWS docs for "S3 Vectors limitations and restrictions". |
Additional Resources
- limits-and-patterns.md -- Multi-tenant patterns, batch ingestion, SSE-KMS, migration
- metadata-filtering.md -- Filter operators, non-filterable metadata, Bedrock KB keys
Frequently asked questions about Store and Query Vectors
Similar skills
ClickHouse Logs Queries
Efficiently manage Supabase logs with ClickHouse SQL.
EF Core D2 Database Diagram Generator
Visualize your EF Core models as D2 diagrams effortlessly.
Safe SQL Execution
Ensure secure SQL execution in Supabase applications.
Oracle to PostgreSQL Migration
Identify migration risks between Oracle and PostgreSQL.
SSMA Console
Streamline Oracle to SQL Server migrations with ease.
SQL Performance Optimization
Enhance SQL query efficiency across all databases.
