Skip to main content

Data Models

Key Pydantic models and types used in the cognee Python API.

SearchResult

Returned by cognee.search().
class SearchResult:
    search_result: Any       # The actual result content
    dataset_id: UUID | None  # Associated dataset UUID
    dataset_name: str | None # Associated dataset name

PipelineRunInfo

Returned by cognee.add(), cognee.cognify(), and pipeline functions.
class PipelineRunInfo:
    status: str                # Pipeline status
    pipeline_run_id: UUID      # Unique run identifier
    dataset_id: UUID           # Associated dataset
    dataset_name: str          # Dataset name
    payload: Any | None        # Execution payload
    data_ingestion_info: list | None  # Ingestion details
Status values: PipelineRunStarted, PipelineRunYield, PipelineRunCompleted, PipelineRunAlreadyCompleted, PipelineRunErrored

Task

Wraps a callable for use in pipelines.
from cognee.modules.pipelines import Task

# Wrap any async generator, generator, coroutine, or function
task = Task(my_function, task_config={"batch_size": 10})
executable
Callable
required
The function to execute. Can be an async generator, generator, coroutine, or regular function.
task_config
dict
default:"{\"batch_size\": 1}"
Task configuration, primarily batch size.

DataPoint

The public base class for all user-defined graph entities. Extend DataPoint to create custom node types that Cognee can index, search, and connect in the knowledge graph.
class DataPoint:
    id: UUID                           # Unique identifier
    created_at: int                    # Creation timestamp (ms)
    updated_at: int                    # Update timestamp (ms)
    version: int                       # Version number
    type: str                          # Data type name
    ontology_valid: bool               # Ontology validation status
    topological_rank: int | None       # Topological rank
    belongs_to_set: list[str] | None   # Node set membership
    source_pipeline: str | None        # Source pipeline name
    source_node_set: str | None        # Source node set
Key methods: to_json(), from_json(), to_dict(), from_dict(), update_version() See DataPoints and Custom Data Models for usage details.

KnowledgeGraph

Default graph model used by cognify() as an internal LLM extraction format. The LLM populates this structure while processing documents; it is not exported from the top-level cognee package and is not intended for user extension.
class KnowledgeGraph(BaseModel):
    nodes: list[Node]    # Graph nodes
    edges: list[Edge]    # Graph edges
    summary: str         # Graph summary
    description: str     # Graph description
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)

class Node:
    id: str
    name: str
    type: str
    description: str

Edge (internal)

class Edge:
    source_node_id: str
    target_node_id: str
    relationship_name: str

Exceptions

All cognee exceptions inherit from CogneeApiError:
ExceptionStatus CodeUse
CogneeSystemError500Internal system errors
CogneeValidationError422Invalid input/parameters
CogneeConfigurationError500Misconfiguration
CogneeTransientError503Temporary failures (retry)