🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
---
title: Configure Memory Environment Variables
description: >-
Learn how to configure the Gate Keeper, Layer Extractor, and Embedding
environment variables required by LobeHub's memory feature.
tags:
- Memory
- Environment Variables
- Embedding
---
# Configure Memory Environment Variables
LobeHub's memory feature relies on three independent model stages working together: the **Gate Keeper** decides whether conversation content is worth saving as a memory, the **Layer Extractor** extracts the actual memory content from the conversation context, and **Embedding** converts the extracted memory content into vectors to support semantic retrieval.
To fit different deployment scenarios, each of these three stages can be configured independently with its own model, provider, API endpoint, and API key. If left unconfigured, LobeHub falls back to the user's preferred model configured in the model provider settings.
## Gate Keeper
The Gate Keeper reviews content before it is written into memory, avoiding redundant or low-quality memories.
### `MEMORY_USER_MEMORY_GATEKEEPER_LANGUAGE`
- Type: Optional
- Description: Forces the language used for the Gate Keeper's output
- Default: -
- Example: `ç®€ä½“ä¸æ–‡`
### `MEMORY_USER_MEMORY_GATEKEEPER_MODEL`
- Type: Optional
- Description: Forces the model used by the Gate Keeper, with priority higher than the provider and model preference settings
- Default: -
- Example: `gpt-5.4-mini`
### `MEMORY_USER_MEMORY_GATEKEEPER_API_KEY`
- Type: Optional
- Description: API key for the provider of the model used by the Gate Keeper
- Default: -
- Example: `sk-xxxxxx...xxxxxx`
### `MEMORY_USER_MEMORY_GATEKEEPER_BASE_URL`
- Type: Optional
- Description: Base URL of the API endpoint. If it is OpenAI-compatible, only the part up to `/v1` needs to be provided
- Default: -
- Example: `https://example.com/v1`
### `MEMORY_USER_MEMORY_GATEKEEPER_PROVIDER`
- Type: Optional
- Description: Selects which LobeHub-supported provider SDK implementation backs this model. If it is OpenAI-compatible, set it to `openai`
- Default: -
- Example: `openai`
### `MEMORY_USER_MEMORY_GATEKEEPER_PREFERRED_PROVIDERS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers, this sets the matching order of providers, separated by commas
- Default: -
- Example: `openai,deepseek`
### `MEMORY_USER_MEMORY_GATEKEEPER_PREFERRED_MODELS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers and activated multiple models, this sets the matching order of models. If no match is found, LobeHub falls through to the next model id. For example, if the OpenAI model on OpenRouter is identified as `openai/gpt-5.4-mini`, use that id here
- Default: -
- Example: `gpt-5.4-mini,openai/gpt-5.4-mini`
## Layer Extractor
The Layer Extractor extracts the specific content worth persisting as long-term memory from the conversation context.
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_CONTEXT_LIMIT`
- Type: Optional
- Description: Token limit for the model's context. For example, if the model's context limit is `27200` tokens, it's recommended to set this to 60%~75% of that limit, leaving the rest of the budget for the generated content
- Default: -
- Example: `20000`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_MODEL`
- Type: Optional
- Description: Forces the model used by the Layer Extractor, with priority higher than the provider and model preference settings
- Default: -
- Example: `gpt-5.4-mini`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_API_KEY`
- Type: Optional
- Description: API key for the provider of the model used by the Layer Extractor
- Default: -
- Example: `sk-xxxxxx...xxxxxx`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_BASE_URL`
- Type: Optional
- Description: Base URL of the API endpoint. If it is OpenAI-compatible, only the part up to `/v1` needs to be provided
- Default: -
- Example: `https://example.com/v1`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_PROVIDER`
- Type: Optional
- Description: Selects which LobeHub-supported provider SDK implementation backs this model. If it is OpenAI-compatible, set it to `openai`
- Default: -
- Example: `openai`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_PREFERRED_PROVIDERS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers, this sets the matching order of providers, separated by commas
- Default: -
- Example: `openai,deepseek`
### `MEMORY_USER_MEMORY_LAYER_EXTRACTOR_PREFERRED_MODELS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers and activated multiple models, this sets the matching order of models. If no match is found, LobeHub falls through to the next model id
- Default: -
- Example: `gpt-5.4-mini,openai/gpt-5.4-mini`
## Embedding
Embedding converts the extracted memory content into vectors for subsequent semantic retrieval.
### `MEMORY_USER_MEMORY_EMBEDDING_CONTEXT_LIMIT`
- Type: Optional
- Description: Token limit for the embedding model. For example, if an OpenAI embedding model has a limit of `8192` tokens, it's recommended to set this to 75%~90% of that limit. You can set it higher when using an embedding model with a larger context window, such as Voyage
- Default: -
- Example: `5000`
### `MEMORY_USER_MEMORY_EMBEDDING_API_KEY`
- Type: Optional
- Description: API key for the provider of the model used for Embedding
- Default: -
- Example: `sk-xxxxxx...xxxxxx`
### `MEMORY_USER_MEMORY_EMBEDDING_BASE_URL`
- Type: Optional
- Description: Base URL of the API endpoint. If it is OpenAI-compatible, only the part up to `/v1` needs to be provided
- Default: -
- Example: `https://example.com/v1`
### `MEMORY_USER_MEMORY_EMBEDDING_MODEL`
- Type: Optional
- Description: Forces the model used for Embedding, with priority higher than the provider and model preference settings
- Default: -
- Example: `text-embedding-3-large`
<Callout type={'info'}>
The example above uses OpenAI's `text-embedding-3-large` model. Replace it with the embedding
model you actually intend to use.
</Callout>
### `MEMORY_USER_MEMORY_EMBEDDING_PROVIDER`
- Type: Optional
- Description: Selects which LobeHub-supported provider SDK implementation backs this model. If it is OpenAI-compatible, set it to `openai`
- Default: -
- Example: `openai`
### `MEMORY_USER_MEMORY_EMBEDDING_PREFERRED_PROVIDERS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers, this sets the matching order of providers, separated by commas
- Default: -
- Example: `openai`
### `MEMORY_USER_MEMORY_EMBEDDING_PREFERRED_MODELS`
- Type: Optional
- Description: When a user with memory enabled has configured multiple providers and activated multiple models, this sets the matching order of models. If no match is found, LobeHub falls through to the next model id
- Default: -
- Example: `text-embedding-3-large,openai/text-embedding-3-large`