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

# Zep plugin

> Context engineering and agent memory with Zep: create users and threads, add chat messages and read the assembled context, build and search knowledge graphs (episodes, nodes, edges, hyperedges, observations, ontology), manage user groups, context templates, batch ingestion and project settings, and work with Agent Skills and traces (205 operations).

Use **Zep** through Corsair: one client, typed API calls, and incoming webhooks.

Create a project API key in the Zep dashboard. Every call acts on that project. Things to know before you write:

* **Users, threads and graphs.** A user has its own graph; a thread belongs to a user and holds chat messages. `threads.messages.add` adds messages and Zep extracts facts into the user's graph in the background; `threads.getContext` returns the assembled context block for the next prompt. Standalone graphs (`graphs.create`) hold shared knowledge that isn't tied to one user.
* **IDs.** v4 addresses everything by `uuid` (`thread_uuid`, `user_uuid`, `graph_uuid`). The ids you chose (`user_id`, `thread_id`, `graph_id`) are looked up with `users.lookup`, `threads.lookup`, `graphs.lookup` or `lookup.developerIds`.
* **Ingestion is asynchronous.** `graphs.episodes.add`, `threads.messages.add` and the batch routes queue work; `tasks.get` and `graphs.episodes.get` show progress. Batches (`batches.create`, `batches.addItems`, `batches.process`) load history in bulk.
* **Search.** `graphs.searchEdges`, `graphs.searchNodes`, `graphs.searchEpisodes`, `graphs.searchObservations` and `graphs.searchThreadSummaries` search one graph; `graphs.getContext` assembles context from a template; `graphs.query` (experimental) streams a multi-hop answer as server-sent events and comes back as text.
* **Deletes are permanent.** Deleting a user deletes its graph and threads; deleting a graph, episode, node or edge removes it from search. Every delete is `destructive`.
* **Agent Skills** (`agents.*`) are in closed release: accounts without access get 403 `permission_denied`. **Trace connections** (`traceConnections.*`, Braintrust or LangSmith) check the provider credential when created and answer 422 when the provider refuses it.
* **Admin-only routes.** Policy sets on user groups (`userGroups.listPolicySets`, `attachPolicySet`, `detachPolicySet`) need a dashboard bearer token: a project API key gets 403. Domain knowledge (`*.getKnowledge`, `*.setKnowledge`) needs the `knowledge_api` account flag (404 without it).
* **Webhooks.** Zep posts `episode.processed`, `ingest.batch.completed` and `byom.request_failed` to an endpoint set up in the dashboard (paid plans), signed with Svix. The plugin verifies them with the endpoint's signing secret.

**What you get:**

* 205 typed API operations
* 3 incoming webhook event types

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/zep better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/zep better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/zep better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/zep better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { zep } from '@corsair-dev/zep';

export const corsair = createCorsair({
	plugins: [
		zep(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the Zep API key before the first call: `pnpm corsair setup --plugin=zep --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> zep()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'zep',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Get a thread's context for the next prompt**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.zep.api.threads.getContext({ thread_uuid: '3f0e6a2c-8b1d-4c7e-9a52-1d2e3f4a5b6c' });
```

**Add chat messages to a thread**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.zep.api.threads.messages.add({
	thread_uuid: '3f0e6a2c-8b1d-4c7e-9a52-1d2e3f4a5b6c',
	messages: [{ role: 'user', name: 'Ada', content: 'I moved to Lisbon last month.' }, { role: 'assistant', content: 'Noted, Lisbon it is.' }],
});
```

See the full list on the [API](https://docs.corsair.dev/plugins/zep/api.md) page.

## Webhooks

This plugin registers **3** webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use `webhookHooks` on the plugin factory.

See [Webhooks](https://docs.corsair.dev/plugins/zep/webhooks.md) for every event path and payload shape, and [Webhooks concept](https://docs.corsair.dev/concepts/webhooks.md) for routing.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/zep/api.md)
>
> Every `zep.api.*` operation with input and output types.

> [card] [Webhooks](https://docs.corsair.dev/plugins/zep/webhooks.md)
>
> Event paths, payloads, and `webhookHooks` examples.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


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