API Documentation

Base URL
https://memflux.org/v1

All endpoints require an API key via the X-API-Key header (except auth endpoints).

Authentication
POST /v1/auth/register

Register a new account. Returns user, session token, and first API key.

{ "email": "user@example.com", "password": "pass123", "name": "John" }
POST /v1/auth/login

Login with email and password. Returns session token.

{ "email": "user@example.com", "password": "pass123" }
Graph Operations
POST /v1/graph/add

Add text to the knowledge graph. LLM-less extraction — returns nodes, relations, keywords, and entities found.

{
  "text": "FastAPI is a modern Python web framework...",
  "source": "optional-source-id",
  "metadata": {}
}
{
  "nodes_added": 16,
  "relations_added": 48,
  "keywords_extracted": ["fastapi", "python", "framework", ...],
  "processing_time_ms": 50
}
POST /v1/graph/query

Query the graph for relevant nodes and relations.

{ "query": "What is FastAPI?", "limit": 10, "min_score": 0.5 }
GET /v1/graph/stats

Get graph statistics (node count, relation count, types, tags).

DELETE /v1/graph/nodes/{node_id}

Delete a node and its relations.

DELETE /v1/graph/relations/{relation_id}

Delete a relation.

Context Generation
POST /v1/context/generate

Generate compressed, relevant context from the graph. This is the core innovation — instead of sending thousands of entries to an LLM, you get only the most relevant, compressed context.

{
  "query": "How does FastAPI handle authentication?",
  "max_tokens": 2000,
  "max_nodes": 50,
  "include_relations": true,
  "format": "structured"
}
{
  "context": "Context for query: ...",
  "nodes_used": 10,
  "relations_used": 20,
  "total_candidates": 16,
  "compression_ratio": 0.625,
  "processing_time_ms": 3,
  "estimated_tokens": 450
}

Format options: structured (default), text, json

API Key Management
POST /v1/keys/createCreate new key
GET /v1/keys/listList your keys
DELETE /v1/keys/{key_id}Revoke a key
PUT /v1/keys/{key_id}/openrouterSet OpenRouter API key (encrypted)
Authentication Header

All API endpoints (except /auth/*) require the X-API-Key header:

X-API-Key: gc_sk_xxxxxxxxxxxxxxxxxxxxxxxxx
Rate Limits
TierRequests/Min
Free60
Pro300
Ultimate1000
Quick Start — cURL
# Add data to your graph
curl -X POST https://memflux.org/v1/graph/add \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gc_sk_your_key_here" \
  -d '{"text": "Your knowledge text here..."}'

# Generate context
curl -X POST https://memflux.org/v1/context/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: gc_sk_your_key_here" \
  -d '{"query": "What do you know about X?"}'