- Complete Quickstart to understand basic operations
- Install Ollama if using the Ollama options below
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.- Ollama (LLM + Embeddings)
- Ollama LLM + Fastembed
Fully local setup using Ollama for both text generation and embeddings.Prerequisites: Install Ollama and pull the required models:.env configuration:
LLM_API_KEY="ollama" is a placeholder required by the client library — Ollama itself does not validate it.
LLM_ENDPOINT is the bare host with no path: on the default litellm_native structured output backend, LiteLLM routes Ollama over its native API and appends /api/generate itself, so a trailing /v1 turns into /v1/api/generate and 404s. EMBEDDING_ENDPOINT is a separate, Cognee-owned path and keeps its /api/embed suffix. See LLM Providers → Ollama for the instructor-backend exception.
HUGGINGFACE_TOKENIZER is the HuggingFace repo ID of the tokenizer used for token counting when sending requests to the Ollama embedding endpoint. It is optional — Cognee no longer requires it at startup — but recommended for accurate token counting.Runnable version: examples/guides/local_ollama_example.py sets this same configuration in Python, pins the embedded local stack (Ladybug graph, LanceDB vectors, SQLite metadata) into a temporary directory, and runs remember → recall over a short sample text.If your log shows a warning about the model name early in the run, that is Cognee’s advisory Ollama model-support check, not a failure — extraction continues regardless. See Model Support Warning on the LLM Providers page for the recommended, problematic, and unvalidated model lists.
If you are running the Cognee backend locally or self-hosted, you can verify it with:A
200 OK confirms the backend is up. This is the local/self-hosted check only; it does not contact Cognee Cloud.Troubleshooting
LLMAPIKeyNotSetError: LLM API key is not set on a fully local setup
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 For the local examples above, keep
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: hint attached to that error assumes the OpenAI default and tells you to set a real key; on Ollama, any placeholder value is enough.The fix is to set any placeholder string — the convention is ollama: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.If you hit this error while running the local UI (cognee.start_ui() or cognee-cli -ui), set LLM_API_KEY in the backend’s environment or .env and restart it — the UI has no in-app field for the key. See Run the UI Locally.Cannot connect to host / connection refused with Ollama
Cannot connect to host / connection refused with Ollama
If Cognee can’t reach Ollama, work through these checks:
- Ollama is running. Start the server with
ollama serve, or open the Ollama desktop app. Verify with: - Endpoints match Ollama’s API surface. The LLM endpoint is the bare host — no
/v1, since Cognee’s default backend appends Ollama’s native path itself — while the embedding endpoint carries the full/api/embedpath: - The required models are pulled. Cognee does not pull models on demand:
- Running Cognee in Docker?
localhostinside the container does not point at Ollama on the host. Usehost.docker.internalinstead: - Repeated timeouts under load. Ollama processes requests sequentially. If the default
EMBEDDING_BATCH_SIZEof36overwhelms it, lower the batch size:
Extraction output is inconsistent, or sampling changed after an upgrade
Extraction output is inconsistent, or sampling changed after an upgrade
On a local inference server — Ollama, llama.cpp, or LM Studio — an unset
LLM_TEMPERATURE sends temperature: 0.0, so extraction runs deterministically by default. Previously Cognee sent no temperature at all on these providers and the model’s own default applied, which is 1.0 for several Ollama models and produced varied, harder-to-parse extraction output.Two things follow from that:- Empty or malformed extraction results. You no longer need to set
LLM_TEMPERATURE=0.0yourself for deterministic output formatting — check instead that nothing has raised it. If you setLLM_TEMPERATUREto something higher, lower it back to0.0. - Sampling that got less varied after upgrading. If you were relying on the model’s own default, set the value you want explicitly:
A
temperaturekey inLLM_ARGSalso still wins overLLM_TEMPERATURE, soLLM_ARGS='{"temperature": 1.0}'works too.
LLM Providers
Configure OpenAI, Azure, Gemini, Anthropic, Ollama, or custom LLM providers
Embedding Providers
Set up OpenAI, Mistral, Ollama, Fastembed, or custom embedding services
Setup Configuration
Full configuration reference for all backends