REST API Server
Mem0 provides a REST API server (written using FastAPI). Users can perform all operations through REST endpoints. The API also includes OpenAPI documentation, accessible at /docs
when the server is running.
APIs supported by Mem0 REST API Server
Features
- Create memories: Create memories based on messages for a user, agent, or run.
- Retrieve memories: Get all memories for a given user, agent, or run.
- Search memories: Search stored memories based on a query.
- Update memories: Update an existing memory.
- Delete memories: Delete a specific memory or all memories for a user, agent, or run.
- Reset memories: Reset all memories for a user, agent, or run.
- OpenAPI Documentation: Accessible via
/docs
endpoint.
Running Locally
The Development Docker Compose comes pre-configured with postgres pgvector, neo4j and a server/history/history.db
volume for the history database.
The only required environment variable to run the server is OPENAI_API_KEY
.
- Create a
.env
file in theserver/
directory and set your environment variables. For example:
- Run the Docker container using Docker Compose:
-
Access the API at http://localhost:8888.
-
Making changes to the server code or the library code will automatically reload the server.
The Development Docker Compose comes pre-configured with postgres pgvector, neo4j and a server/history/history.db
volume for the history database.
The only required environment variable to run the server is OPENAI_API_KEY
.
- Create a
.env
file in theserver/
directory and set your environment variables. For example:
- Run the Docker container using Docker Compose:
-
Access the API at http://localhost:8888.
-
Making changes to the server code or the library code will automatically reload the server.
- Create a
.env
file in the current directory and set your environment variables. For example:
- Either pull the docker image from docker hub or build the docker image locally.
- Run the Docker container:
- Access the API at http://localhost:8000.
- Create a
.env
file in the current directory and set your environment variables. For example:
- Install dependencies:
- Start the FastAPI server:
- Access the API at http://localhost:8000.
Usage
Once the server is running (locally or via Docker), you can interact with it using any REST client or through your preferred programming language (e.g., Go, Java, etc.). You can test out the APIs using the OpenAPI documentation at http://localhost:8000/docs endpoint.