Vectra
A unified Ruby client for vector databases. Write once, switch providers seamlessly.
Vectra is a production-ready Ruby gem that provides a consistent interface for working with multiple vector database providers. Whether you're using Pinecone, Qdrant, Weaviate, or pgvector, Vectra allows you to switch between providers with minimal code changes.
Supported Providers
| Provider | Type | Status |
|---|---|---|
| Pinecone | Managed Cloud | ✅ Supported |
| Qdrant | Open Source | ✅ Supported |
| Weaviate | Open Source | ✅ Supported |
| pgvector | PostgreSQL | ✅ Supported |
Key Features
- Provider Agnostic: Switch providers with one line change
- Production Ready: Ruby 3.2+, 95%+ test coverage
- Resilient: Retry logic with exponential backoff
- Observable: Datadog & New Relic instrumentation
- Rails Ready: ActiveRecord integration with
has_vectorDSL
Usage Example
require 'vectra'
# Initialize client (works with any provider)
client = Vectra::Client.new(
provider: :pinecone,
api_key: ENV['PINECONE_API_KEY'],
environment: 'us-west-4'
)
# Upsert vectors
client.upsert(
vectors: [
{ id: 'doc-1', values: [0.1, 0.2, 0.3], metadata: { title: 'Hello' } },
{ id: 'doc-2', values: [0.4, 0.5, 0.6], metadata: { title: 'World' } }
]
)
# Search
results = client.query(vector: [0.1, 0.2, 0.3], top_k: 5)
results.each { |match| puts "#{match.id}: #{match.score}" }
# Delete
client.delete(ids: ['doc-1', 'doc-2'])
Rails Integration
Vectra includes ActiveRecord integration for seamless Rails usage:
class Document < ApplicationRecord
include Vectra::ActiveRecord
has_vector :embedding,
provider: :qdrant,
index: 'documents',
dimension: 1536
end
# Auto-indexes on save
doc = Document.create!(title: 'Hello', embedding: [0.1, 0.2, ...])
# Search
Document.vector_search(embedding: query_vector, limit: 10)
Project Status
Vectra is actively maintained and production-ready. The gem has comprehensive test coverage and supports all major vector database providers, making it an ideal choice for Ruby applications requiring vector search capabilities.

