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.
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.
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.
from redisvl.utils.vectorize import CohereTextVectorizer
# set COHERE_API_KEY in your environment
co = CohereTextVectorizer()
embedding = co.embed(
text="What is the capital city of France?",
input_type="search_query"
)
embeddings = co.embed_many(
texts=["my document chunk content", "my other document chunk content"],
input_type="search_document"
)
Learn more about using vectorizers in your embedding workflows.
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 applied.ai@redis.com. 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?",
response="Paris"
)
# 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"])
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.get_recent(top_k=1)
# >>> [{"role": "llm", "content": "I don't know", "metadata": {"model": "gpt-4"}}]
# Get relevant chat history (powered by vector search)
history.get_relevant("weather", top_k=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
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.
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.
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:
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.
Alternatives
Use instead of redisvl: tools that do the same job, closest first.