Skip to main content
Deploy Cognee as a REST API server to expose its functionality via HTTP endpoints.

Setup

Edit .env with your preferred configuration. See Setup Configuration guides for all available options.

Deployment Methods

Start Server

Access API

Agent Mode

Cognee can run in agent mode, which tracks active agent connections and shuts the server down once they all disconnect. This is intended for ephemeral deployments where an external orchestrator launches a Cognee server for one or more agents and tears it down when they finish. Enable agent mode in either of two ways:
When agent mode is enabled:
  • The default port becomes 8011 (instead of 8000). The CLI flag overrides the COGNEE_AGENT_MODE env var. HTTP_API_PORT still wins if you set it explicitly.
  • A background watchdog starts after the first POST /api/v1/agents/register call and checks the active connection count every 60 seconds. When the count drops to zero, the watchdog sends SIGTERM to the server process.
  • The server stays alive indefinitely while waiting for the first registration — the watchdog does not arm until then.
Agents call POST /api/v1/agents/register on connect and POST /api/v1/agents/unregister on disconnect; see the Agent Management accordion below for the full surface.

Authentication

If REQUIRE_AUTHENTICATION=true in your .env file:
  1. Register: POST /api/v1/auth/register
  2. Login: POST /api/v1/auth/login
  3. Use token: Include Authorization: Bearer <token> header or use cookies

Python SDK Client

After deploying the server, connect the Python SDK to your running instance using cognee.serve():
You can also configure the connection via environment variables instead of passing arguments to serve():
The CloudClient returned by serve() exposes four methods that map to the server’s V2 endpoints: remember() (ingest + cognify), recall() (search), improve() (enrich graph), and forget() (delete). Call await cognee.disconnect() to revert to local mode.

Uploading skills

client.remember(..., content_type="skills") ingests local SKILL.md files as Skill nodes. Pass either a single SKILL.md file path or a directory; directories are searched recursively for SKILL.md files. The client reads the local file contents and uploads their bytes (preserving the relative folder layout), so the path is resolved on the caller’s machine rather than on the server:
The client raises FileNotFoundError when the path does not exist and ValueError when a directory contains no SKILL.md files.
When a skill push reaches the server without any file named SKILL.md — for example a direct POST /api/v1/remember upload with content_type=skills whose uploaded files use other names — the server now ingests each uploaded file as an individual skill instead of skipping the push. Pushes that already contain SKILL.md files are ingested as before, preserving their folder layout.

HTTP API Examples

Register a user:
Login and get token:
Create a dataset:
List datasets:
Remember data and build memory in one call:
Recall from a dataset with explicit retrieval settings:
Improve an existing dataset in the background:
Forget only derived memory and keep the uploaded files:
Both POST /api/v1/remember and POST /api/v1/add expect multipart/form-data, where data is one or more file uploads — not a JSON body or a plain form string. Sending text directly (for example -F "data=some text" or a JSON {"data": "..."} body) fails validation with:
Attach a file with curl’s @ prefix instead:
To ingest raw text, write it to a file first and upload that file:
You can attach multiple files by repeating -F "data=@...". If you prefer to send raw strings as JSON, use the Python SDK (await client.remember("some text", ...)) or the POST /api/v1/skills JSON endpoint for skill markdown — the multipart endpoints always require file uploads.Targeting a remote (non-localhost) server: replace http://localhost:8000 with your server’s address, e.g. http://<host-or-ip>:8000 on a private network or https://cognee.example.com behind a reverse proxy. Bind the server to a reachable interface with --host 0.0.0.0 (see the Python (Local) tab), and keep authentication enabled whenever the server is not on a trusted, private network.
The /api/v1/activity router exposes endpoints for pipeline run history, trace data, tenant or agent monitoring, and dataset export. All endpoints require authentication.Reading the pipeline-runs feedEvery row carries a kind discriminator (never null):
  • "pipeline" — a pipeline run; pipeline_name is set.
  • "operation" — a single-row operation record; pipeline_name and status are null, so status-based readers do not see these rows at all.
Alongside the original id, pipeline_name, status, dataset_id, dataset_name, owner_id, owner_email, created_at and pipeline_run_id keys, each row carries the operation columns below. All of them are nullable — rows written before this feature were not backfilled, and each writer sets only the subset it knows.Two values are easy to misread:
  • tokens_in / tokens_out of null means not measured; 0 means measured zero. Do not conflate them, and do not use a truthiness check.
  • When background is true, an outcome of "succeeded" means the work was accepted and started, not that it finished. Counting those rows as completions inflates any success-rate or cost figure derived from the feed.
The table behind the feed is append-only, so tokens_* cannot be summed row by row either — a pipeline run contributes several rows sharing one pipeline_run_id, and parent_operation_id chains child totals into their parent. See what gets stored in a pipeline run record for the deduplication rules.Pagination. The response is a bare JSON array with no total — it has always been a top-level array, so no paging envelope was added. len(results) == limit means another page may exist.Visibility. Without dataset_id, the feed returns rows authored by the caller or their child agents, plus rows on any dataset shared with them. Note that recall, prune and multi-dataset search records carry no dataset_id, so passing dataset_id omits them entirely; passing a dataset_id the caller cannot read is still a 403.
A row can be visible because the caller authored it even when the caller has no read permission on its dataset (write-only access, or read revoked after the run). In that case dataset_name, owner_id and owner_email come back as null while dataset_id is still returned. Clients that render activity entries should tolerate a missing dataset name rather than assuming it is always present.
When running Cognee as a server, two /api/v1/llm endpoints can help you bootstrap a custom extraction prompt from sample text:
  • POST /api/v1/llm/infer-schema — analyze sample text and return a graph schema
  • POST /api/v1/llm/custom-prompt — generate a custom extraction prompt from that schema
Typical flow: infer a schema from sample text, generate a prompt, then pass that prompt to POST /api/v1/cognify.
Optional parameters keys for the LLM endpoints include temperature, max_tokens, top_p, and seed.
The /api/v1/agents router exposes two groups of endpoints: agent management (create / list / get / delete an agent identity) and agent connections (register, unregister, and inspect live sessions). All endpoints require authentication. Agent identities are persisted as child users of the calling user, keyed by UUID (agentId in API responses), and authenticate to Cognee using the API key returned on creation — agents do not have passwords.RegisterAgentRequest body fields: agent_session_name (required — combined with the caller’s user ID to form the connection ID), type (sdk/api/mcp/claude_code/opencode/workflow/unknown, default api), memory_mode (session/cognee/hybrid/none/unknown), session_id, dataset_ids, dataset_names, source, origin_function, metadata.
When the server runs in agent mode, register and unregister drive the auto-shutdown watchdog. The same agent_session_name registered twice by the same user counts as a single connection — registration is idempotent on the connection ID.
Create tenant:
Add user to tenant:
Create role:
Assign user to role:
Grant dataset permissions:

API Reference

Explore all API endpoints

Setup Configuration

Configure providers and databases

MCP Integration

Set up AI assistant integration