Data Models
Key Pydantic models and types used in the cognee Python API.SearchResult
Returned bycognee.search().
PipelineRunInfo
Returned bycognee.add(), cognee.cognify(), and pipeline functions.
PipelineRunStarted, PipelineRunYield, PipelineRunCompleted, PipelineRunAlreadyCompleted, PipelineRunErrored
data_ids
data_ids is computed from data_ingestion_info: the ids of the Data rows the run processed, in result order, without duplicates. Items that errored are left out. Items that already existed with the same content (PipelineRunAlreadyCompleted) are included, because the existing row holds that content. For add(), use these ids for later update() or datasets.delete_data() calls instead of working them out from the content yourself.
data_ids is None, and the key is left out of serialized output, when the run info has no data_ingestion_info. This covers PipelineRunStarted, progress updates, the run infos nested inside data_ingestion_info entries, and add(run_in_background=True), which returns before the items are stored. The field is serialized with the model, so POST /api/v1/add responses include it too.
data_ingestion_info entries
Each entry describes one data item the run handled:data_name, data_location and data_label are set on the incremental path, which runs when incremental_loading or data_cache is True (both are by default). They are filled for failed items too, so you can tell which files in a folder failed, but only with RAISE_INCREMENTAL_LOADING_ERRORS=false: by default a failing item aborts the run and the error is raised instead of returned. Use them to match ids to inputs: data_ids does not line up one-to-one with what you passed in.
A PipelineRunErrored run info additionally carries error_class: str | None and error_message: str | None (PII-scrubbed) naming the root cause of the failure. See Failed runs for how to read them.
Task
Wraps a callable for use in pipelines.The function to execute. Can be an async generator, generator, coroutine, or regular function.
DataPoint
The public base class for all user-defined graph entities. ExtendDataPoint to create custom node types that Cognee can index, search, and connect in the knowledge graph.
to_json(), from_json(), to_dict(), from_dict(), update_version()
See DataPoints and Custom Data Models for usage details.
KnowledgeGraph
Default graph model used bycognify() and remember() as an internal extraction format. With no graph_model argument, it is filled once per chunk by the LLM, or, when no LLM key is configured, by the GLiNER demo extractor. It is a plain Pydantic model, not a DataPoint, and is never stored as it is. It is not exported from the top-level cognee package and is not intended for user extension.
LLM_PROVIDER=gemini, a Gemini variant is selected at import. It also requires summary: str and description: str on KnowledgeGraph and label: str on Node, to work around a Gemini structured-output restriction. Graph construction reads only nodes and edges in both variants.
Node and the Edge type nested inside KnowledgeGraph are used as internal pipeline types during extraction, rather than as user-facing extension points. For custom entities and application models, use DataPoint subclasses instead.Node (internal)
Edge (internal)
How a filled KnowledgeGraph is stored
Cognee turns each chunk’sKnowledgeGraph into Entity, EntityType and Timestamp nodes, contains edges from the chunk, and the extracted relationships:
Node.idis local to one chunk’s graph: edges use it to name their endpoints, but it is not the stored id. The storedEntityid comes fromname, so the same name in different chunks or documents becomes one node. Two nodes with the same name in one chunk graph stay separate. If two nodes in one chunk graph share anid, only the first is kept.Node.typebecomes anEntityTypenode the entity points to withis_a. A blank type creates none. A node of typeTimestampwhose name is a normalized time (YYYY,YYYY-MM,YYYY-MM-DD, …) becomes aTimestampnode, whichSearchType.TEMPORALuses to find facts by date.- An edge whose endpoint is not among the chunk’s nodes is skipped. Relationships already in the graph are not written again.
Edge.descriptionbecomes the stored edge’s text and, with the defaultSUMMARY_METHOD=from_extraction, a line of the chunk’s summary.
Exceptions
All cognee exceptions inherit fromCogneeApiError: