Skip to main content

cognee.push()

Description

Upload a local dataset’s already-built knowledge graph to a Cognee Cloud (or any remote Cognee) instance. The dataset’s graph is exported to a COGX archive, packed as a tarball, uploaded, and imported on the remote instance — preserving the entities and relationships you extracted locally instead of re-deriving them from the raw files. This is what distinguishes push() from sync(): push() ships the graph so the remote side does little or no LLM work, while sync() ships the raw data and the remote instance rebuilds the graph itself.
The dataset must already have a knowledge graph. If the export finds 0 nodes, push() raises an error — run cognify() (or remember()) on the dataset first.

Authentication

push() reuses the serve() credential stack. Run cognee.serve() (or cognee-cli serve) once to log in, then push any time. The remote target is resolved in this order:
  1. Explicit url / api_key arguments
  2. An active cognee.serve() connection
  3. COGNEE_SERVICE_URL / COGNEE_API_KEY environment variables
  4. Saved credentials from a previous serve() login (~/.cognee/cloud_credentials.json)
If none resolve, push() raises a RuntimeError telling you to authenticate.

Parameters

Union[str, UUID]
default:"'main_dataset'"
Local dataset name or UUID to push. Requires read permission.
Optional[str]
default:"None"
Dataset name on the remote instance. Defaults to the local dataset’s name.
str
default:"'preserve'"
Remote import fidelity. One of preserve, hybrid, or re-derive (see below).
bool
default:"False"
If true, the remote import is scheduled and the call returns once the upload completes; poll the returned pipeline_run_id for progress. Recommended for large graphs.
Optional[str]
default:"None"
Remote instance URL. Falls back to the active serve() connection, COGNEE_SERVICE_URL, or saved credentials.
Optional[str]
default:"None"
API key for the remote instance. Falls back like url.
User
default:"None"
Local user context for the export. Uses the default user when omitted.

Import modes

Returns

A PushResult dataclass:
str
Status reported by the remote remember call (for example "started").
str
Name of the local dataset that was exported.
str
Dataset name the graph was imported into on the remote instance.
int
Number of nodes uploaded.
int
Number of edges uploaded.
Optional[str]
Remote migration pipeline run id; poll it when run_in_background=True.
dict
Raw response returned by the remote remember endpoint.

Examples

The remote instance must run a Cognee version with COGX archive import support. Against an older server the upload is accepted but ingested as a plain file; push() detects this and raises an error rather than silently degrading. Upgrade the remote instance, or use sync() / remember() with raw data instead.

See also