Skip to main content
After completing the installation steps successfully, run your first Cognee example to see AI memory in action.

Run it without an API key

If you haven’t configured LLM_API_KEY yet, one CLI command proves the install works:
It imports a small knowledge graph that ships inside the cognee package and answers two example questions from it. The import is graph-only (no embeddings are computed) and the queries use CHUNKS_LEXICAL, a keyword search — so the whole run makes no LLM calls and no embedding calls, and works on a machine with no network access. The only outbound request is Cognee’s anonymous telemetry event, which is best-effort (it fails silently offline) and switched off entirely by TELEMETRY_DISABLED=true. Clean up afterwards with cognee-cli forget --dataset demo. See the CLI reference for its flags and output.
The demo is a keyword search over a pre-built graph. The Python example below builds a graph from your own text and gets an LLM-written answer, so it does need LLM_API_KEY configured.

Basic Usage

This minimal example shows how to store content and retrieve it:
Output wording may vary by provider and model, but it should answer the question using the text stored with remember.

Interactive knowledge graph visualization — drag nodes, zoom, and hover for details. Create your own visualization with 2 additional lines of code here.

Open visualization full screen

What just happened

The code demonstrates Cognee’s two primary v1.0 operations:
  • .remember — Stores data in memory. Under the hood it runs ingestion, chunking, entity extraction, graph building, and a follow-up enrichment pass. The result is a fully queryable knowledge graph.
  • .recall — Retrieves from memory. It auto-routes the query to the best retrieval strategy and returns contextual results from the knowledge graph.

About async / await in Cognee

Cognee uses asynchronous code extensively. That means many of its functions are defined with async and must be called with await. This lets Python handle waiting (e.g. for I/O or network calls) without blocking the rest of your program.
This example uses async / await, Python’s way of doing asynchronous programming. Asynchronous programming is used when functions may block because they are waiting for something (for example, a reply from an API call). By writing async def, you define a function that can pause at certain points. The await keyword marks those calls that may need to pause. To run such functions, Python provides the asyncio library. It uses a loop, called the event loop, which executes your code in order but, whenever a function is waiting, can temporarily run another one. From inside your function, though, everything still runs top-to-bottom: each line after an await only executes once the awaited call has finished.
  • A good starting point is this guide.
  • Official documentation is available here.

Next Steps

Cognee core concepts

Learn about Cognee’s core concepts, architecture, building blocks, and main operations.

Improve and enrich memory

Enrich an existing graph and bridge session memory into permanent memory.