A FastAPI-based REST API for memory operations, providing a robust interface for managing and querying memories.
- Memory CRUD operations
- Memory search and querying
- Memory history tracking
- Memory relations management
- Real-time updates via WebSocket
- Cross-session memory bridging
- Memory compression
- Memory suggestions
- Python 3.9+
- Docker and Docker Compose
- Neo4j 4.4+
- Qdrant latest version
- OpenAI API key
- Clone the repository:
git clone https://github.com/yourusername/mem0-rest.git
cd mem0-rest- Copy the sample environment file and update it with your settings:
cp sample.env .env- Start the services using Docker Compose:
docker-compose up -d- The API will be available at http://localhost:8000
- API documentation: http://localhost:8000/api/docs
- ReDoc documentation: http://localhost:8000/api/redoc
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/macOS
.\venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Run the development server:
uvicorn src.main:app --reload --host 0.0.0.0 --port 8000POST /api/memories/- Create a new memoryGET /api/memories/{memory_id}- Get a memory by IDPUT /api/memories/{memory_id}- Update a memoryDELETE /api/memories/{memory_id}- Delete a memoryGET /api/memories/- List memories with filters
POST /api/queries/search- Search memoriesGET /api/queries/suggestions- Get memory suggestionsGET /api/queries/similar/{memory_id}- Get similar memories
GET /api/history/{memory_id}- Get memory historyGET /api/history/relations/{memory_id}- Get memory relationsPOST /api/history/relations- Add memory relationDELETE /api/history/relations/{relation_id}- Remove memory relation
/api/ws/memory/{session_id}- Memory updates stream/api/ws/stream/{session_id}- Memory content stream
The application can be configured using environment variables or a .env file. See sample.env for available options.
API_VERSION- API versionDEBUG- Enable debug modeJWT_SECRET- Secret key for JWT tokensOPENAI_API_KEY- OpenAI API keyQDRANT_HOST- Qdrant hostNEO4J_URI- Neo4j connection URI
Run tests using pytest:
pytestRun tests with coverage:
pytest --cov=src --cov-report=htmlBuild the Docker image:
docker build -t mem0-rest .Run the container:
docker run -p 8000:8000 --env-file .env mem0-rest- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
