Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

5.9 KB
Raw Blame
---
title: "Configure the OSS Stack"
description: "Configure Mem0 OSS in Python or TypeScript with your own LLM, embedder, and vector store."
icon: "sliders"
---

Mem0 OSS works out of the box with OpenAI defaults. Point it at your own LLM, embedder, vector store, and reranker by passing a config when you create `Memory`.

<Info>
  **Prerequisites**
  - Python 3.10+ (`pip`) or Node.js 18+ (`npm`)
  - A running vector store such as Qdrant or Postgres + pgvector (Python's default Qdrant and Node's in-memory store need nothing extra)
  - API keys for your chosen LLM and embedder providers
</Info>

<Tip>
  New to Mem0 OSS? Run the <Link href="/open-source/python-quickstart">Python</Link> or <Link href="/open-source/node-quickstart">Node.js</Link> quickstart first, then come back to swap in your own providers.
</Tip>

## Install dependencies

<CodeGroup>
```bash pip
pip install mem0ai
```

```bash npm
npm install mem0ai
```
</CodeGroup>

Using Qdrant as your vector store? Install its Python client (the Node SDK talks to Qdrant over REST) and run the server locally:

```bash
pip install qdrant-client   # Python only
docker run -p 6333:6333 qdrant/qdrant
```

## Define your configuration

Each component takes a `provider` and a `config`. Keys are `snake_case` in Python and `camelCase` in TypeScript. Pass the config when you create `Memory`:

<CodeGroup>
```python Python
from mem0 import Memory

config = {
    "vector_store": {
        "provider": "qdrant",
        "config": {"host": "localhost", "port": 6333},
    },
    "llm": {
        "provider": "openai",
        "config": {"model": "gpt-5-mini", "temperature": 0.1},
    },
    "embedder": {
        "provider": "openai",
        "config": {"model": "text-embedding-3-small"},
    },
    "reranker": {
        "provider": "cohere",
        "config": {"model": "rerank-v3.5"},
    },
}

memory = Memory.from_config(config)
```

```ts Node.js
import { Memory } from "mem0ai/oss";

const memory = new Memory({
  llm: {
    provider: "openai",
    config: { apiKey: process.env.OPENAI_API_KEY || "", model: "gpt-5-mini", temperature: 0.1 },
  },
  embedder: {
    provider: "openai",
    config: { apiKey: process.env.OPENAI_API_KEY || "", model: "text-embedding-3-small" },
  },
  vectorStore: {
    provider: "qdrant",
    config: { host: "localhost", port: 6333, collectionName: "memories" },
  },
});
```
</CodeGroup>

Set your provider keys as environment variables:

```bash
export OPENAI_API_KEY="..."
export COHERE_API_KEY="..."   # Cohere reranker only
```

<Note>
  The TypeScript OSS SDK configures the LLM, embedder, vector store, history store, and reranker. Graph memory is not part of OSS in either language: it is a built-in [Mem0 Platform feature](/platform/features/graph-memory).
</Note>

Prefer a config file? Load YAML into Python's `from_config`:

```python
import yaml
from mem0 import Memory

with open("config.yaml") as f:
    config = yaml.safe_load(f)

memory = Memory.from_config(config)
```

<Info icon="check">
  Verify it works: add a memory and search it back. `memory.add(...)` followed by `memory.search(...)` should populate your vector store and return the memory as a top hit.
</Info>

## Available providers

Change the `provider` string to switch backends. The most common options:

| Component | Python | TypeScript |
| --- | --- | --- |
| LLM | `openai`, `anthropic`, `gemini`, `groq`, `ollama`, `aws_bedrock`, `azure_openai`, `litellm` | `openai`, `anthropic`, `gemini`, `groq`, `ollama`, `aws_bedrock`, `azure_openai`, `mistral`, `deepseek` |
| Embedder | `openai`, `gemini`, `azure_openai`, `ollama`, `huggingface`, `vertexai`, `aws_bedrock` | `openai`, `gemini`, `azure_openai`, `ollama` |
| Vector store | `qdrant`, `pgvector`, `chroma`, `pinecone`, `redis`, `weaviate`, `milvus`, `elasticsearch` | `memory`, `qdrant`, `pgvector`, `redis`, `supabase`, `azure-ai-search`, `vectorize`, `milvus` |

See the full catalog in <Link href="/components/llms/overview">Components</Link>.

## Tune component settings

<AccordionGroup>
  <Accordion title="Vector store collections">
    Name collections explicitly in production (`collection_name` / `collectionName`) to isolate tenants and enable per-tenant retention policies.
  </Accordion>
  <Accordion title="LLM extraction temperature">
    Keep extraction temperature at or below 0.2 so memories stay deterministic. Raise it only when you see facts being missed.
  </Accordion>
  <Accordion title="Reranker depth (Python)">
    Limit `top_k` to 10 to 20 results. Sending more adds latency without meaningful gains.
  </Accordion>
</AccordionGroup>

<Warning>
  Mixing managed and self-hosted components? Make sure every outbound provider call has a secure network path. Managed rerankers and embedders often require outbound internet even if your vector store is on-prem.
</Warning>

## Quick recovery

- Qdrant connection errors: confirm port `6333` is exposed and the API key (if set) matches.
- Empty search results: verify the embedder model name. A mismatch causes dimension errors.
- `Unknown reranker` (Python): upgrade the SDK with `pip install --upgrade mem0ai` to load the latest provider registry.
- `Cannot find module` (Node): two common causes. First, import from the OSS entry point, `import { Memory } from "mem0ai/oss"`, not `"mem0ai"`. Second, provider SDKs are optional peer dependencies loaded on demand, so install the one for the provider you configured (for example `npm install @qdrant/js-client-rest` for Qdrant). Installing `mem0ai` alone only pulls in the providers used by default; you do not need SDKs for providers you never select.

<CardGroup cols={2}>
  <Card
    title="Pick Providers"
    description="Browse the LLM, vector store, embedder, and reranker catalogs."
    icon="sitemap"
    href="/components/llms/overview"
  />
  <Card
    title="Deploy with Docker Compose"
    description="Follow the end-to-end OSS deployment walkthrough."
    icon="server"
    href="/open-source/features/rest-api"
  />
</CardGroup>