Vectra — The Unified Vector Database Client for Ruby
Source: Dev.to
Vectra — Unified Vector Database Client for Ruby (Pinecone, Qdrant, Weaviate, pgvector, and more)
If you’ve ever built AI applications in Ruby—semantic search, RAG, recommendation engines, or embedding queries—you know how quickly it becomes tedious to support multiple vector databases. Each provider has its own API, client, and quirks.
Vectra solves this problem by providing a single, unified API for all popular vector DBs, freeing you from vendor lock‑in. Write your code once and switch backends effortlessly—Pinecone, Qdrant, Weaviate, and even PostgreSQL with pgvector.
- GitHub Repository: https://github.com/stokry/vectra/
- Documentation: https://vectra-docs.netlify.app/
Why Vectra?
- Provider‑agnostic API – One set of methods (
upsert,query,delete, etc.) works across all vendors. - Support for multiple databases – Pinecone, Qdrant, Weaviate, pgvector, all through the same client.
- Production‑ready – Retry logic, configurable backoff, observability via metrics, and ready‑to‑use classes for production workloads.
- Rails integration –
has_vectorDSL for ActiveRecord models; embedding fields can be automatically indexed and searched. - Well‑documented gem – Guides, YARD documentation, and examples for each provider.
Example usage
require 'vectra'
# Initialize client for any provider
client = Vectra::Client.new(
provider: :pinecone,
api_key: ENV['PINECONE_API_KEY'],
environment: 'us-west-4'
)
# Upsert an embedding
client.upsert(
vectors: [
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Hello' } }
]
)
# Query for similar vectors
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
results.each { |m| puts "#{m.id}: #{m.score}" }
# Delete
client.delete(ids: ['doc-1'])
The same API works without changes if you switch the client to Qdrant, Weaviate, or pgvector.
When Vectra is Useful
- Building applications with semantic search
- Implementing RAG (retrieval‑augmented generation) with embeddings
- Avoiding vendor lock‑in across vector databases
- Having a consistent Ruby API surface for all vector databases
Where to Find It
- GitHub: https://github.com/stokry/vectra/
- Documentation: https://vectra-docs.netlify.app/