Skip to main content
The Cognee Python SDK can connect to a remote Cognee instance using cognee.serve(). Once connected, all operations (remember, recall, forget, improve) route to the remote instance instead of running locally.

Connect to Cognee Cloud

After login, the SDK stores credentials at ~/.cognee/cloud_credentials.json. Subsequent calls to cognee.serve() first health-check the saved instance URL using the cached API key, and reconnect without re-authenticating whenever that instance responds — even if the stored Auth0 access token has expired. Re-authentication (a token refresh when possible, otherwise a browser login) runs only when no usable credentials are cached or the saved instance does not respond.
Because reuse is gated on the instance being reachable rather than on token lifetime, an expired token by itself no longer blocks startup: a healthy instance keeps accepting your cached credentials through an Auth0 outage.

Connect to any instance

For self-hosted or staging environments, pass the URL and API key directly:
Or use environment variables:

Local-to-local connections

Connect to a Cognee backend on the same machine or local network:
Start the local server with cognee serve before connecting.

Usage after connection

Once connected, all SDK operations execute on the remote instance:
The local UI in Cognee Cloud automatically detects running local instances on localhost:8000 and shows their connection status.

Push a prebuilt graph instead of raw data

Connecting with serve() and re-running remember() makes the remote instance rebuild the knowledge graph. If you have already built the graph locally and want to avoid re-deriving it (and the LLM cost that comes with it), use cognee.push() instead. It exports the dataset’s graph as a COGX archive and imports it on the remote instance, preserving your local entities and relationships:
The same operation is available from the terminal as cognee push.