> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mem0.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Config

> Reference for shared and provider-specific reranker configuration options in Mem0, including top_k and API key settings.

## Common Configuration Parameters

All rerankers share these common configuration parameters:

| Parameter  | Description                                         | Type  | Default  |
| ---------- | --------------------------------------------------- | ----- | -------- |
| `provider` | Reranker provider name                              | `str` | Required |
| `top_k`    | Maximum number of results to return after reranking | `int` | `None`   |
| `api_key`  | API key for the reranker service                    | `str` | `None`   |

## Provider-Specific Configuration

### Zero Entropy

| Parameter | Description                                  | Type  | Default      |
| --------- | -------------------------------------------- | ----- | ------------ |
| `model`   | Model to use: `zerank-1` or `zerank-1-small` | `str` | `"zerank-1"` |
| `api_key` | Zero Entropy API key                         | `str` | `None`       |

### Cohere

| Parameter            | Description                                  | Type   | Default         |
| -------------------- | -------------------------------------------- | ------ | --------------- |
| `model`              | Cohere rerank model                          | `str`  | `"rerank-v3.5"` |
| `api_key`            | Cohere API key                               | `str`  | `None`          |
| `return_documents`   | Whether to return document texts in response | `bool` | `False`         |
| `max_chunks_per_doc` | Maximum chunks per document                  | `int`  | `None`          |

### Sentence Transformer

| Parameter           | Description                                  | Type   | Default                                  |
| ------------------- | -------------------------------------------- | ------ | ---------------------------------------- |
| `model`             | HuggingFace cross-encoder model name         | `str`  | `"cross-encoder/ms-marco-MiniLM-L-6-v2"` |
| `device`            | Device to run model on (`cpu`, `cuda`, etc.) | `str`  | `None`                                   |
| `batch_size`        | Batch size for processing                    | `int`  | `32`                                     |
| `show_progress_bar` | Show progress during processing              | `bool` | `False`                                  |

### Hugging Face

| Parameter | Description                                  | Type  | Default                     |
| --------- | -------------------------------------------- | ----- | --------------------------- |
| `model`   | HuggingFace reranker model name              | `str` | `"BAAI/bge-reranker-large"` |
| `api_key` | HuggingFace API token                        | `str` | `None`                      |
| `device`  | Device to run model on (`cpu`, `cuda`, etc.) | `str` | `None`                      |

### LLM-based

| Parameter        | Description                                | Type    | Default                |
| ---------------- | ------------------------------------------ | ------- | ---------------------- |
| `model`          | LLM model to use for scoring               | `str`   | `"gpt-4o-mini"`        |
| `provider`       | LLM provider (`openai`, `anthropic`, etc.) | `str`   | `"openai"`             |
| `api_key`        | API key for LLM provider                   | `str`   | `None`                 |
| `temperature`    | Temperature for LLM generation             | `float` | `0.0`                  |
| `max_tokens`     | Maximum tokens for LLM response            | `int`   | `100`                  |
| `scoring_prompt` | Custom prompt template for scoring         | `str`   | Default scoring prompt |

### LLM Reranker

| Parameter      | Description                 | Type   | Default  |
| -------------- | --------------------------- | ------ | -------- |
| `llm.provider` | LLM provider for reranking  | `str`  | Required |
| `llm.config`   | LLM configuration object    | `dict` | Required |
| `top_n`        | Number of results to return | `int`  | `None`   |

## Environment Variables

You can set API keys using environment variables:

* `ZERO_ENTROPY_API_KEY` - Zero Entropy API key
* `COHERE_API_KEY` - Cohere API key
* `HUGGINGFACE_API_KEY` - HuggingFace API token
* `OPENAI_API_KEY` - OpenAI API key (for LLM-based reranker)
* `ANTHROPIC_API_KEY` - Anthropic API key (for LLM-based reranker)

## Basic Configuration Example

```python Python theme={null}
config = {
    "vector_store": {
        "provider": "chroma",
        "config": {
            "collection_name": "my_memories",
            "path": "./chroma_db"
        }
    },
    "llm": {
        "provider": "openai",
        "config": {
            "model": "gpt-5-mini"
        }
    },
    "reranker": {
        "provider": "zero_entropy",
        "config": {
            "model": "zerank-1",
            "top_k": 5
        }
    }
}
```

## TypeScript SDK

The self-hosted [TypeScript SDK](/open-source/features/reranker-search#typescript-sdk) (`mem0ai/oss`) supports the same five providers. Config keys are camelCase (`apiKey`, `topK`, `maxLength`) and each provider's SDK is a peer dependency you install per reranker.

| Provider               | Install                                 | Default model                   | Key config fields                                              |
| ---------------------- | --------------------------------------- | ------------------------------- | -------------------------------------------------------------- |
| `cohere`               | `pnpm add cohere-ai`                    | `rerank-v3.5`                   | `apiKey`, `model`, `topK`                                      |
| `zero_entropy`         | `pnpm add zeroentropy`                  | `zerank-1`                      | `apiKey`, `model`, `topK`                                      |
| `sentence_transformer` | `pnpm add @huggingface/transformers`    | `Xenova/ms-marco-MiniLM-L-6-v2` | `model`, `device`, `maxLength`, `normalize`, `topK`            |
| `huggingface`          | `pnpm add @huggingface/transformers`    | `Xenova/bge-reranker-base`      | `model`, `device`, `maxLength`, `normalize`, `topK`            |
| `llm_reranker`         | None (uses your LLM provider's own SDK) | `openai` / `gpt-4o-mini`        | `provider`, `model`, `apiKey`, `llm` (nested override), `topK` |

```typescript theme={null}
import { Memory } from "mem0ai/oss";

const memory = new Memory({
  reranker: {
    provider: "zero_entropy",
    config: { apiKey: process.env.ZERO_ENTROPY_API_KEY, topK: 5 },
  },
});
```

<Note>
  The local cross-encoder providers (`sentence_transformer`, `huggingface`) run on [Transformers.js](https://huggingface.co/docs/transformers.js) and default to ONNX (`Xenova/*`) model mirrors, so Python default model strings must be swapped for their ONNX equivalents. `batchSize` and `showProgressBar` are accepted for parity with Python but are no-ops in the TypeScript runtime. See the [reranker feature guide](/open-source/features/reranker-search#typescript-sdk) for full examples.
</Note>
