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

Base model for all graph entities.
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()

KnowledgeGraph

Default graph model used by cognify().
class KnowledgeGraph(BaseModel):
    nodes: list[Node]    # Graph nodes
    edges: list[Edge]    # Graph edges
    summary: str         # Graph summary
    description: str     # Graph description

Node

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

Edge

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)