> ## 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.

# Local Setup (No API Key)

> Run Cognee locally with Ollama and Fastembed.

Run Cognee entirely on your own machine — no cloud API key required. The key rule is that **both** the LLM provider **and** the embedding provider must be configured together to use a local backend; configuring only one will cause the other to fall back to OpenAI.

**Before you start:**

* Complete [Quickstart](/getting-started/quickstart) to understand basic operations
* Install [Ollama](https://ollama.ai) if using the Ollama options below

<Info>
  After switching to a local provider for the first time, call `cognee.prune.prune_system(metadata=True)` before running `cognify` to ensure there are no stale vector collections from the previous (OpenAI) embedding dimensions.
</Info>

<Tabs>
  <Tab title="Ollama (LLM + Embeddings)">
    Fully local setup using [Ollama](https://ollama.ai) for both text generation and embeddings.

    **Prerequisites**: Install Ollama and pull the required models:

    ```bash theme={null}
    ollama pull llama3.1:8b
    ollama pull nomic-embed-text:latest
    ```

    **.env configuration:**

    ```dotenv theme={null}
    # LLM — Ollama
    LLM_PROVIDER="ollama"
    LLM_MODEL="llama3.1:8b"
    LLM_ENDPOINT="http://localhost:11434/v1"
    LLM_API_KEY="ollama"

    # Embeddings — Ollama
    EMBEDDING_PROVIDER="ollama"
    EMBEDDING_MODEL="nomic-embed-text:latest"
    EMBEDDING_ENDPOINT="http://localhost:11434/api/embed"
    EMBEDDING_DIMENSIONS="768"
    HUGGINGFACE_TOKENIZER="nomic-ai/nomic-embed-text-v1.5"
    ```

    `LLM_API_KEY="ollama"` is a placeholder required by the client library — Ollama itself does not validate it.
    `HUGGINGFACE_TOKENIZER` is the HuggingFace repo ID of the tokenizer used for token counting when sending requests to the Ollama embedding endpoint.
  </Tab>

  <Tab title="Ollama LLM + Fastembed">
    Uses [Ollama](https://ollama.ai) for text generation and [Fastembed](https://github.com/qdrant/fastembed) for CPU-friendly local embeddings (no Ollama embedding model required).

    **Prerequisites**: Install Ollama and pull the LLM model:

    ```bash theme={null}
    ollama pull llama3.1:8b
    ```

    Install the Fastembed extra (not bundled with the base `cognee` package):

    ```bash theme={null}
    pip install 'cognee[fastembed]'
    ```

    See the [Fastembed setup notes](/setup-configuration/embedding-providers#fastembed-local) for supported models and dimensions.

    **.env configuration:**

    ```dotenv theme={null}
    # LLM — Ollama
    LLM_PROVIDER="ollama"
    LLM_MODEL="llama3.1:8b"
    LLM_ENDPOINT="http://localhost:11434/v1"
    LLM_API_KEY="ollama"

    # Embeddings — Fastembed (CPU, no API key)
    EMBEDDING_PROVIDER="fastembed"
    EMBEDDING_MODEL="sentence-transformers/all-MiniLM-L6-v2"
    EMBEDDING_DIMENSIONS="384"
    ```
  </Tab>
</Tabs>

## Troubleshooting

<AccordionGroup>
  <Accordion title="`LLMAPIKeyNotSetError: LLM API key is not set` on a fully local setup">
    Cognee is free and open source — running it locally with Ollama needs **no account, subscription, or paid API key**. You are not being asked to pay for anything.

    The error appears because Ollama is one of the providers Cognee requires a **non-empty** `LLM_API_KEY` for, even though Ollama itself ignores the value. If `LLM_API_KEY` is unset or empty, Cognee raises `LLMAPIKeyNotSetError` before it ever contacts your local server.

    The fix is to set any placeholder string — the convention is `ollama`:

    ```dotenv theme={null}
    LLM_PROVIDER="ollama"
    LLM_MODEL="llama3.1:8b"
    LLM_ENDPOINT="http://localhost:11434/v1"
    LLM_API_KEY="ollama"
    ```

    For the local examples above, keep `LLM_API_KEY="ollama"` in place. Fastembed does not need an embedding API key, and Ollama embeddings use the same local placeholder. Use the complete `.env` blocks in the tabs above so neither provider falls back to OpenAI.
  </Accordion>

  <Accordion title="`Cannot connect to host` / connection refused with Ollama">
    If Cognee can't reach Ollama, work through these checks:

    1. **Ollama is running.** Start the server with `ollama serve`, or open the Ollama desktop app. Verify with:
       ```bash theme={null}
       curl http://localhost:11434/api/tags
       ```
    2. **Endpoints match Ollama's API surface.** The LLM endpoint must use the OpenAI-compatible path and the embedding endpoint uses the native Ollama path:
       ```dotenv theme={null}
       LLM_ENDPOINT="http://localhost:11434/v1"
       EMBEDDING_ENDPOINT="http://localhost:11434/api/embed"
       ```
    3. **The required models are pulled.** Cognee does not pull models on demand:
       ```bash theme={null}
       ollama pull llama3.1:8b
       ollama pull nomic-embed-text:latest
       ```
    4. **Running Cognee in Docker?** `localhost` inside the container does not point at Ollama on the host. Use `host.docker.internal` instead:
       ```dotenv theme={null}
       LLM_ENDPOINT="http://host.docker.internal:11434/v1"
       EMBEDDING_ENDPOINT="http://host.docker.internal:11434/api/embed"
       ```
    5. **Repeated timeouts under load.** Ollama processes requests sequentially. If the default `EMBEDDING_BATCH_SIZE` of `36` overwhelms it, lower the batch size:
       ```dotenv theme={null}
       EMBEDDING_BATCH_SIZE="5"
       ```

    For more detail on embedding-side tuning, see [Embedding Providers → Ollama](/setup-configuration/embedding-providers#ollama-local).
  </Accordion>
</AccordionGroup>

<Columns cols={3}>
  <Card title="LLM Providers" icon="brain" href="/setup-configuration/llm-providers">
    Configure OpenAI, Azure, Gemini, Anthropic, Ollama, or custom LLM providers
  </Card>

  <Card title="Embedding Providers" icon="layers" href="/setup-configuration/embedding-providers">
    Set up OpenAI, Mistral, Ollama, Fastembed, or custom embedding services
  </Card>

  <Card title="Setup Configuration" icon="settings" href="/setup-configuration/overview">
    Full configuration reference for all backends
  </Card>
</Columns>
