Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for running REST API Server #2241

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions docs/open-source/features/rest-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,30 @@ Mem0 provides a REST API server (written using FastAPI). Users can perform all o
OPENAI_API_KEY=your-openai-api-key
```

2. Build the Docker image:
2. Either pull the docker image from docker hub or build the docker image locally.

<Tabs>
<Tab title="Pull from Docker Hub">

```bash
docker pull mem0/mem0-api-server
```

</Tab>

<Tab title="Build Locally">

```bash
docker build -t mem0-api-server .
```

</Tab>
</Tabs>

3. Run the Docker container:

``` bash
docker run -p 8000:8000 mem0-api-server
docker run -p 8000:8000 mem0-api-server --env-file .env
```

4. Access the API at http://localhost:8000.
Expand Down
1 change: 0 additions & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY .env .
COPY . .

EXPOSE 8000
Expand Down
2 changes: 1 addition & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ build:
docker build -t mem0-api-server .

run_local:
docker run -p 8000:8000 -v $(shell pwd):/app mem0-api-server
docker run -p 8000:8000 -v $(shell pwd):/app mem0-api-server --env-file .env

.PHONY: build run_local
50 changes: 2 additions & 48 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,6 @@ Mem0 provides a REST API server (written using FastAPI). Users can perform all o
- **Reset memories:** Reset all memories for a user, agent, or run.
- **OpenAPI Documentation:** Accessible via `/docs` endpoint.

## Running Locally
## Running the server

### With Docker

1. Create a `.env` file in the root directory of the project and set your environment variables. For example:

```env
OPENAI_API_KEY=your-openai-api-key
```

2. Build the Docker image:

```bash
docker build -t mem0-api-server .
```

3. Run the Docker container:

``` bash
docker run -p 8000:8000 mem0-api-server
```

4. Access the API at http://localhost:8000.

### Without Docker

1. Create a `.env` file in the root directory of the project and set your environment variables. For example:

```env
OPENAI_API_KEY=your-openai-api-key
```

2. Install dependencies:

```bash
pip install -r requirements.txt
```

3. Start the FastAPI server:

```bash
uvicorn main:app --reload
```

4. 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`](http://localhost:8000/docs) endpoint.
Follow the instructions in the [docs](https://docs.mem0.ai/open-source/features/rest-api) to run the server.