Setup
Edit
.env with your preferred configuration. See Setup Configuration guides for all available options.Deployment Methods
- Docker
- Python (Local)
Start Server
Access API
- API: http://localhost:8000
- Documentation: http://localhost:8000/docs
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:- The default port becomes
8011(instead of8000). The CLI flag overrides theCOGNEE_AGENT_MODEenv var.HTTP_API_PORTstill wins if you set it explicitly. - A background watchdog starts after the first
POST /api/v1/agents/registercall and checks the active connection count every 60 seconds. When the count drops to zero, the watchdog sendsSIGTERMto the server process. - The server stays alive indefinitely while waiting for the first registration — the watchdog does not arm until then.
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
IfREQUIRE_AUTHENTICATION=true in your .env file:
- Register:
POST /api/v1/auth/register - Login:
POST /api/v1/auth/login - 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 usingcognee.serve():
serve():
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.
HTTP API Examples
Authentication
Authentication
Register a user:Login and get token:
Dataset Management
Dataset Management
Create a dataset:List datasets:
Data Operations
Data Operations
- Cognee v1.0
- Legacy Operations
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:
Activity and Observability
Activity and Observability
The
/api/v1/activity router exposes endpoints for pipeline run history, trace data, tenant or agent monitoring, and dataset export. All endpoints require authentication.| Endpoint | Description |
|---|---|
GET /api/v1/activity/pipeline-runs | Last 50 pipeline runs with dataset name and owner. Accepts optional ?dataset_id=<uuid> to filter by dataset. |
GET /api/v1/activity/spans | In-memory OTEL span buffer (last 50 traces). Requires COGNEE_TRACING_ENABLED=true. Returns an empty list when tracing is disabled. |
GET /api/v1/activity/users | All active users in the current tenant. |
GET /api/v1/activity/agents | Registered agents with status (LIVE / INACTIVE), API key count, and recent activity flag. |
GET /api/v1/activity/export/{dataset_id} | Downloads the dataset’s knowledge graph as a Markdown export. |
- Pipeline Runs
- Trace Buffer
- Dataset Export
LLM Utility Endpoints
LLM Utility Endpoints
When running Cognee as a server, two Optional
/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 schemaPOST /api/v1/llm/custom-prompt— generate a custom extraction prompt from that schema
POST /api/v1/cognify.- Infer Schema
- Generate Prompt
- Use with Cognify
parameters keys for the LLM endpoints include temperature, max_tokens, top_p, and seed.Agent Management
Agent Management
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.| Endpoint | Description |
|---|---|
POST /api/v1/agents/create?name=<name> | Create an agent identity. Returns agentId (UUID), a synthesized agentEmail, and the one-time agentApiKey. Store the key — it is not retrievable later. Returns 409 if an agent with that name already exists for the caller. |
GET /api/v1/agents/list | List agents created by the authenticated user. Each item includes agentId, agentEmail, and apiKeyLabel. |
GET /api/v1/agents/{agent_id} | Fetch a single agent. 404 if not found, 403 if the caller does not own it. |
DELETE /api/v1/agents/{agent_id} | Delete an agent. 404 / 403 as above. |
POST /api/v1/agents/register | Register an agent connection (session). Body uses RegisterAgentRequest (see below). Returns the created AgentConnection. 201 Created. |
POST /api/v1/agents/unregister | Deactivate a connection. Body: { "agent_session_name": "<name>" }. Returns { "activeAgents": <count> }. |
GET /api/v1/agents/connections | List agent connections visible to the caller. Filters: agent_id, range (24h/7d/30d/all, default 30d), status (active/inactive/unknown), include_sources, active_only, limit (1–500, default 50), offset. |
GET /api/v1/agents/connections/me | Connection detail for the authenticated user’s own agent connection. Optional agent_session_name query filter. 404 if no matching connection. |
GET /api/v1/agents/connections/{agent_id} | Connection detail for a specific agent. Optional agent_session_name query filter. |
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/workflow/unknown, default api),
memory_mode (session/cognee/hybrid/none/unknown), session_id,
dataset_ids, dataset_names, source, origin_function, metadata.- Create an Agent
- Register a Connection
- Unregister
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.Multi-tenant Operations
Multi-tenant Operations
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