Skip to main content
A minimal guide to the smallest end-to-end Cognee script. Use it as the starting point for a new project: one passage of text goes in with remember(), one question comes back answered with recall(), and nothing else is configured.

Before You Start

  • Complete Quickstart to understand basic operations
  • Ensure you have LLM Providers configured — the answer is generated by a language model
  • Read Remember and Recall for what the two operations do
  • No data is required up front — the script ingests its own passage, but it starts with cognee.forget(everything=True), which wipes all existing Cognee data; run it against a setup you can afford to reset

Code in Action

What Just Happened

Step 1: Start From a Clean Slate

forget(everything=True) deletes every dataset, graph node, embedding, and session-cache entry the current user owns, so the run starts with an empty graph and the answer can only come from the passage below. Leave this line out of your own application — you rarely want to erase everything before storing something new.

Step 2: Remember the Passage

remember() takes raw text and runs the full ingestion workflow on it: the passage is chunked, entities and relationships are extracted, and the result is written to the graph as memory. self_improvement=False keeps the run to plain ingestion instead of also running improve().

Step 3: Recall an Answer

SearchType.GRAPH_COMPLETION retrieves the graph triplets relevant to query_text, builds a context from them, and asks a language model to answer from that context. recall() returns a list, so the loop prints each result — with this small a graph, expect a single answer describing NLP.

Step 4: Run the Script

Both operations are asynchronous, so main() runs under asyncio.run(). The setup_logging(log_level=ERROR) call no longer changes the console level: logging is configured once per process, on the first call, and import cognee already made it. To keep Cognee’s own progress logging out of the output, set LOG_LEVEL=ERROR in your .env or in the environment before importing Cognee — see Setting the Log Level.

Remember

Every way to get data into Cognee memory, and what each option changes.

Recall

Understand recall()‘s full parameter surface and auto-routing behavior.

Inspecting Graph Completion Context

See the triplets GRAPH_COMPLETION retrieved before it answered.