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

# Dify

> Add Cognee memory tools to your Dify apps and workflows.

Connect [Dify](https://dify.ai/) to cognee's AI memory engine with a marketplace tool plugin. Add data, build a knowledge graph with cognify, and run semantic search directly from your Dify apps and workflows — no code required.

There are two plugins depending on where your Cognee runs:

| Plugin                                  | Backend                    | Auth             |
| --------------------------------------- | -------------------------- | ---------------- |
| **Cognee** (`cognee`)                   | Cognee Cloud (hosted)      | API key          |
| **Cognee (Self-Hosted)** (`cognee-sdk`) | Your own Cognee OSS server | Email + password |

## Cognee (Cloud)

Targets the hosted [Cognee Cloud](/cognee-cloud/overview) API.

### Setup

1. Get your **Base URL** and **API key** from the [Cognee Cloud dashboard](https://platform.cognee.ai/).
2. Install the **Cognee** plugin from the Dify Marketplace.
3. Configure the plugin credentials:

| Field      | Value                                  |
| ---------- | -------------------------------------- |
| `base_url` | `https://tenant-xxx.aws.cognee.ai/api` |
| `api_key`  | Your Cognee API key                    |

### Tools

| Tool             | Description                                                                  |
| ---------------- | ---------------------------------------------------------------------------- |
| Create Dataset   | Create a new dataset (or return an existing one with the same name)          |
| Add Data         | Ingest text content into a dataset                                           |
| Add File         | Upload files (PDF, DOCX, TXT, …) into a dataset                              |
| Cognify          | Process dataset(s) into a searchable knowledge graph                         |
| Search           | Query the knowledge graph (14 search strategies, `top_k`, `only_context`, …) |
| Get Datasets     | List all datasets for the authenticated user                                 |
| Get Dataset Data | List all data items in a dataset                                             |
| Delete Dataset   | Permanently delete a dataset and its data                                    |
| Delete Data      | Delete a specific data item from a dataset                                   |

## Cognee (Self-Hosted)

Targets a local or self-hosted Cognee OSS server. Tested with Cognee `v0.5.5`.

### Run a Cognee server

<CodeGroup>
  ```yaml docker-compose.yml theme={null}
  services:
    cognee:
      image: cognee/cognee:0.5.5
      container_name: cognee-local
      ports:
        - "8000:8000"
      environment:
        - HOST=0.0.0.0
        - ENVIRONMENT=local
      volumes:
        - .env:/app/.env
  ```

  ```bash pip theme={null}
  pip install cognee==0.5.5
  LLM_API_KEY=sk-your-openai-key-here python -m cognee.api.client
  ```
</CodeGroup>

Provide your `LLM_API_KEY` (via `.env` for Docker) and start the server, then verify it:

```bash theme={null}
curl http://localhost:8000/health   # should return HTTP 200
```

### Setup

In the Dify plugins page, find **Cognee (Self-Hosted)** and configure:

| Field           | Value                      |
| --------------- | -------------------------- |
| `base_url`      | `http://localhost:8000`    |
| `user_email`    | `default_user@example.com` |
| `user_password` | `default_password`         |

The plugin validates the configuration with a health check and login.

<Info>
  The plugin runs on your host (not inside Docker), so use `localhost`. If you run the plugin inside Docker too, use `host.docker.internal`. Change the default credentials before production use.
</Info>

### Tools

| Tool           | Description                                                   |
| -------------- | ------------------------------------------------------------- |
| Add Data       | Add text data to a dataset                                    |
| Cognify        | Build memory from one or more datasets                        |
| Search         | Search the knowledge graph for relevant information           |
| Update Data    | Replace an existing data item and re-integrate it into memory |
| Delete Dataset | Delete a dataset and all its data                             |
| Delete Data    | Delete a specific data item                                   |

<Info>
  The self-hosted plugin authenticates with email + password (not an API key), adds an **Update Data** tool, and does not include the cloud-only **Add File** / **Create Dataset** tools.
</Info>

## Typical Workflow

Both plugins follow the same pattern inside a Dify app or workflow:

1. **Add Data** (or **Add File**) to ingest content into a dataset
2. **Cognify** to build the knowledge graph
3. **Search** before LLM calls to pull relevant context from memory
4. **Delete Dataset** / **Delete Data** to clean up

***

<CardGroup cols={2}>
  <Card title="Cloud plugin source" icon="github" href="https://github.com/topoteretes/cognee-integrations/tree/main/integrations/dify">
    View the Cognee Cloud Dify plugin
  </Card>

  <Card title="Self-hosted plugin source" icon="github" href="https://github.com/topoteretes/cognee-integrations/tree/main/integrations/dify-sdk">
    View the self-hosted Dify plugin
  </Card>
</CardGroup>
