Give AlbumentationsX a star on GitHub — it powers this leaderboard

Star on GitHub

redisvl

Python client library and CLI for using Redis as a vector database

Rank: #3145Downloads: 1,553,623 (30 days)Stars: 377Forks: 74

Description

<div align="center"> <img width="300" src="https://raw.githubusercontent.com/redis/redis-vl-python/main/docs/_static/Redis_Logo_Red_RGB.svg" alt="Redis"> <h1>Redis Vector Library</h1> <p><strong>The AI-native Redis Python client</strong></p> </div> <div align="center">

License: MIT pypi PyPI - Downloads GitHub stars

Code style: black Language GitHub last commit

DocumentationRecipesGitHub

</div>

Introduction

Redis Vector Library (RedisVL) is the production-ready Python client for AI applications built on Redis. Lightning-fast vector search meets enterprise-grade reliability.

Perfect for building RAG pipelines with real-time retrieval, AI agents with memory and semantic routing, and recommendation systems with fast search and reranking.

<div align="center">
🎯 Core Capabilities🚀 AI Extensions🛠️ Dev Utilities
Index Management<br/>Schema design, data loading, CRUD opsSemantic Caching<br/>Reduce LLM costs & boost throughputCLI<br/>Index management from terminal
Vector Search<br/>Similarity search with metadata filtersLLM Memory<br/>Agentic AI context managementAsync Support<br/>Async indexing and search for improved performance
Complex Filtering<br/>Combine multiple filter typesSemantic Routing<br/>Intelligent query classificationVectorizers<br/>8+ embedding provider integrations
Hybrid Search<br/>Combine semantic & full-text signalsEmbedding Caching<br/>Cache embeddings for efficiencyRerankers<br/>Improve search result relevancy
</div>

💪 Getting Started

Installation

Install redisvl into your Python (>=3.9) environment using pip:

pip install redisvl

For more detailed instructions, visit the installation guide.

Redis

Choose from multiple Redis deployment options:

<details> <summary><b>Redis Cloud</b> - Managed cloud database (free tier available)</summary>

Redis Cloud offers a fully managed Redis service with a free tier, perfect for getting started quickly.

</details> <details> <summary><b>Docker</b> - Local development</summary>

Run Redis locally using Docker:

docker run -d --name redis -p 6379:6379 redis:latest

This runs Redis 8+ with built-in vector search capabilities.

</details> <details> <summary><b>Redis Enterprise</b> - Commercial, self-hosted database</summary>

Redis Enterprise provides enterprise-grade features for production deployments.

</details> <details> <summary><b>Redis Sentinel</b> - High availability with automatic failover</summary>

Configure Redis Sentinel for high availability:

# Connect via Sentinel
redis_url="redis+sentinel://sentinel1:26379,sentinel2:26379/mymaster"
</details> <details> <summary><b>Azure Managed Redis</b> - Fully managed Redis Enterprise on Azure</summary>

Azure Managed Redis provides fully managed Redis Enterprise on Microsoft Azure.

</details>

💡 Tip: Enhance your experience and observability with the free Redis Insight GUI.

Overview

Index Management

  1. Design a schema for your use case that models your dataset with built-in Redis indexable fields (e.g. text, tags, numerics, geo, and vectors).

    <details> <summary><b>Load schema from YAML file</b></summary>
    index:
      name: user-idx
      prefix: user
      storage_type: json
    
    fields:
      - name: user
        type: tag
      - name: credit_score
        type: tag
      - name: job_title
        type: text
        attrs:
          sortable: true
          no_index: false  # Index for search (default)
          unf: false       # Normalize case for sorting (default)
      - name: embedding
        type: vector
        attrs:
          algorithm: flat
          dims: 4
          distance_metric: cosine
          datatype: float32
    
    from redisvl.schema import IndexSchema
    
    schema = IndexSchema.from_yaml("schemas/schema.yaml")
    
    </details> <details> <summary><b>Load schema from Python dictionary</b></summary>
    from redisvl.schema import IndexSchema
    
    schema = IndexSchema.from_dict({
        "index": {
            "name": "user-idx",
            "prefix": "user",
            "storage_type": "json"
        },
        "fields": [
            {"name": "user", "type": "tag"},
            {"name": "credit_score", "type": "tag"},
            {
                "name": "job_title",
                "type": "text",
                "attrs": {
                    "sortable": True,
                    "no_index": False,  # Index for search
                    "unf": False        # Normalize case for sorting
                }
            },
            {
                "name": "embedding",
                "type": "vector",
                "attrs": {
                    "algorithm": "flat",
                    "datatype": "float32",
                    "dims": 4,
                    "distance_metric": "cosine"
                }
            }
        ]
    })
    
    </details>

    📚 Learn more about schema design and schema creation.

  2. Create a SearchIndex class with an input schema to perform admin and search operations on your index in Redis:

    from redis import Redis
    from redisvl.index import SearchIndex
    
    # Define the index
    index = SearchIndex(schema, redis_url="redis://localhost:6379")
    
    # Create the index in Redis
    index.create()
    

    An async-compatible index class also available: AsyncSearchIndex.

  3. Load and fetch data to/from your Redis instance:

    data = {"user": "john", "credit_score": "high", "embedding": [0.23, 0.49, -0.18, 0.95]}
    
    # load list of dictionaries, specify the "id" field
    index.load([data], id_field="user")
    
    # fetch by "id"
    john = index.fetch("john")
    

Retrieval

Define queries and perform advanced searches over your indices, including vector search, complex filtering, and hybrid search combining semantic and full-text signals.

<details> <summary><b>Quick Reference: Query Types</b></summary>
Query TypeUse CaseDescription
VectorQuerySemantic similarity searchFind similar vectors with optional filters
RangeQueryDistance-based searchVector search within a defined distance range
FilterQueryMetadata filteringFilter and search using metadata fields
TextQueryFull-text searchBM25-based keyword search with field weighting
HybridQueryCombined searchCombine semantic + full-text signals (Redis 8.4.0+)
CountQueryCounting recordsCount documents matching filter criteria
</details>

Vector Search

  • VectorQuery - Flexible vector queries with customizable filters enabling semantic search:

    from redisvl.query import VectorQuery
    
    query = VectorQuery(
      vector=[0.16, -0.34, 0.98, 0.23],
      vector_field_name="embedding",
      num_results=3,
      # Optional: tune search performance with runtime parameters
      ef_runtime=100  # HNSW: higher for better recall
    )
    # run the vector search query against the embedding field
    results = index.query(query)
    
  • RangeQuery - Vector search within a defined range paired with customizable filters

Complex Filtering

Build complex filtering queries by combining multiple filter types (tags, numerics, text, geo, timestamps) using logical operators:

```python
from redisvl.query import VectorQuery
from redisvl.query.filter import Tag, Num

# Combine multiple filter types
tag_filter = Tag("user") == "john"
price_filter = Num("price") >= 100

# Create complex filtering query with combined filters
query = VectorQuery(
    vector=[0.16, -0.34, 0.98, 0.23],
    vector_field_name="embedding",
    filter_expression=tag_filter & price_filter,
    num_results=10
)
results = index.query(query)
```