redis
redis-vl-python
Python

Redis Vector Library (RedisVL) -- the AI-native Python client for Redis.

Last updated Aug 10, 2026
420
Stars
94
Forks
54
Issues
+1
Stars/day
Attention Score
87
Language breakdown
Python 99.8%
Makefile 0.2%
โ–ธ Files click to expand
README

Redis

Redis Vector Library

The AI-native Redis Python client

License: MIT pypi PyPI - Downloads GitHub stars

Code style: black Language GitHub last commit

Documentation โ€ข Recipes โ€ข GitHub


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.

| ๐ŸŽฏ Core Capabilities | ๐Ÿš€ AI Extensions | ๐Ÿ› ๏ธ Dev Utilities | |:---:|:---:|:---:| | Index Management
Schema design, data loading, CRUD ops | Semantic Caching
Reduce LLM costs & boost throughput | CLI
Index management from terminal | | Vector Search
Similarity search with metadata filters | LLM Memory
Agentic AI context management | Async Support
Async indexing and search for improved performance | | Complex Filtering
Combine multiple filter types | Semantic Routing
Intelligent query classification | Vectorizers
8+ embedding provider integrations | | Hybrid Search
Combine semantic & full-text signals | Embedding Caching
Cache embeddings for efficiency | Rerankers
Improve search result relevancy | | | | MCP Server
Expose one or more existing Redis indexes to MCP clients |

๐Ÿ’ช Getting Started

Installation

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

pip install redisvl

Install the MCP server extra when you want to expose one or more existing Redis indexes through MCP:

pip install redisvl[mcp]
For more detailed instructions, visit the installation guide.
For MCP concepts and setup, see the RedisVL MCP docs and the MCP how-to guide.

Redis

Choose from multiple Redis deployment options:

Redis Cloud - Managed cloud database (free tier available)

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

Docker - Local development

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.

Redis Enterprise - Commercial, self-hosted database

Redis Enterprise provides enterprise-grade features for production deployments.

Redis Sentinel - High availability with automatic failover

Configure Redis Sentinel for high availability:

# Connect via Sentinel
redis_url="redis+sentinel://sentinel1:26379,sentinel2:26379/mymaster"

Azure Managed Redis - Fully managed Redis Enterprise on Azure

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

๐Ÿ’ก Tip: Enhance your experience and observability with the free Redis Insight GUI.

Overview

Index Management

  • 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).
Load schema from YAML file
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")

Load schema from Python dictionary

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" } } ] })

> ๐Ÿ“š Learn more about schema design and schema creation.

  • 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.

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.

Quick Reference: Query Types

| Query Type | Use Case | Description | |:---|:---|:---| | VectorQuery | Semantic similarity search | Find similar vectors with optional filters | | RangeQuery | Distance-based search | Vector search within a defined distance range | | FilterQuery | Metadata filtering | Filter and search using metadata fields | | TextQuery | Full-text search | BM25-based keyword search with field weighting | | HybridQuery | Combined search | Combine semantic + full-text signals (Redis 8.4.0+) | | CountQuery | Counting records | Count documents matching filter criteria |

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], vectorfieldname="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:

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], vectorfieldname="embedding", filterexpression=tagfilter & price_filter, num_results=10 ) results = index.query(query)

  • FilterQuery - Standard search using filters and full-text search
  • CountQuery - Count the number of indexed records given attributes
  • TextQuery - Full-text search with support for field weighting and BM25 scoring
Learn more about building complex filtering queries.

Hybrid Search

Combine semantic (vector) search with full-text (BM25) search signals for improved search quality:

  • HybridQuery - Native hybrid search combining text and vector similarity (Redis 8.4.0+):
from redisvl.query import HybridQuery

