Cognee Valkey Vector Adapter
A Valkey vector database adapter for Cognee using Valkey Glide, providing high-performance vector storage and retrieval for AI memory applications. Compared to the Redis adapter, Valkey offers a fully open-source, community-driven architecture without the licensing restrictions of Redis. Using Valkey Glide ensures efficient async operations and native support for Valkey’s enhancements, providing optimal compatibility and performance when running on Valkey, making it the best choice for teams adopting Valkey as their primary in-memory vector solution.
Features
- Full support for vector embeddings storage and retrieval
- Batch / pipeline operations for efficient processing
- Automatic embedding generation via configurable embedding engines
- Comprehensive error handling
Installation
If published, the package can be simply installed via pip:
pip install cognee-community-vector-adapter-valkey
In case it is not published yet, you can use poetry to locally build the adapter package:
pip install uv
uv sync --all-extras
Prerequisites
You need a Valkey instance with the Valkey Search module enabled. You can use:
- Valkey:
docker run -d --name valkey -p 6379:6379 valkey/valkey-bundle
Examples
Checkout the examples/ folder!
uv run examples/example.py
You will need an OpenAI API key to run the example script.
Configuration
Configure Valkey as your vector database in cognee:
vector_db_provider: Set to "valkey"vector_db_url: Valkey connection URL (e.g., "valkey://localhost:6379")
Environment Variables
Set the following environment variables or pass them directly in the config:
export VECTOR_DB_URL="valkey://localhost:6379"
Connection URL Examples
# Local Valkey
config.set_vector_db_config(
{"vector_db_provider": "valkey", "vector_db_url": "valkey://localhost:6379"}
)
# Valkey with authentication
config.set_vector_db_config(
{"vector_db_provider": "valkey", "vector_db_url": "valkey://user:password@localhost:6379"}
)
Requirements
- Python >= 3.11, <= 3.13
- valkey-glide >= 2.1.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_valkey import ValkeyAdapter
from cognee.infrastructure.engine import DataPoint
# Initialize embedding engine and adapter
embedding_engine = EmbeddingEngine(model="your-model")
valkey_adapter = ValkeyAdapter(url="valkey://localhost:6379", embedding_engine=embedding_engine)
# Direct adapter operations
await valkey_adapter.create_collection("my_collection")
data_points = [DataPoint(id="1", text="Hello", metadata={"index_fields": ["text"]})]
await valkey_adapter.create_data_points("my_collection", data_points)
results = await valkey_adapter.search("my_collection", query_text="Hello", limit=10)
Error Handling
The adapter includes comprehensive error handling:
VectorEngineInitializationError: Raised when required parameters are missingCollectionNotFoundError: Raised when attempting operations on non-existent collectionsInvalidValueError: Raised for invalid query parameters- Graceful handling of connection failures and embedding errors
Troubleshooting
Common Issues
- Connection Errors: Ensure Valkey is running and accessible at the specified URL
- Search Module Missing: Make sure Valkey has the Search module enabled
- Embedding Dimension Mismatch: Verify embedding engine dimensions match index configuration
- 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("ValkeyAdapter").setLevel(logging.DEBUG)
Development
To contribute or modify the adapter:
- Clone the repository and
cdinto thevalkeyfolder - Install dependencies:
uv sync --all-extras - Make sure a Valkey instance is running (see above)
- Make your changes, test, and submit a PR
Metadata
Release files for cognee-community-vector-adapter-valkey 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cognee_community_vector_adapter_valkey-0.2.0.tar.gz | 348.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognee_community_vector_adapter_valkey-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 362.0 kB
Release files / cognee_community_vector_adapter_valkey-0.2.0.tar.gz
| Download URL | cognee_community_vector_adapter_valkey-0.2.0.tar.gz |
|---|---|
| Size | 348.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5287ba5b6f8c0751709f0a60a5469bdf591d46423296a48a37db7ba504a565e
|
|
BLAKE2b-256 checksum How to use checksums |
818a2eaf57de91058a7074800f883154912bb8e32a44bb5db5aa2e3883796a9c
|
| 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_valkey-0.2.0-py3-none-any.whl
| Download URL | cognee_community_vector_adapter_valkey-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cf76218516af9f392ec12fdc9a5b749fd6a6608240e28e5d1ae1491ebc1a8d4
|
|
BLAKE2b-256 checksum How to use checksums |
b33e10ba4a6da8680be71ed1381605244e2e8b97854532613ab3e5a0d2dc964d
|
| 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-valkey 0.2.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.