Basic Usage
This minimal example shows how to store content and retrieve it:Visualisation
Visualisation
Interactive knowledge graph visualization — drag nodes, zoom, and hover for details. Create your own visualization with 2 additional lines of code here.
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.
add, cognify, and search operations are still available.
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.Async basics
Async basics
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.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.