hybrid_query = HybridQuery( text="running shoes", textfieldname="description", vector=[0.1, 0.2, 0.3], vectorfieldname="embedding", combinati, # or "RRF" num_results=10 ) results = index.query(hybrid_query)

Learn more about hybrid search.

Dev Utilities

Vectorizers

Integrate with popular embedding providers to greatly simplify the process of vectorizing unstructured data for your index and queries.

Supported Vectorizer Providers

from redisvl.utils.vectorize import CohereTextVectorizer

set COHEREAPIKEY in your environment

co = CohereTextVectorizer()

embedding = co.embed( text="What is the capital city of France?", inputtype="searchquery" )

embeddings = co.embed_many( texts=["my document chunk content", "my other document chunk content"], inputtype="searchdocument" )

Learn more about using vectorizers in your embedding workflows.

Rerankers

Integrate with popular reranking providers to improve the relevancy of the initial search results from Redis

Extensions

RedisVL Extensions provide production-ready modules implementing best practices and design patterns for working with LLM memory and agents. These extensions encapsulate learnings from our user community and enterprise customers.

๐Ÿ’ก Have an idea for another extension? Open a PR or reach out to us at . We're always open to feedback.

Semantic Caching

Increase application throughput and reduce the cost of using LLM models in production by leveraging previously generated knowledge with the SemanticCache.

Example: Semantic Cache Usage

from redisvl.extensions.cache.llm import SemanticCache

init cache with TTL and semantic distance threshold

llmcache = SemanticCache( name="llmcache", ttl=360, redis_url="redis://localhost:6379", distance_threshold=0.1 # Redis COSINE distance [0-2], lower is stricter )

store user queries and LLM responses in the semantic cache

llmcache.store( prompt="What is the capital city of France?", resp )

quickly check the cache with a slightly different prompt (before invoking an LLM)

response = llmcache.check(prompt="What is France's capital city?") print(response[0]["response"])
>>> Paris

Learn more about semantic caching for LLMs.

Embedding Caching

Reduce computational costs and improve performance by caching embedding vectors with their associated text and metadata using the EmbeddingsCache.

Example: Embedding Cache Usage

from redisvl.extensions.cache.embeddings import EmbeddingsCache
from redisvl.utils.vectorize import HFTextVectorizer

Initialize embedding cache

embed_cache = EmbeddingsCache( name="embed_cache", redis_url="redis://localhost:6379", ttl=3600 # 1 hour TTL )

Initialize vectorizer with cache

vectorizer = HFTextVectorizer( model="sentence-transformers/all-MiniLM-L6-v2", cache=embed_cache )

First call computes and caches the embedding

embedding = vectorizer.embed("What is machine learning?")

Subsequent calls retrieve from cache (much faster!)

cached_embedding = vectorizer.embed("What is machine learning?")
>>> Cache hit! Retrieved from Redis in <1ms

Learn more about embedding caching for improved performance.

LLM Memory

Improve personalization and accuracy of LLM responses by providing user conversation context. Manage access to memory data using recency or relevancy, powered by vector search with the MessageHistory.

Example: Message History Usage

from redisvl.extensions.message_history import SemanticMessageHistory

history = SemanticMessageHistory( name="my-session", redis_url="redis://localhost:6379", distance_threshold=0.7 )

Supports roles: system, user, llm, tool

Optional metadata field for additional context

history.add_messages([ {"role": "user", "content": "hello, how are you?"}, {"role": "llm", "content": "I'm doing fine, thanks."}, {"role": "user", "content": "what is the weather going to be today?"}, {"role": "llm", "content": "I don't know", "metadata": {"model": "gpt-4"}} ])

Get recent chat history

history.getrecent(topk=1)

>>> [{"role": "llm", "content": "I don't know", "metadata": {"model": "gpt-4"}}]

Get relevant chat history (powered by vector search)

history.getrelevant("weather", topk=1)

>>> [{"role": "user", "content": "what is the weather going to be today?"}]

Filter messages by role

history.get_recent(role="user") # Get only user messages history.get_recent(role=["user", "system"]) # Or multiple roles

Learn more about LLM memory.

Semantic Routing

Build fast decision models that run directly in Redis and route user queries to the nearest "route" or "topic".

Example: Semantic Router Usage

from redisvl.extensions.router import Route, SemanticRouter

routes = [ Route( name="greeting", references=["hello", "hi"], metadata={"type": "greeting"}, distance_threshold=0.3, ), Route( name="farewell", references=["bye", "goodbye"], metadata={"type": "farewell"}, distance_threshold=0.3, ), ]

build semantic router from routes

router = SemanticRouter( name="topic-router", routes=routes, redis_url="redis://localhost:6379", )

router("Hi, good morning")

>>> RouteMatch(name='greeting', distance=0.273891836405)

Learn more about semantic routing.

Command Line Interface

Create, destroy, and manage Redis index configurations from a purpose-built CLI interface: rvl.

$ rvl --help

usage: rvl <command> [<args>]

Redis Vector Library CLI.

Command groups: index Create, inspect, list, and delete Redis search indexes stats Show statistics for an existing Redis search index version Show the installed RedisVL version mcp Run the RedisVL MCP server

Examples: rvl index --help rvl index create -s schema.yaml rvl stats -i user_index rvl mcp --config /path/to/mcp.yaml

Use rvl index --help to see documented subcommands such as create, info, listall, delete, and destroy. Use rvl stats --help to see both index-name and schema-path examples plus the shared Redis connection options for data-plane commands.

Run the MCP server over stdio (default):

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml

Or over Streamable HTTP for remote MCP clients:

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml --transport streamable-http --host 0.0.0.0 --port 8000

Or over SSE:

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml --transport sse --host 0.0.0.0 --port 9000

Use --read-only to expose search without upsert.

Read more about using the CLI and running RedisVL MCP.

MCP Server

RedisVL includes an MCP server that lets MCP-compatible clients search or upsert data in one or more existing Redis indexes through a small, stable tool contract.

The server:

  • connects to one or more existing Redis Search indexes, each addressed by a logical id
  • reconstructs each index's schema from Redis at startup
  • uses each index's configured vectorizer for query embedding and optional upsert embedding
  • exposes list-indexes for discovery, search-records, and (unless every index is read-only) upsert-records
  • supports stdio (default), Streamable HTTP, and SSE transports
A single configured index is the simplest case and works exactly as before โ€” callers omit the index selector. With multiple indexes, clients call list-indexes first and pass the chosen index to search-records and upsert-records.

Run it over stdio (default):

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml

Run it over Streamable HTTP for remote clients:

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml --transport streamable-http --host 0.0.0.0 --port 8000

Use --read-only when clients should only search:

uvx --from redisvl[mcp] rvl mcp --config /path/to/mcp.yaml --read-only

For configuration details, tool arguments, and examples, see the RedisVL MCP docs and the MCP how-to guide.

๐Ÿš€ Why RedisVL?

Redis is a proven, high-performance database that excels at real-time workloads. With RedisVL, you get a production-ready Python client that makes Redis's vector search, caching, and session management capabilities easily accessible for AI applications.

Built on the Redis Python client, RedisVL provides an intuitive interface for vector search, LLM caching, and conversational AI memory - all the core components needed for modern AI workloads.

๐Ÿ˜ Helpful Links

For additional help, check out the following resources:

๐Ÿซฑ๐Ÿผโ€๐Ÿซฒ๐Ÿฝ Contributing

Please help us by contributing PRs, opening GitHub issues for bugs or new feature ideas, improving documentation, or increasing test coverage. Read more about how to contribute!

๐Ÿšง Maintenance

This project is supported by Redis, Inc on a good faith effort basis. To report bugs, request features, or receive assistance, please file an issue.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท redis/redis-vl-python ยท Updated daily from GitHub