Adding a New Vector Store to cognee
This guide describes how to integrate a new vector database engine into cognee, following the same pattern used for existing engines (e.g., Weaviate, Qdrant, Milvus, PGVector, LanceDB).Repository Options
Cognee used both the core and the community repositories to host vector-database adapters. 🚨 From now on every vector-database adapter – except LanceDB – will live in the cognee-community repository.Qdrant have already been migrated from the core library and the remaining adapters will follow shortly. You can find Redis, OpenSearch, and Azure AI Search integrations available in the community repo.
Therefore all new adapter contributions must target the community repository.The core repository will keep only the built-in LanceDB integration.
For Community Repository
To add a new adapter to cognee-community:- Fork and clone the cognee-community repository
- Create your adapter in
packages/vector/<engine_name>/cognee_community_vector_adapter_<engine_name>/ - Inside that directory add
__init__.py,<engine_name>_adapter.py, andregister.py(see the Redis implementation as an example). - At the package root
packages/<engine_name>/add__init__.py,pyproject.toml, andREADME.md. - Submit a pull request to the community repository
Why cognee-community?
cognee-community is the extension hub for Cognee.Anything that is not part of the core lives here—adapters for third-party databases, pipelines, community contributed additional tasks, etc.
Placing your adapter in this repository means:
- Your code is released under the community license and can evolve independently of the core.
- It can be installed with
pip install cognee-community-vector-adapter-(engine_name)without pulling in heavyweight drivers for users who don’t need them. For example, for Qdrant it ispip install cognee-community-vector-adapter-qdrant - These packages can be called with the cognee core package using the registration step described below.
packages/* in the community repo—each sub-folder represents a separate provider implemented in exactly the way you are about to do.
1. Implement the Adapter
File:packages/vector/<engine_name>/cognee_community_vector_adapter_<engine_name>/<engine_name>_adapter.py
Your adapter must implement the VectorDBInterface protocol, implementing all required methods for collection management, data point operations, and search functionality. Here is a sample skeleton with placeholders:
VectorDBInterface. Reference the existing adapters like QDrantAdapter for more comprehensive examples.
2. Test with a Dedicated Script
File:packages/vector/engine_name/examples/example.py
Create a script that loads cognee, configures it to use your new <engine_name> provider, and runs basic usage checks. For example:
- Your new adapter can be selected by cognee.
- Data can be added to the vector database.
- Search functionality works correctly.
- The database is empty after a prune operation.
3. Create a Test Workflow
File:.github/workflows/vector_db_tests.yml
Add a new job to the existing vector database tests workflow:
5. Update pyproject.toml
Add your vector database client dependencies to the optional dependencies:pyproject.toml:
- Create a test or example script
test_<engine_name>.pyorexample.pythat you can use in your test workflow. - Create** a test workflow:
.github/workflows/engine_name/test_<engine_name>.yml. - Add required dependencies to
pyproject.tomloptional dependencies. - Open a PR to verify that your new integration passes CI.
Additional Considerations
Error Handling
- Implement proper error handling for connection failures, timeouts, and API errors.
- Log meaningful error messages that help with debugging.
- Handle graceful degradation when the vector database is unavailable.
Performance
- Consider implementing connection pooling if your vector database supports it.
- Add proper async/await patterns to avoid blocking operations.
- Implement batch operations efficiently where possible.
Security
- Never log sensitive information like API keys or connection strings.
- Validate inputs to prevent injection attacks.
- Follow your vector database’s security best practices.
Documentation
- Add docstrings to all public methods.
- Document any specific configuration requirements.
- Include examples of how to use your vector database with cognee.