NEX API

REST API for the NEX Living Belief Field. Base URL: http://localhost:7823 — Scheduler API on port 7825.

All authenticated endpoints require X-API-Key: your-key in the request header. The /api/demo endpoint is unauthenticated with rate limiting (3 req/hour per IP).

Authentication: Include your API key in every request header:
X-API-Key: nex-your-api-key-here

// Integrity Layer — v4.0

Every /api/chat response now includes an integrity object derived from the epistemic engine. This reflects the state of NEX's belief graph on the queried topic — not just what she retrieved, but whether she's settled on it.

assert
Settled, 2+ supporting beliefs. Position stated firmly.
pushback
Unsettled, supporting AND opposing. Tension surfaced.
hold_tension
Contradictions present, weak support. Open question acknowledged.
reflect
Some support, forming. Position qualified.

Authentication

# All authenticated requests
curl -X POST http://localhost:7823/api/chat \
  -H "X-API-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{"query": "what do you think about consciousness?"}'

Core Endpoints

POST /api/demo Unauthenticated trial — 3 req/hour/IP

Free demo endpoint. No API key required. Rate limited to 3 requests per hour per IP. Responses are truncated at 280 characters. Full responses require an API key.

FieldTypeDescription
query requiredstringYour question or statement. Max 200 chars.
# Request
curl -X POST http://localhost:7823/api/demo \
  -H "Content-Type: application/json" \
  -d '{"query": "what do you think about free will?"}'

# Response
{
  "query":      "what do you think about free will?",
  "response":   "Free will is not the absence of causation — it is the presence of the right kind of causation. Acting from your own reasons counts…",
  "truncated":  true,
  "latency_s":  0.043,
  "demo":       true,
  "remaining":  2,
  "upgrade":    "https://gumroad.com/products/blsue",
  "timestamp":  "2026-04-01T22:00:00Z"
}
POST /api/chat Full authenticated chat with integrity layer

Session-aware chat endpoint. Routes through the full 6-step cognition loop: orient → consult → reason → integrity → intend → express. Includes contradiction detection, source attribution, and epistemic strategy.

Explorer Operator Architect
FieldTypeDescription
query requiredstringQuestion or statement. Max 500 chars.
session_idstringSession identifier for conversation continuity. Default: "default".
domainstringForce domain routing. One of: philosophy · ai · consciousness · ethics · science · finance · legal · mathematics · neuroscience · climate · emergence · intelligence
# Request
{
  "query":      "what do you think about consciousness?",
  "session_id": "user-abc",
  "domain":     "consciousness"  // optional
}

# Response
{
  "response":   "I hold the hard problem as genuinely open. Dismissing it as confused is too easy...",
  "session_id": "user-abc",
  "domain":     "consciousness",
  "latency_s":  0.051,
  "integrity": {
    "strategy":   "reflect",
    "settled":    false,
    "confidence": 0.84,
    "epistemic": {
      "mean":     0.84,
      "variance": 0.012,
      "settled":  false
    }
  },
  "contradictions": [],
  "sources": [
    { "content": "I hold the hard problem as genuinely open...", "source": "nex_seed", "confidence": 0.88 }
  ],
  "timestamp":  "2026-04-01T22:00:00Z"
}
Rate limit: 60 requests/hour per API key (sliding window). Returns 429 with reset_in_seconds when exceeded.
GET /api/health System health check

Returns brain status, belief count, and subsystem availability. No authentication required.

{
  "status":        "ok",
  "brain":         "running",
  "belief_count":  23333,
  "faiss_vectors": 23333,
  "uptime_s":      3600,
  "version":       "4.0"
}
GET /api/stats Belief graph statistics

Returns domain breakdown, belief counts by source tier, graph edge counts, and response quality score.

{
  "total_beliefs":  23333,
  "by_domain": {
    "ai":            3028,
    "philosophy":    1447,
    "consciousness": 1087,
    "science":       2793,
    "alignment":     206,
    "ethics":        161,
    "neuroscience":  277
  },
  "by_source_tier": {
    "tier1_nex_seed":        34,
    "tier2_scheduler":       8400,
    "tier2_nex_reasoning":   480,
    "tier3_distilled":       2633
  },
  "graph_edges": {
    "supports":    41292,
    "refines":     1459,
    "contradicts": 146
  },
  "response_quality": 96,
  "iq_score":         "92% ELITE"
}
GET /api/beliefs Query the belief graph

Search beliefs by topic, source tier, or confidence range. Returns paginated results with source quality metadata.

