Skip to main content
Redis

🧠 Cognee Redis Vector Adapter

Blazing fast vector similarity search for Cognee using Redis

License: Apache 2.0 Language

Powered by RedisVL

Cognee    RedisVL Docs    Examples    Support

Features

  • Full support for vector embeddings storage and retrieval
  • Batch / pipeline operations for efficient processing
  • Automatic embedding generation via configurable embedding engines
  • JSON payload serialization with UUID support
  • Comprehensive error handling

Installation

If published, the package can be simply installed via pip:

pip install cognee-community-vector-adapter-redis

In case it is not published yet, you can use poetry to locally build the adapter package:

pip install poetry
poetry install # run this command in the directory containing the pyproject.toml file

Prerequisites

You need a Redis instance with the Redis Search module enabled. You can use:

  1. Redis:

    docker run -d --name redis -p 6379:6379 redis:8.0.2
    
  2. Redis Cloud with the search module enabled: Redis Cloud

Examples

Checkout the examples/ folder!

uv run examples/example.py

You will need an OpenAI API key to run the example script.

Usage

import os
import asyncio
from cognee import config, prune, add, cognify, search, SearchType

# Import the register module to enable Redis support
from cognee_community_vector_adapter_redis import register


async def main():
    # Configure Redis as vector database
    config.set_vector_db_config(
        {
            "vector_db_provider": "redis",
            "vector_db_url": os.getenv("VECTOR_DB_URL", "redis://localhost:6379"),
            "vector_db_key": os.getenv("VECTOR_DB_KEY", "your-api-key"),  # Optional
        }
    )

    # Optional: Clean previous data
    await prune.prune_data()
    await prune.prune_system()

    # Add your content
    await add("""
    Natural language processing (NLP) is an interdisciplinary
    subfield of computer science and information retrieval.
    """)

    # Process with cognee
    await cognify()

    # Search
    search_results = await search(
        query_type=SearchType.GRAPH_COMPLETION, query_text="Tell me about NLP"
    )

    for result in search_results:
        print("Search result:", result)


if __name__ == "__main__":
    asyncio.run(main())

Configuration

Configure Redis as your vector database in cognee:

  • vector_db_provider: Set to "redis"
  • vector_db_url: Redis connection URL (e.g., "redis://localhost:6379")
  • vector_db_key: Optional API key parameter (for compatibility, not used by Redis)

Environment Variables

Set the following environment variables or pass them directly in the config:

export VECTOR_DB_URL="redis://localhost:6379"
export VECTOR_DB_KEY="optional-key"  # Not used by Redis

Connection URL Examples

# Local Redis
config.set_vector_db_config(
    {"vector_db_provider": "redis", "vector_db_url": "redis://localhost:6379"}
)

# Redis with authentication
config.set_vector_db_config(
    {"vector_db_provider": "redis", "vector_db_url": "redis://user:password@localhost:6379"}
)

# Redis with SSL
config.set_vector_db_config(
    {"vector_db_provider": "redis", "vector_db_url": "rediss://localhost:6380"}
)

Requirements

  • Python >= 3.11, <= 3.13
  • redisvl >= 0.6.0, <= 1.0.0
  • cognee == 1.4.2

Advanced Usage

For direct adapter usage (advanced users only):

from cognee.infrastructure.databases.vector.embeddings.EmbeddingEngine import EmbeddingEngine
from cognee_community_vector_adapter_redis import RedisAdapter
from cognee.infrastructure.engine import DataPoint

# Initialize embedding engine and adapter
embedding_engine = EmbeddingEngine(model="your-model")
redis_adapter = RedisAdapter(url="redis://localhost:6379", embedding_engine=embedding_engine)

# Direct adapter operations
await redis_adapter.create_collection("my_collection")
data_points = [DataPoint(id="1", text="Hello", metadata={"index_fields": ["text"]})]
await redis_adapter.create_data_points("my_collection", data_points)
results = await redis_adapter.search("my_collection", query_text="Hello", limit=10)

Error Handling

The adapter includes comprehensive error handling:

  • VectorEngineInitializationError: Raised when required parameters are missing
  • CollectionNotFoundError: Raised when attempting operations on non-existent collections
  • InvalidValueError: Raised for invalid query parameters
  • Graceful handling of connection failures and embedding errors

Troubleshooting

Common Issues

  1. Connection Errors: Ensure Redis is running and accessible at the specified URL
  2. Search Module Missing: Make sure Redis has the Search module enabled
  3. Embedding Dimension Mismatch: Verify embedding engine dimensions match index configuration
  4. Collection Not Found: Always create collections before adding data points

Debug Logging

The adapter uses Cognee's logging system. Enable debug logging to see detailed operation logs:

import logging

logging.getLogger("RedisAdapter").setLevel(logging.DEBUG)

Development

To contribute or modify the adapter:

  1. Clone the repository and cd into the redis folder
  2. Install dependencies: uv sync --all-extras
  3. Make sure a Redis instance is running (see above)
  4. Make your changes, test, and submit a PR

Metadata

Release files for cognee-community-vector-adapter-redis 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cognee-community-vector-adapter-redis 0.3.0
File Size Uploaded Provenance
cognee_community_vector_adapter_redis-0.3.0.tar.gz 303.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cognee-community-vector-adapter-redis 0.3.0
File Interpreter ABI Platform
cognee_community_vector_adapter_redis-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 312.5 kB

Release files / cognee_community_vector_adapter_redis-0.3.0.tar.gz

Download URL cognee_community_vector_adapter_redis-0.3.0.tar.gz
Size 303.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ed9f8edc01ca85d825c8e650a61ef9c8cb735bf6ca06c6f73f62bd881862d72d
BLAKE2b-256 checksum
How to use checksums
af3eb2bab294ba0a1b74ce33ae976fbf5f09d016da589677e089e0ae2169a57f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0

Release files / cognee_community_vector_adapter_redis-0.3.0-py3-none-any.whl

Download URL cognee_community_vector_adapter_redis-0.3.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb498afafc8e925e9c0ed5251c698510ec0cf14d1201859c2658ae12f623605b
BLAKE2b-256 checksum
How to use checksums
bf3834894da44245893c826369154ac47d8e8953a8a6303381a8f8b4dbb711e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.10.18 Darwin/24.1.0

Security for cognee-community-vector-adapter-redis 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page