> ## Documentation Index
> Fetch the complete documentation index at: https://cortex-e852fafe-t3code-rewrite-docs-declutter.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain

> Persistent, cross-session memory and retrieval for LangChain chains and agents, backed by HydraDB.

HydraDB integration for [LangChain](https://langchain.com): persistent,
cross-session memory and retrieval for your chains and agents.

Install the [PyPI package](https://pypi.org/project/langchain-hydradb/):

```bash theme={"dark"}
pip install langchain-hydradb
```

```python theme={"dark"}
from langchain_hydradb import HydraDBClient, HydraDBRetriever

client = HydraDBClient(api_key="sk_live_...", tenant_id="your-database")

# Use HydraDB as a retriever in any chain
retriever = HydraDBRetriever(client=client, kind="both", max_results=6)
docs = retriever.invoke("what did we decide about auth?")

# Write durable memory
client.add_text("We deploy on Fridays only.", infer=True)
```

| Class | Role |
| - | - |
| `HydraDBClient` | Thin HTTP client, public API only (`POST /query`, `POST /context/ingest`, `DELETE /context`) |
| `HydraDBRetriever` | `BaseRetriever` over memory, knowledge, or both |
| `HydraDBChatMessageHistory` | `BaseChatMessageHistory` that persists and recalls turns |

<Note>
  Requires `langchain-core >= 0.3`. Writes use the public knowledge path, so
  `add_text`/`add_conversation` store as knowledge; recall `kind` may be
  `"memory"`, `"knowledge"`, or `"both"`. Ingestion is asynchronous, so recall a
  source only after it finishes indexing.
</Note>

## Feedback and contributions

This plugin is open source. Feel free to [raise an issue](https://github.com/hydra-db/hydradb-langchain-plugin/issues) or [contribute on GitHub](https://github.com/hydra-db/hydradb-langchain-plugin).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.