rgenai - Rust AWS Bedrock Client Library
RGenAi is a Rust library for AWS Bedrock that provides easy-to-use clients for text generation, image generation, embeddings, and vector storage. Built with performance, type safety, and developer experience in mind.
🚀 Features
🤖 AI Model Support
- Text Generation: Support for multiple models including:
- Amazon Titan
- Anthropic Claude (with Claude 4 support with profile inference)
- Meta Llama
- Mistral
- AI21
- Cohere
- Image Generation: Amazon Titan Image Generator
- Embeddings: Amazon Titan Embed model
- Streaming: Real-time text generation with async streams
🗄️ Vector Storage Backend
- PostgreSQL with pgvector extension (Primary supported backend)
- Note: Pinecone and Upstash integrations are planned but not currently functional
🔧 Advanced Features
- RAG (Retrieval Augmented Generation): Built-in context retrieval and generation
- Semantic Search: Vector similarity search with PostgreSQL/pgvector
- Beautiful Logging: Structured logging with emojis and colors
- Profile Inference: Automatic model profile selection
- Configuration Management: Environment-based configuration
📦 Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
# For PostgreSQL vector storage support
= { = "0.1.0", = ["postgres"] }
Feature Flags
postgres- Enable PostgreSQL with pgvector support (Recommended)pinecone- Pinecone support (Coming soon)upstash- Upstash support (Coming soon)
🏁 Quick Start
Basic Text Generation
use ;
async
Vector Storage with PostgreSQL
use ;
use HashMap;
async
🎛️ Configuration
Environment Variables
# AWS Configuration
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
# PostgreSQL Configuration (Required for vector storage)
USE_PSQL=true
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=password
POSTGRES_DATABASE=vectordb
# Application Configuration
PORT=8080
PostgreSQL Setup
- Install PostgreSQL and pgvector extension
- Create database and enable extension:
;
\c vectordb
CREATE EXTENSION vector;
- The library will automatically create required tables and indexes
🤖 Default Models
When no model_id is provided, the library uses these defaults:
- Text Generation:
amazon.titan-text-express-v1 - Image Generation:
amazon.titan-image-generator-v1 - Embeddings:
amazon.titan-embed-text-v1
📝 Logging
use ;
let logger_config = new
.with_level
.with_colors
.with_file_output;
init_with_config?;
🛠️ Error Handling
use ;
match client.text.generate.await
🔍 Known Limitations
- Currently, only PostgreSQL with pgvector is fully supported for vector storage
- Pinecone and Upstash integrations are in development
- Some advanced model parameters may not be exposed yet
🤝 Contributing
Contributions are welcome! Priority areas:
- Implementing Pinecone and Upstash storage backends
- Adding more model parameter controls
- Improving documentation and examples
- Adding tests and benchmarks
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
📞 Support
- Documentation: docs.rs/rgenai
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ by DevMaan707 - Empowering Rust AI applications 🦀