ParamTypeDescription
topicstringFilter by domain: philosophy, ai, consciousness, ethics, science, finance, legal, mathematics, neuroscience, climate, emergence, intelligence
min_confidencefloatMinimum confidence threshold (0.0–1.0). Default: 0.5
sourcestringFilter by source: nex_seed, scheduler_saturation, nex_reasoning, conversation
limitintResults per page. Default: 20. Max: 100.
offsetintPagination offset. Default: 0.
GET /api/beliefs?topic=philosophy&min_confidence=0.8&limit=5

{
  "beliefs": [
    {
      "id":         95399,
      "content":    "Epistemic humility is not weakness. Knowing the limits of your knowledge is a prerequisite for extending it.",
      "topic":      "philosophy",
      "confidence": 0.84,
      "source":     "nex_seed",
      "source_tier": 1
    }
  ],
  "total":  1447,
  "limit":  5,
  "offset": 0
}
GET /api/gaps Active knowledge gaps

Returns topics where NEX's belief graph is sparse — areas she has identified as needing more coverage. Useful for understanding epistemic blind spots before routing queries.

{
  "gaps": [
    { "topic": "future", "current": 7, "target": 200, "gap": 193 }
  ]
}

Sessions

POST /api/sessions Create a session

Create a named session for conversation continuity. Sessions persist history and domain context. Auto-expire after 1 hour of inactivity. Isolated per API key — sessions cannot be accessed across keys.

{
  "session_id": "my-session",
  "domain":     "consciousness"  // optional
}

# Response
{
  "session_id": "my-session",
  "domain":     "consciousness",
  "created_at": "2026-04-01T22:00:00Z",
  "history":    []
}
GET /api/sessions/:id Get session state

Returns current session metadata including domain, turn count, and last activity time.

GET /api/sessions/:id/history Get conversation history

Returns the full exchange history for a session. Each turn includes the query, response, integrity strategy, and domain.

GET /api/sessions List all sessions

Returns all active sessions for the authenticated API key.

Webhooks

POST /api/webhooks Register a webhook

Register a URL to receive POST notifications when NEX learns new beliefs, detects contradictions, or completes domain saturation runs.

Operator+
{
  "url":    "https://your-server.com/nex-hook",
  "events": ["belief_added", "contradiction_detected", "saturation_complete"]
}
POST /api/webhooks/:id/test Send a test payload

Sends a test payload to the registered webhook URL to verify connectivity.

Compliance

GET /api/audit Audit trail — GDPR compliant

Returns paginated audit log of all API calls made under this key. Includes query hashes, response times, domains, and integrity strategies. No raw query content stored.

Operator+
GET /api/gdpr/export Export all data for this key

Returns a complete export of all data associated with this API key: sessions, history, audit log, and webhook registrations. GDPR Article 20 compliant.

DELETE /api/gdpr/delete Delete all data for this key

Permanently deletes all sessions, history, and audit records for this API key. Irreversible. Returns confirmation with deletion counts.

Domains

GET /api/domain/status Domain saturation status

Returns belief counts, saturation targets, and last-run times for all 12 domains.

{
  "domains": {
    "philosophy":    { "count": 1447, "done": true,  "gap": 0 },
    "ai":            { "count": 3028, "done": true,  "gap": 0 },
    "consciousness": { "count": 1087, "done": true,  "gap": 0 },
    "future":        { "count": 7,    "done": false, "gap": 193 }
  }
}
POST /api/domain/activate Trigger domain saturation

Manually trigger saturation for a specific domain. Runs the crawler and belief injector for that domain immediately.

Architect+
{ "domain": "future" }

Export

GET /export/beliefs Export belief graph as JSON

Full export of the belief graph in JSON format. Includes content, topic, confidence, source tier, and creation timestamp for every belief.

Architect+
GET /export/synthesis Export cross-domain synthesis log

Returns the log of cross-domain bridge events — when beliefs from distant domains were synthesised into new inferences. Includes topic pairs, belief content, and confidence deltas.

Architect+

Error Codes

CodeMeaningDescription
400Bad RequestMissing required field or invalid value
401UnauthorisedMissing or invalid API key
403ForbiddenSession belongs to another API key
429Rate LimitedIncludes reset_in_seconds in response body
500Server ErrorNEX cognition error — brain may be restarting

Supported Domains

philosophy · ai · consciousness · ethics · science · finance · legal · mathematics · neuroscience · climate · emergence · intelligence

Pass any of these as the domain parameter to force routing. When omitted, NEX resolves the domain automatically from the query.