{"id":4974,"library":"langmem","title":"LangMem","description":"LangMem (version 0.0.30) is a Python library providing prebuilt utilities for memory management and retrieval, specifically designed for AI agents and LLM applications. It offers abstractions for integrating with various embedding models and vector stores, facilitating the creation of intelligent systems with long-term memory. The library is under active development with frequent minor updates.","status":"active","version":"0.0.30","language":"en","source_language":"en","source_url":"https://github.com/langmem/langmem","tags":["AI","LLM","Memory","Vector Store","Embeddings","Agentic AI"],"install":[{"cmd":"pip install langmem","lang":"bash","label":"Install core library"},{"cmd":"pip install langmem[openai,chromadb]","lang":"bash","label":"Install with common extras"}],"dependencies":[{"reason":"Required for using OpenAIEmbeddings and other OpenAI-related components.","package":"openai","optional":true},{"reason":"Required for using the Chroma vector store.","package":"chromadb","optional":true}],"imports":[{"symbol":"MemoryManager","correct":"from langmem import MemoryManager"},{"symbol":"OpenAIEmbeddings","correct":"from langmem.embeddings import OpenAIEmbeddings"},{"note":"The 'vectorstores' submodule is plural.","wrong":"from langmem.vectorstore import Chroma","symbol":"Chroma","correct":"from langmem.vectorstores import Chroma"}],"quickstart":{"code":"import os\nfrom langmem import MemoryManager\nfrom langmem.embeddings import OpenAIEmbeddings\nfrom langmem.vectorstores import Chroma\n\n# NOTE: For this example, you need to install 'openai' and 'chromadb'\n# pip install langmem openai chromadb\n\n# Ensure OPENAI_API_KEY is set in your environment variables.\n# For testing, you can uncomment and set it directly:\n# os.environ['OPENAI_API_KEY'] = 'YOUR_OPENAI_API_KEY'\n\nopenai_api_key = os.environ.get('OPENAI_API_KEY', '')\nif not openai_api_key:\n    print(\"Warning: OPENAI_API_KEY environment variable not set. OpenAIEmbeddings might fail.\")\n\n# Initialize embeddings and vector store\nembeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)\nvectorstore = Chroma(embedding_function=embeddings) # Chroma requires embedding_function\n\n# Initialize MemoryManager\nmemory_manager = MemoryManager(vectorstore=vectorstore)\n\n# Add memories\nmemory_manager.add_memory(\"The quick brown fox jumps over the lazy dog.\")\nmemory_manager.add_memory(\"The quick red bird flies high in the sky.\")\nmemory_manager.add_memory(\"The lazy dog often naps under the oak tree.\")\n\n# Recall information\nresults = memory_manager.recall(\"What is the fox doing?\")\nprint(\"\\nRecall results for 'What is the fox doing?':\", results)\n\nresults = memory_manager.recall(\"Where does the dog nap?\")\nprint(\"\\nRecall results for 'Where does the dog nap?':\", results)","lang":"python","description":"This quickstart demonstrates how to set up `MemoryManager` with `OpenAIEmbeddings` and `Chroma` to add and recall memories. It assumes `openai` and `chromadb` are installed (e.g., via `pip install langmem[openai,chromadb]`) and `OPENAI_API_KEY` is configured in your environment. Note the use of `embedding_function` when initializing `Chroma`."},"warnings":[{"fix":"Refer to the GitHub repository and commit history for recent changes. Pin your dependency versions to specific patch releases (e.g., `langmem==0.0.30`) to mitigate unexpected breaks.","message":"API stability is not guaranteed below version 1.0.0. The library is in early development (0.0.x), and breaking changes may occur frequently between minor versions without extensive prior notice.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Consult the `pyproject.toml` or `setup.py` on GitHub for available `extras_require` groups, or manually install individual packages as needed for your chosen components.","message":"Many useful components (e.g., specific embedding models, vector stores) are optional dependencies. You must explicitly install them (e.g., `pip install openai chromadb`) to use them with `langmem`.","severity":"gotcha","affected_versions":"All"},{"fix":"Use `vectorstore = Chroma(embedding_function=embeddings_instance)` to correctly configure your vector store with an embedding model.","message":"When initializing vector stores like `Chroma`, ensure you pass the embedding model instance using the correct parameter name, which is `embedding_function`, not `embeddings`.","severity":"gotcha","affected_versions":"All"},{"fix":"Set the API key as an environment variable (e.g., `export OPENAI_API_KEY='your_key'`) or pass it directly to the constructor (e.g., `OpenAIEmbeddings(openai_api_key='your_key')`).","message":"For cloud-based embedding services (e.g., OpenAIEmbeddings), the necessary API key (e.g., `OPENAI_API_KEY`) must be set in your environment variables or passed directly during initialization. Forgetting this will lead to authentication errors.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}