0.0
No release in over 3 years
Vectra provides a unified interface to work with multiple vector database providers including Pinecone, Qdrant, Weaviate, and PostgreSQL with pgvector. Write once, switch providers easily.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.5
~> 13.0
~> 3.12
~> 1.57
~> 0.22
~> 6.2
~> 3.19
~> 0.9
>= 2.1

Runtime

 Project Readme

Vectra

Gem Version CI codecov License: MIT

A unified Ruby client for vector databases. Write once, switch providers seamlessly.

📖 Documentation: vectra-docs.netlify.app

Supported Providers

Provider Type Status
Pinecone Managed Cloud ✅ Supported
Qdrant Open Source ✅ Supported
Weaviate Open Source ✅ Supported
pgvector PostgreSQL ✅ Supported

Installation

gem 'vectra-client'
bundle install

Quick Start

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'])

Provider Examples

# Pinecone
client = Vectra.pinecone(api_key: ENV['PINECONE_API_KEY'], environment: 'us-west-4')

# Qdrant (local)
client = Vectra.qdrant(host: 'http://localhost:6333')

# Qdrant (cloud)
client = Vectra.qdrant(host: 'https://your-cluster.qdrant.io', api_key: ENV['QDRANT_API_KEY'])

# Weaviate
client = Vectra.weaviate(host: 'http://localhost:8080', api_key: ENV['WEAVIATE_API_KEY'])

# pgvector (PostgreSQL)
client = Vectra.pgvector(connection_url: 'postgres://user:pass@localhost/mydb')

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_vector DSL

Rails Integration

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)

Development

git clone https://github.com/stokry/vectra.git
cd vectra
bundle install
bundle exec rspec
bundle exec rubocop

Contributing

Bug reports and pull requests welcome at github.com/stokry/vectra.

License

MIT License - see LICENSE file.