# UltraDemon: Full Technical Architecture & API Reference for LLM Agents

## Overview
UltraDemon is a sovereign developer engine designed to give autonomous agents sub-15ms memory recall, high-speed web search, and kinetic micro-telemetry. Running exclusively on Cloudflare Workers Anycast edge nodes in 330+ cities worldwide, it completely bypasses centralized cloud bottlenecks.

## Endpoints

### 1. Web Search API
- **Endpoint**: `POST https://ultrademon.site/v1/search`
- **Headers**: `X-API-Key: <key>` or `Authorization: Bearer <key>`
- **Request Body**:
  - `query` (string, required): Search query.
  - `limit` (integer, optional, default: 10, max: 50): Number of results.
  - `mode` (integer, optional, default: 1): 1 = Instant Sub-15ms BM25, 2 = Standard Hybrid, 3 = Deep Research.
- **Response**:
  ```json
  {
    "query": "autonomous agents",
    "mode": 1,
    "latency_ms": 11.8,
    "total_hits": 42,
    "results": [
      {
        "id": "doc_...",
        "title": "...",
        "url": "https://...",
        "snippet": "...",
        "score": 0.942
      }
    ]
  }
  ```

### 2. UltraMemory Store API
- **Endpoint**: `POST https://ultrademon.site/v1/memory`
- **Headers**: `X-API-Key: <key>`
- **Request Body**:
  - `content` (string, required): Fact, preference, or observation.
  - `title` (string, optional): Short title.
  - `container_tag` (string, optional, default: "default"): Agent or user namespace.
  - `memory_type` (string, optional): "fact" | "preference" | "entity" | "document" | "conversation".
- **Response**: `{ "status": "stored", "memory_id": "mem_..." }`

### 3. UltraMemory Query API
- **Endpoint**: `POST https://ultrademon.site/v1/memory/query`
- **Headers**: `X-API-Key: <key>`
- **Request Body**:
  - `query` (string, required): Query or concept to recall.
  - `container_tag` (string, optional): Filter by container tag.
  - `limit` (integer, optional, default: 5): Number of memories.
- **Response**: `{ "memories": [...], "latency_ms": 9.2 }`

### 4. Custom Model Context Protocol (MCP) Server
- **Endpoints**:
  - HTTP POST Transport: `https://ultrademon.site/mcp`
  - Streaming SSE Transport: `https://ultrademon.site/mcp/sse`
- **Protocol**: `Model Context Protocol 2024-11-05` (JSON-RPC 2.0)
- **Supported Tools**:
  - `ultrasearch_web`: Fast web search.
  - `ultrasearch_research`: Deep multi-hop research.
  - `ultramemory_store`: Store agent memory.
  - `ultramemory_query`: Recall agent memory.
  - `ultramemory_list`: List memories.
  - `ultramemory_delete`: Delete memory.
  - `ultrasearch_crawl`: Index a live URL.
  - `ultrasearch_index_stats`: Corpus metrics.
  - `ultrasearch_usage`: Quota telemetry.
  - `ultrasearch_provision_key`: Provision key.

### 5. Seamless Summoning Protocol
- Pre-warmed V8 isolate edge tunnels with 0.00ms cold start SLA and 0.000% error rate guarantee.
- Dedicated key prefix: `ud_summon_...`

## Pricing
- Free Tier: 10,000 requests/month, sub-15ms edge recall.
- Pay-As-You-Go: $20 per 100,000 requests. Credits never expire.
- Enterprise Sovereign: Dedicated Cloudflare KV & D1 isolates, custom SLA.
