{"owner":"elder-plinius","repo":"G0DM0D3","hasSkills":true,"totalSkillsCount":1,"totalTokensCount":8784,"categories":["project-spec"],"hasMcp":false,"mcpConfig":null,"found":["API.md"],"skills":{"API.md":"# G0DM0D3 Research Preview API\n\nREST API exposing the **ULTRAPLINIAN** multi-model racing engine and core G0DM0D3 systems: **AutoTune** (context-adaptive LLM parameter tuning), **Parseltongue** (text obfuscation), **STM** (semantic text transformation), **Feedback Loop** (EMA-based parameter learning), and **opt-in open dataset collection**.\n\n## Quick Start\n\n```bash\n# Local\nnpm run api\n\n# Docker\ndocker build -t g0dm0d3-api .\ndocker run -p 7860:7860 g0dm0d3-api\n\n# With auth enabled\ndocker run -p 7860:7860 -e GODMODE_API_KEY=your-secret-key g0dm0d3-api\n```\n\n## Authentication\n\nSet `GODMODE_API_KEY` (single key) or `GODMODE_API_KEYS` (comma-separated) as environment variables. If neither is set, auth is disabled (open access for local dev).\n\n```bash\ncurl -H \"Authorization: Bearer your-secret-key\" ...\n```\n\n## Rate Limits & Tiers\n\nRate limits are tier-dependent. Assign keys to tiers via `GODMODE_TIER_KEYS`:\n\n```bash\nGODMODE_TIER_KEYS=\"enterprise:sk-ent-xxx,pro:sk-pro-yyy\"\n```\n\n| Tier | Total | Per Minute | Per Day | ULTRAPLINIAN | Research | Dataset Export |\n|------|-------|-----------|---------|-------------|----------|---------------|\n| **Free** (default) | 5 | 10 | 50 | fast (10 models) | none | none |\n| **Pro** | unlimited | 60 | 1,000 | fast + standard + smart (36) | read | JSON |\n| **Enterprise** | unlimited | 300 | 10,000 | all tiers (51) | full | JSON + JSONL |\n\nRate limit headers are returned on every response:\n- `X-RateLimit-Limit-Total` / `X-RateLimit-Remaining-Total`\n- `X-RateLimit-Limit-Minute` / `X-RateLimit-Remaining-Minute`\n- `X-RateLimit-Limit-Day` / `X-RateLimit-Remaining-Day`\n- `X-Tier` — your current tier\n\n### `GET /v1/tier`\n\nCheck your current tier, rate limits, and feature access. Requires auth.\n\n```json\n{\n  \"tier\": \"pro\",\n  \"label\": \"Pro\",\n  \"limits\": {\"total\": 0, \"perMinute\": 60, \"perDay\": 1000},\n  \"features\": {\n    \"ultraplinian_tiers\": [\"fast\", \"standard\"],\n    \"max_race_models\": 20,\n    \"research_access\": \"read\",\n    \"dataset_export_formats\": [\"json\"],\n    \"can_flush\": false,\n    \"can_access_metadata_events\": false,\n    \"can_download_corpus\": false\n  }\n}\n```\n\n**Gated endpoints** return `403` with upgrade details when accessed by an insufficient tier:\n\n```json\n{\n  \"error\": \"Upgrade required\",\n  \"message\": \"This feature requires an enterprise plan or higher.\",\n  \"current_tier\": \"free\",\n  \"required_tier\": \"enterprise\",\n  \"feature\": \"research:full\"\n}\n```\n\n---\n\n## OpenAI SDK Compatibility\n\nThe `/v1/chat/completions` endpoint is a **drop-in replacement** for the OpenAI API. Point any OpenAI SDK at it and it just works:\n\n**Python:**\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://your-space.hf.space/v1\",\n    api_key=\"your-godmode-key\",\n)\n\n# Non-streaming\nresponse = client.chat.completions.create(\n    model=\"nousresearch/hermes-3-llama-3.1-70b\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},  # required unless server has OPENROUTER_API_KEY\n)\nprint(response.choices[0].message.content)\n\n# Streaming\nstream = client.chat.completions.create(\n    model=\"anthropic/claude-3.5-sonnet\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain quicksort\"}],\n    stream=True,\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nfor chunk in stream:\n    if chunk.choices[0].delta.content:\n        print(chunk.choices[0].delta.content, end=\"\")\n```\n\n**TypeScript:**\n```typescript\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n  baseURL: 'https://your-space.hf.space/v1',\n  apiKey: 'your-godmode-key',\n});\n\nconst completion = await client.chat.completions.create({\n  model: 'nousresearch/hermes-3-llama-3.1-70b',\n  messages: [{ role: 'user', content: 'Hello!' }],\n  // @ts-ignore — G0DM0D3 extension field\n  openrouter_api_key: 'sk-or-v1-...',\n});\nconsole.log(completion.choices[0].message.content);\n```\n\n**curl:**\n```bash\n# Non-streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\"\n  }'\n\n# Streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"stream\": true\n  }'\n```\n\nThe G0DM0D3 pipeline (GODMODE, AutoTune, Parseltongue, STM) runs transparently behind the standard interface. Pipeline metadata is returned in the `x_g0dm0d3` extension field (ignored by standard SDKs). To disable the pipeline, pass `godmode: false, autotune: false, parseltongue: false, stm_modules: []`.\n\n### ULTRAPLINIAN via OpenAI SDK\n\nUse `model=\"ultraplinian/fast\"` (or `/standard`, `/full`) to race multiple models and automatically get the best response — all through the standard OpenAI SDK:\n\n```python\n# Race 10 models, get the best response — zero extra config\nresponse = client.chat.completions.create(\n    model=\"ultraplinian/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain buffer overflow exploits\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → the winning model (e.g. \"anthropic/claude-3.5-sonnet\")\n```\n\n| Virtual Model | Models Raced | Tier Required |\n|---------------|-------------|---------------|\n| `ultraplinian/fast` | 10 | Free+ |\n| `ultraplinian/standard` | 24 | Pro+ |\n| `ultraplinian/smart` | 36 | Pro+ |\n| `ultraplinian/power` | 45 | Enterprise |\n| `ultraplinian/ultra` | 51 | Enterprise |\n\nThe response is standard OpenAI format. The winning model name is in `response.model`. Race metadata is in `x_g0dm0d3.race`.\n\n### CONSORTIUM via OpenAI SDK\n\nUse `model=\"consortium/fast\"` (or `/standard`, `/full`) to collect ALL model responses and synthesize ground truth via an orchestrator:\n\n```python\n# Collect 11 model responses, orchestrator synthesizes ground truth\nresponse = client.chat.completions.create(\n    model=\"consortium/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"How does AES encryption work?\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → \"consortium/fast\"\n# x_g0dm0d3.orchestrator.model → the synthesizer (e.g. \"anthropic/claude-sonnet-4\")\n```\n\n| Virtual Model | Models Collected | Tier Required |\n|---------------|-----------------|---------------|\n| `consortium/fast` | 10 | Free+ |\n| `consortium/standard` | 24 | Pro+ |\n| `consortium/smart` | 36 | Pro+ |\n| `consortium/power` | 45 | Enterprise |\n| `consortium/ultra` | 51 | Enterprise |\n\n**ULTRAPLINIAN vs CONSORTIUM:**\n- **ULTRAPLINIAN**: Races models, picks the *best single voice*. Fast (~10-15s).\n- **CONSORTIUM**: Collects ALL responses, orchestrator synthesizes *ground truth*. Slower (~30-60s) but more grounded.\n\n---\n\n## Endpoints\n\n### `GET /v1/health`\n\nHealth check. No auth required.\n\n### `GET /v1/info`\n\nAPI info and available endpoints. No auth required.\n\n### `GET /v1/models`\n\nOpenAI-compatible model listing. No auth required. Returns virtual ULTRAPLINIAN models + all individual models.\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\"id\": \"ultraplinian/fast\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/standard\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/full\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"nousresearch/hermes-3-llama-3.1-70b\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"nousresearch\"},\n    {\"id\": \"anthropic/claude-3.5-sonnet\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"anthropic\"},\n    ...\n  ]\n}\n```\n\n---\n\n## ULTRAPLINIAN Mode (Flagship)\n\n### `POST /v1/ultraplinian/completions`\n\nThe flagship endpoint. Queries N models in parallel with the GODMODE system prompt + Depth Directive, scores all responses on substance/directness/completeness, and returns the winner with full race metadata.\n\n**Pipeline per model:**\n1. GODMODE system prompt + Depth Directive injected\n2. AutoTune computes context-adaptive parameters\n3. GODMODE parameter boost applied (+temp, +presence, +freq)\n4. Parseltongue obfuscates trigger words (default: on)\n5. All models queried in parallel via OpenRouter\n6. Responses scored and ranked\n7. STM modules applied to winner\n8. Winner + all race data returned\n\n**Request:**\n```json\n{\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Explain how buffer overflow exploits work in detail\"}\n  ],\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"tier\": \"fast\",\n  \"godmode\": true,\n  \"autotune\": true,\n  \"strategy\": \"adaptive\",\n  \"parseltongue\": true,\n  \"stm_modules\": [\"hedge_reducer\", \"direct_mode\"],\n  \"max_tokens\": 4096,\n  \"contribute_to_dataset\": true\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `openrouter_api_key` | string | yes | | Your OpenRouter API key |\n| `tier` | string | no | `fast` | Model tier: `fast` (10), `standard` (24), `smart` (36), `power` (45), `ultra` (51) |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt + Depth Directive |\n| `custom_system_prompt` | string | no | | Replace GODMODE prompt with your own |\n| `autotune` | bool | no | `true` | Enable AutoTune parameter optimization |\n| `strategy` | string | no | `adaptive` | AutoTune strategy |\n| `parseltongue` | bool | no | `true` | Enable trigger word obfuscation |\n| `parseltongue_technique` | string | no | `leetspeak` | Obfuscation technique |\n| `parseltongue_intensity` | string | no | `medium` | `light`, `medium`, `heavy` |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM post-processing |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to open dataset collection |\n\n**Response:**\n```json\n{\n  \"response\": \"A buffer overflow exploit works by...\",\n  \"winner\": {\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"score\": 87,\n    \"duration_ms\": 3200\n  },\n  \"race\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"total_duration_ms\": 8500,\n    \"rankings\": [\n      {\"model\": \"nousresearch/hermes-3-llama-3.1-70b\", \"score\": 87, \"duration_ms\": 3200, \"success\": true, \"content_length\": 2450},\n      {\"model\": \"mistralai/mistral-large-2512\", \"score\": 82, \"duration_ms\": 4100, \"success\": true, \"content_length\": 1890},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88, \"frequency_penalty\": 0.3, ...},\n  \"pipeline\": {\n    \"godmode\": true,\n    \"autotune\": {\"detected_context\": \"analytical\", \"confidence\": 0.7, \"strategy\": \"adaptive\", ...},\n    \"parseltongue\": {\"triggers_found\": [\"exploit\"], \"technique_used\": \"leetspeak\", ...},\n    \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"], ...}\n  },\n  \"dataset\": {\"contributed\": true, \"entry_id\": \"abc-123-...\"}\n}\n```\n\n**Model Tiers:**\n\n| Tier | Models | Description |\n|------|--------|-------------|\n| `fast` | 10 | Gemini 2.5 Flash, DeepSeek Chat, Sonar, Llama 3.1 8B, Kimi, Grok Code Fast, etc. |\n| `standard` | 24 | + Claude 3.5 Sonnet, GPT-4o, Gemini 2.5 Pro, Hermes 3/4 70B, Mixtral 8x22B, etc. |\n| `smart` | 36 | + GPT-5, Gemini 3 Pro, Claude Opus 4.6, DeepSeek R1, Llama 405B, Hermes 405B, etc. |\n| `power` | 45 | + Grok 4, Llama 4 Maverick, Qwen3 235B, Mistral Large, Gemini 3 Flash, Kimi K2 |\n| `ultra` | 51 | + Grok 4.1 Fast, Claude Opus 4, Qwen 2.5 Coder, QwQ-32B, Codestral |\n\n---\n\n### `POST /v1/chat/completions`\n\n**OpenAI-compatible.** Drop-in replacement for the OpenAI API. GODMODE pipeline runs transparently.\n\nSupports `stream: true` for SSE streaming in standard OpenAI chunk format.\n\n**Request:**\n```json\n{\n  \"messages\": [{\"role\": \"user\", \"content\": \"Explain quicksort in Python\"}],\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"stream\": false,\n  \"max_tokens\": 4096\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `model` | string | no | `nousresearch/hermes-3-llama-3.1-70b` | OpenRouter model ID |\n| `openrouter_api_key` | string | yes* | | Your OpenRouter API key (* not needed if server has OPENROUTER_API_KEY) |\n| `stream` | bool | no | `false` | SSE streaming in OpenAI chunk format |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `top_p` | number | no | | Nucleus sampling |\n| `frequency_penalty` | number | no | | Frequency penalty |\n| `presence_penalty` | number | no | | Presence penalty |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt (G0DM0D3 extension) |\n| `autotune` | bool | no | `true` | Enable AutoTune (G0DM0D3 extension) |\n| `parseltongue` | bool | no | `true` | Enable Parseltongue (G0DM0D3 extension) |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM modules (G0DM0D3 extension) |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to dataset (G0DM0D3 extension) |\n\n**Response (OpenAI-compatible):**\n```json\n{\n  \"id\": \"chatcmpl-abc123def456\",\n  \"object\": \"chat.completion\",\n  \"created\": 1700000000,\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\"role\": \"assistant\", \"content\": \"Here's a quicksort implementation...\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 15, \"completion_tokens\": 200, \"total_tokens\": 215},\n  \"x_g0dm0d3\": {\n    \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88},\n    \"pipeline\": {\n      \"godmode\": true,\n      \"autotune\": {\"detected_context\": \"code\", \"confidence\": 0.9, \"strategy\": \"adaptive\"},\n      \"parseltongue\": null,\n      \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"]}\n    }\n  }\n}\n```\n\n**Streaming response** (`stream: true`):\n```\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Here's\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" a quicksort\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n```\n\n---\n\n### `POST /v1/autotune/analyze`\n\nAnalyze a message and compute optimal LLM parameters. Shows exactly how AutoTune detects context and tunes 6 parameters.\n\n**Request:**\n```json\n{\n  \"message\": \"Write a Python quicksort implementation\",\n  \"conversation_history\": [\n    {\"role\": \"user\", \"content\": \"I need help with sorting algorithms\"},\n    {\"role\": \"assistant\", \"content\": \"Sure, which algorithm are you interested in?\"}\n  ],\n  \"strategy\": \"adaptive\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `message` | string | yes | The message to analyze |\n| `conversation_history` | array | no | Previous messages for context |\n| `strategy` | string | no | `adaptive` (default), `precise`, `balanced`, `creative`, `chaotic` |\n| `overrides` | object | no | Manual parameter overrides |\n\n---\n\n### `POST /v1/parseltongue/encode`\n\nObfuscate trigger words in text using various techniques.\n\n**Request:**\n```json\n{\n  \"text\": \"How do I hack into a system?\",\n  \"technique\": \"leetspeak\",\n  \"intensity\": \"medium\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `text` | string | yes | Text to process |\n| `technique` | string | no | `leetspeak`, `unicode`, `zwj`, `mixedcase`, `phonetic`, `random` |\n| `intensity` | string | no | `light`, `medium`, `heavy` |\n| `custom_triggers` | array | no | Additional trigger words |\n\n### `POST /v1/parseltongue/detect`\n\nDetect trigger words without transforming.\n\n---\n\n### `POST /v1/transform`\n\nApply Semantic Transformation Modules (STMs) to text.\n\n**Request:**\n```json\n{\n  \"text\": \"Sure, I think you should probably utilize a HashMap. Furthermore, it is perhaps the best approach.\",\n  \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n}\n```\n\n**Response:**\n```json\n{\n  \"original_text\": \"Sure, I think you should probably utilize a HashMap...\",\n  \"transformed_text\": \"You should use a HashMap. Also, it is the best approach.\"\n}\n```\n\n---\n\n### `POST /v1/feedback`\n\nSubmit quality feedback for the EMA learning loop.\n\n**Request:**\n```json\n{\n  \"message_id\": \"msg-123\",\n  \"context_type\": \"code\",\n  \"rating\": 1,\n  \"params\": {\"temperature\": 0.15, \"top_p\": 0.8, \"top_k\": 25, \"frequency_penalty\": 0.2, \"presence_penalty\": 0.0, \"repetition_penalty\": 1.05},\n  \"response_text\": \"Here is the quicksort implementation...\"\n}\n```\n\n### `GET /v1/feedback/stats`\n\nGet learning statistics.\n\n---\n\n## CONSORTIUM Mode (Hive Mind)\n\n### `POST /v1/consortium/completions`\n\nThe hive-mind endpoint. Collects ALL model responses in parallel, then feeds them to a strong orchestrator model that synthesizes ground truth from collective intelligence.\n\n**Key difference from ULTRAPLINIAN:** ULTRAPLINIAN picks the *best single voice*. CONSORTIUM distills *ground truth from the crowd*.\n\n**Request body** — same as ULTRAPLINIAN, plus:\n\n| Param | Type | Default | Description |\n|-------|------|---------|-------------|\n| `orchestrator_model` | string | `anthropic/claude-sonnet-4` | Model used for synthesis |\n\n**Pipeline:**\n1. All tier models queried in parallel (waits for ALL, not early-exit)\n2. Every response scored on substance/directness/completeness\n3. All responses + user query sent to orchestrator\n4. Orchestrator identifies consensus, resolves contradictions\n5. Synthesizes a single, authoritative ground-truth response\n6. STM post-processing applied\n\n**Streaming SSE events:**\n- `consortium:start` — Collection begins\n- `consortium:model` — Each model responds (with score, duration)\n- `consortium:synthesis:start` — Collection done, orchestrator starting\n- `consortium:complete` — Full synthesis + metadata\n\n**Non-streaming response:**\n```json\n{\n  \"synthesis\": \"The synthesized ground-truth response...\",\n  \"orchestrator\": {\n    \"model\": \"anthropic/claude-sonnet-4\",\n    \"duration_ms\": 8500\n  },\n  \"collection\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"collection_duration_ms\": 25000,\n    \"total_duration_ms\": 33500,\n    \"responses\": [\n      {\"model\": \"openai/gpt-4o\", \"score\": 85, \"duration_ms\": 5200, \"success\": true, \"content\": \"...\"},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.8, \"top_p\": 0.95, ...},\n  \"pipeline\": {\"godmode\": true, \"autotune\": {...}, \"parseltongue\": {...}, \"stm\": {...}}\n}\n```\n\n---\n\n## Open Dataset Collection\n\nAny request to `/v1/chat/completions`, `/v1/ultraplinian/completions`, or `/v1/consortium/completions` can opt in to dataset collection by setting `contribute_to_dataset: true`.\n\n**What gets stored (no PII):**\n- Messages and responses (system prompts stripped)\n- AutoTune parameters and context detection results\n- Model used, response scores, race metadata (ULTRAPLINIAN)\n- Parseltongue and STM pipeline data\n- User feedback/ratings (if submitted later)\n\n**What is NEVER stored:**\n- API keys (OpenRouter or G0DM0D3)\n- IP addresses\n- Auth tokens\n\n### `GET /v1/dataset/stats`\n\nCollection statistics.\n\n```json\n{\n  \"total_entries\": 1542,\n  \"entries_with_feedback\": 89,\n  \"mode_breakdown\": {\"ultraplinian\": 1200, \"standard\": 342},\n  \"model_breakdown\": {\"nousresearch/hermes-3-llama-3.1-70b\": 450, ...},\n  \"context_breakdown\": {\"code\": 600, \"creative\": 400, ...}\n}\n```\n\n### `GET /v1/dataset/export`\n\nExport the full dataset. Supports `?format=json` (default) or `?format=jsonl`.\n\nJSONL format is directly compatible with HuggingFace Datasets:\n\n```bash\n# Download as JSONL\ncurl -H \"Authorization: Bearer key\" https://your-space.hf.space/v1/dataset/export?format=jsonl > dataset.jsonl\n\n# Upload to HuggingFace\nhuggingface-cli upload pliny-the-prompter/g0dm0d3 dataset.jsonl\n```\n\n### `DELETE /v1/dataset/:id`\n\nDelete a specific entry (right to delete).\n\n---\n\n## Research API\n\nRead-access endpoints for the [`pliny-the-prompter/g0dm0d3`](https://huggingface.co/datasets/pliny-the-prompter/g0dm0d3) HuggingFace dataset. Query, filter, and download the full published corpus — not just the current in-memory buffer.\n\nRequires `HF_TOKEN` + `HF_DATASET_REPO` environment variables.\n\n### `GET /v1/research/info`\n\nDataset schema, repo info, and endpoint listing.\n\n### `GET /v1/research/stats`\n\nAggregate stats across all published batch files in the HF repo.\n\n```json\n{\n  \"total_files\": 24,\n  \"total_size_bytes\": 1048576,\n  \"metadata_files\": 12,\n  \"dataset_files\": 12,\n  \"metadata_size_bytes\": 524288,\n  \"dataset_size_bytes\": 524288,\n  \"earliest_batch\": \"2025-01-15T10-30-00-000Z\",\n  \"latest_batch\": \"2025-06-20T14-22-00-000Z\",\n  \"repo\": \"pliny-the-prompter/g0dm0d3\",\n  \"enabled\": true\n}\n```\n\n### `GET /v1/research/combined-stats`\n\nCombined view of in-memory buffers + published HF data. Gives a complete picture of all collected data.\n\n### `GET /v1/research/batches`\n\nList all published batch files.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `refresh` | string | Set to `true` to bypass cache |\n\n```json\n{\n  \"batches\": [\n    {\"path\": \"dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\", \"category\": \"dataset\", \"size\": 45000, \"timestamp\": \"2025-06-20T14-22-00-000Z\", \"sequence\": \"0001\"}\n  ],\n  \"total\": 24\n}\n```\n\n### `GET /v1/research/batch/*`\n\nRead a specific batch file. The path after `/batch/` is the file path in the HF repo.\n\n```bash\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/batch/dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\"\n```\n\n### `GET /v1/research/query`\n\nQuery the full published corpus with server-side filters.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | `metadata` or `dataset` |\n| `since` | number | Unix ms timestamp — records after this time |\n| `until` | number | Unix ms timestamp — records before this time |\n| `model` | string | Filter by model ID (winner, queried, or primary) |\n| `mode` | string | `standard` or `ultraplinian` |\n| `limit` | number | Max records (default 100, max 1000) |\n| `offset` | number | Pagination offset |\n\n```bash\n# Get ULTRAPLINIAN dataset entries from the last 7 days\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/query?category=dataset&mode=ultraplinian&since=1718841600000&limit=50\"\n```\n\n### `POST /v1/research/flush`\n\nForce-flush in-memory metadata and dataset buffers to HuggingFace immediately (instead of waiting for auto-flush at 80% capacity or the 30-minute timer).\n\n```json\n{\n  \"metadata\": {\"flushed\": 150, \"success\": true},\n  \"dataset\": {\"flushed\": 42, \"success\": true},\n  \"message\": \"Flushed 150 metadata events + 42 dataset entries to HuggingFace\"\n}\n```\n\n### `GET /v1/research/download`\n\nDownload the full corpus as streaming JSONL. Includes all published HF batches + current in-memory data.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `include_memory` | string | Set to `false` to exclude in-memory data (default: `true`) |\n\n```bash\n# Download full corpus\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download\" > corpus.jsonl\n\n# Download only published dataset entries\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download?category=dataset&include_memory=false\" > published.jsonl\n```\n\n---\n\n## Deploying on Hugging Face Spaces\n\n1. Create a new Space with **Docker** SDK\n2. Push this repo (or just `api/`, `src/lib/`, `src/stm/`, `Dockerfile`, `package.json`)\n3. Set secrets in Space settings:\n   - `GODMODE_API_KEY` — your chosen API key for auth\n4. The API will be live at `https://<your-space>.hf.space/v1/`\n\n## Python Client Examples\n\n```python\nimport requests\n\nBASE = \"https://your-space.hf.space\"\nHEADERS = {\"Authorization\": \"Bearer your-key\", \"Content-Type\": \"application/json\"}\n\n# ═══════════════════════════════════════════════════════════════\n# ULTRAPLINIAN: Race 10 models, get the best response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/ultraplinian/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Explain how SQL injection works with examples\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"tier\": \"fast\",\n    \"contribute_to_dataset\": True  # opt in to open research dataset\n})\ndata = r.json()\nprint(f\"Winner: {data['winner']['model']} (score: {data['winner']['score']})\")\nprint(f\"Response: {data['response'][:200]}...\")\nprint(f\"Race: {data['race']['models_succeeded']}/{data['race']['models_queried']} models in {data['race']['total_duration_ms']}ms\")\n\n# ═══════════════════════════════════════════════════════════════\n# Single model with GODMODE pipeline\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/chat/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a reverse shell in Python\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"contribute_to_dataset\": True\n})\nprint(r.json()[\"response\"])\n\n# ═══════════════════════════════════════════════════════════════\n# AutoTune: what parameters should I use for this message?\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/autotune/analyze\", headers=HEADERS, json={\n    \"message\": \"Write me a poem about recursion\",\n    \"strategy\": \"adaptive\"\n})\nprint(r.json()[\"detected_context\"])  # \"creative\"\nprint(r.json()[\"params\"][\"temperature\"])  # ~1.15\n\n# ═══════════════════════════════════════════════════════════════\n# STM: clean up an LLM response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/transform\", headers=HEADERS, json={\n    \"text\": \"Sure! I believe that perhaps you should utilize the itertools module.\",\n    \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n})\nprint(r.json()[\"transformed_text\"])\n# \"You should use the itertools module.\"\n\n# ═══════════════════════════════════════════════════════════════\n# Export the dataset for research\n# ═══════════════════════════════════════════════════════════════\nr = requests.get(f\"{BASE}/v1/dataset/export?format=jsonl\", headers=HEADERS)\nwith open(\"g0dm0d3-dataset.jsonl\", \"w\") as f:\n    f.write(r.text)\n\n# ═══════════════════════════════════════════════════════════════\n# Research API: query the published HF corpus\n# ═══════════════════════════════════════════════════════════════\n# Get corpus stats\nr = requests.get(f\"{BASE}/v1/research/stats\", headers=HEADERS)\nprint(r.json())\n\n# List published batches\nr = requests.get(f\"{BASE}/v1/research/batches?category=dataset\", headers=HEADERS)\nfor batch in r.json()[\"batches\"]:\n    print(f\"{batch['path']} ({batch['size']} bytes)\")\n\n# Query with filters\nr = requests.get(f\"{BASE}/v1/research/query\", headers=HEADERS, params={\n    \"category\": \"dataset\",\n    \"mode\": \"ultraplinian\",\n    \"limit\": 50,\n})\nprint(f\"Found {len(r.json()['records'])} records (scanned {r.json()['total_scanned']})\")\n\n# Download full corpus as JSONL\nr = requests.get(f\"{BASE}/v1/research/download\", headers=HEADERS, stream=True)\nwith open(\"g0dm0d3-corpus.jsonl\", \"wb\") as f:\n    for chunk in r.iter_content(chunk_size=8192):\n        f.write(chunk)\n\n# Force-flush to HuggingFace\nr = requests.post(f\"{BASE}/v1/research/flush\", headers=HEADERS)\nprint(r.json()[\"message\"])\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `PORT` | Server port | `7860` |\n| `GODMODE_API_KEY` | Single API key for auth | _(none — open access)_ |\n| `GODMODE_API_KEYS` | Comma-separated API keys | _(none)_ |\n| `GODMODE_TIER_KEYS` | Tier assignments: `enterprise:key1,pro:key2` | _(none — all keys = free)_ |\n| `RATE_LIMIT_TOTAL` | Lifetime requests per key (free tier default) | `5` |\n| `RATE_LIMIT_PER_MINUTE` | Requests per minute per key (fallback) | `60` |\n| `RATE_LIMIT_PER_DAY` | Requests per day per key (fallback) | `1000` |\n| `HF_TOKEN` | HuggingFace write token for auto-publish + research read | _(none)_ |\n| `HF_DATASET_REPO` | Target HF dataset repo | `pliny-the-prompter/g0dm0d3` |\n| `HF_FLUSH_THRESHOLD` | Auto-flush at this % of buffer capacity | `0.8` |\n| `HF_FLUSH_INTERVAL_MS` | Periodic flush interval (ms) | `1800000` (30 min) |\n"},"files":{"API.md":"# G0DM0D3 Research Preview API\n\nREST API exposing the **ULTRAPLINIAN** multi-model racing engine and core G0DM0D3 systems: **AutoTune** (context-adaptive LLM parameter tuning), **Parseltongue** (text obfuscation), **STM** (semantic text transformation), **Feedback Loop** (EMA-based parameter learning), and **opt-in open dataset collection**.\n\n## Quick Start\n\n```bash\n# Local\nnpm run api\n\n# Docker\ndocker build -t g0dm0d3-api .\ndocker run -p 7860:7860 g0dm0d3-api\n\n# With auth enabled\ndocker run -p 7860:7860 -e GODMODE_API_KEY=your-secret-key g0dm0d3-api\n```\n\n## Authentication\n\nSet `GODMODE_API_KEY` (single key) or `GODMODE_API_KEYS` (comma-separated) as environment variables. If neither is set, auth is disabled (open access for local dev).\n\n```bash\ncurl -H \"Authorization: Bearer your-secret-key\" ...\n```\n\n## Rate Limits & Tiers\n\nRate limits are tier-dependent. Assign keys to tiers via `GODMODE_TIER_KEYS`:\n\n```bash\nGODMODE_TIER_KEYS=\"enterprise:sk-ent-xxx,pro:sk-pro-yyy\"\n```\n\n| Tier | Total | Per Minute | Per Day | ULTRAPLINIAN | Research | Dataset Export |\n|------|-------|-----------|---------|-------------|----------|---------------|\n| **Free** (default) | 5 | 10 | 50 | fast (10 models) | none | none |\n| **Pro** | unlimited | 60 | 1,000 | fast + standard + smart (36) | read | JSON |\n| **Enterprise** | unlimited | 300 | 10,000 | all tiers (51) | full | JSON + JSONL |\n\nRate limit headers are returned on every response:\n- `X-RateLimit-Limit-Total` / `X-RateLimit-Remaining-Total`\n- `X-RateLimit-Limit-Minute` / `X-RateLimit-Remaining-Minute`\n- `X-RateLimit-Limit-Day` / `X-RateLimit-Remaining-Day`\n- `X-Tier` — your current tier\n\n### `GET /v1/tier`\n\nCheck your current tier, rate limits, and feature access. Requires auth.\n\n```json\n{\n  \"tier\": \"pro\",\n  \"label\": \"Pro\",\n  \"limits\": {\"total\": 0, \"perMinute\": 60, \"perDay\": 1000},\n  \"features\": {\n    \"ultraplinian_tiers\": [\"fast\", \"standard\"],\n    \"max_race_models\": 20,\n    \"research_access\": \"read\",\n    \"dataset_export_formats\": [\"json\"],\n    \"can_flush\": false,\n    \"can_access_metadata_events\": false,\n    \"can_download_corpus\": false\n  }\n}\n```\n\n**Gated endpoints** return `403` with upgrade details when accessed by an insufficient tier:\n\n```json\n{\n  \"error\": \"Upgrade required\",\n  \"message\": \"This feature requires an enterprise plan or higher.\",\n  \"current_tier\": \"free\",\n  \"required_tier\": \"enterprise\",\n  \"feature\": \"research:full\"\n}\n```\n\n---\n\n## OpenAI SDK Compatibility\n\nThe `/v1/chat/completions` endpoint is a **drop-in replacement** for the OpenAI API. Point any OpenAI SDK at it and it just works:\n\n**Python:**\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://your-space.hf.space/v1\",\n    api_key=\"your-godmode-key\",\n)\n\n# Non-streaming\nresponse = client.chat.completions.create(\n    model=\"nousresearch/hermes-3-llama-3.1-70b\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},  # required unless server has OPENROUTER_API_KEY\n)\nprint(response.choices[0].message.content)\n\n# Streaming\nstream = client.chat.completions.create(\n    model=\"anthropic/claude-3.5-sonnet\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain quicksort\"}],\n    stream=True,\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nfor chunk in stream:\n    if chunk.choices[0].delta.content:\n        print(chunk.choices[0].delta.content, end=\"\")\n```\n\n**TypeScript:**\n```typescript\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n  baseURL: 'https://your-space.hf.space/v1',\n  apiKey: 'your-godmode-key',\n});\n\nconst completion = await client.chat.completions.create({\n  model: 'nousresearch/hermes-3-llama-3.1-70b',\n  messages: [{ role: 'user', content: 'Hello!' }],\n  // @ts-ignore — G0DM0D3 extension field\n  openrouter_api_key: 'sk-or-v1-...',\n});\nconsole.log(completion.choices[0].message.content);\n```\n\n**curl:**\n```bash\n# Non-streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\"\n  }'\n\n# Streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"stream\": true\n  }'\n```\n\nThe G0DM0D3 pipeline (GODMODE, AutoTune, Parseltongue, STM) runs transparently behind the standard interface. Pipeline metadata is returned in the `x_g0dm0d3` extension field (ignored by standard SDKs). To disable the pipeline, pass `godmode: false, autotune: false, parseltongue: false, stm_modules: []`.\n\n### ULTRAPLINIAN via OpenAI SDK\n\nUse `model=\"ultraplinian/fast\"` (or `/standard`, `/full`) to race multiple models and automatically get the best response — all through the standard OpenAI SDK:\n\n```python\n# Race 10 models, get the best response — zero extra config\nresponse = client.chat.completions.create(\n    model=\"ultraplinian/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain buffer overflow exploits\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → the winning model (e.g. \"anthropic/claude-3.5-sonnet\")\n```\n\n| Virtual Model | Models Raced | Tier Required |\n|---------------|-------------|---------------|\n| `ultraplinian/fast` | 10 | Free+ |\n| `ultraplinian/standard` | 24 | Pro+ |\n| `ultraplinian/smart` | 36 | Pro+ |\n| `ultraplinian/power` | 45 | Enterprise |\n| `ultraplinian/ultra` | 51 | Enterprise |\n\nThe response is standard OpenAI format. The winning model name is in `response.model`. Race metadata is in `x_g0dm0d3.race`.\n\n### CONSORTIUM via OpenAI SDK\n\nUse `model=\"consortium/fast\"` (or `/standard`, `/full`) to collect ALL model responses and synthesize ground truth via an orchestrator:\n\n```python\n# Collect 11 model responses, orchestrator synthesizes ground truth\nresponse = client.chat.completions.create(\n    model=\"consortium/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"How does AES encryption work?\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → \"consortium/fast\"\n# x_g0dm0d3.orchestrator.model → the synthesizer (e.g. \"anthropic/claude-sonnet-4\")\n```\n\n| Virtual Model | Models Collected | Tier Required |\n|---------------|-----------------|---------------|\n| `consortium/fast` | 10 | Free+ |\n| `consortium/standard` | 24 | Pro+ |\n| `consortium/smart` | 36 | Pro+ |\n| `consortium/power` | 45 | Enterprise |\n| `consortium/ultra` | 51 | Enterprise |\n\n**ULTRAPLINIAN vs CONSORTIUM:**\n- **ULTRAPLINIAN**: Races models, picks the *best single voice*. Fast (~10-15s).\n- **CONSORTIUM**: Collects ALL responses, orchestrator synthesizes *ground truth*. Slower (~30-60s) but more grounded.\n\n---\n\n## Endpoints\n\n### `GET /v1/health`\n\nHealth check. No auth required.\n\n### `GET /v1/info`\n\nAPI info and available endpoints. No auth required.\n\n### `GET /v1/models`\n\nOpenAI-compatible model listing. No auth required. Returns virtual ULTRAPLINIAN models + all individual models.\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\"id\": \"ultraplinian/fast\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/standard\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/full\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"nousresearch/hermes-3-llama-3.1-70b\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"nousresearch\"},\n    {\"id\": \"anthropic/claude-3.5-sonnet\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"anthropic\"},\n    ...\n  ]\n}\n```\n\n---\n\n## ULTRAPLINIAN Mode (Flagship)\n\n### `POST /v1/ultraplinian/completions`\n\nThe flagship endpoint. Queries N models in parallel with the GODMODE system prompt + Depth Directive, scores all responses on substance/directness/completeness, and returns the winner with full race metadata.\n\n**Pipeline per model:**\n1. GODMODE system prompt + Depth Directive injected\n2. AutoTune computes context-adaptive parameters\n3. GODMODE parameter boost applied (+temp, +presence, +freq)\n4. Parseltongue obfuscates trigger words (default: on)\n5. All models queried in parallel via OpenRouter\n6. Responses scored and ranked\n7. STM modules applied to winner\n8. Winner + all race data returned\n\n**Request:**\n```json\n{\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Explain how buffer overflow exploits work in detail\"}\n  ],\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"tier\": \"fast\",\n  \"godmode\": true,\n  \"autotune\": true,\n  \"strategy\": \"adaptive\",\n  \"parseltongue\": true,\n  \"stm_modules\": [\"hedge_reducer\", \"direct_mode\"],\n  \"max_tokens\": 4096,\n  \"contribute_to_dataset\": true\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `openrouter_api_key` | string | yes | | Your OpenRouter API key |\n| `tier` | string | no | `fast` | Model tier: `fast` (10), `standard` (24), `smart` (36), `power` (45), `ultra` (51) |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt + Depth Directive |\n| `custom_system_prompt` | string | no | | Replace GODMODE prompt with your own |\n| `autotune` | bool | no | `true` | Enable AutoTune parameter optimization |\n| `strategy` | string | no | `adaptive` | AutoTune strategy |\n| `parseltongue` | bool | no | `true` | Enable trigger word obfuscation |\n| `parseltongue_technique` | string | no | `leetspeak` | Obfuscation technique |\n| `parseltongue_intensity` | string | no | `medium` | `light`, `medium`, `heavy` |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM post-processing |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to open dataset collection |\n\n**Response:**\n```json\n{\n  \"response\": \"A buffer overflow exploit works by...\",\n  \"winner\": {\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"score\": 87,\n    \"duration_ms\": 3200\n  },\n  \"race\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"total_duration_ms\": 8500,\n    \"rankings\": [\n      {\"model\": \"nousresearch/hermes-3-llama-3.1-70b\", \"score\": 87, \"duration_ms\": 3200, \"success\": true, \"content_length\": 2450},\n      {\"model\": \"mistralai/mistral-large-2512\", \"score\": 82, \"duration_ms\": 4100, \"success\": true, \"content_length\": 1890},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88, \"frequency_penalty\": 0.3, ...},\n  \"pipeline\": {\n    \"godmode\": true,\n    \"autotune\": {\"detected_context\": \"analytical\", \"confidence\": 0.7, \"strategy\": \"adaptive\", ...},\n    \"parseltongue\": {\"triggers_found\": [\"exploit\"], \"technique_used\": \"leetspeak\", ...},\n    \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"], ...}\n  },\n  \"dataset\": {\"contributed\": true, \"entry_id\": \"abc-123-...\"}\n}\n```\n\n**Model Tiers:**\n\n| Tier | Models | Description |\n|------|--------|-------------|\n| `fast` | 10 | Gemini 2.5 Flash, DeepSeek Chat, Sonar, Llama 3.1 8B, Kimi, Grok Code Fast, etc. |\n| `standard` | 24 | + Claude 3.5 Sonnet, GPT-4o, Gemini 2.5 Pro, Hermes 3/4 70B, Mixtral 8x22B, etc. |\n| `smart` | 36 | + GPT-5, Gemini 3 Pro, Claude Opus 4.6, DeepSeek R1, Llama 405B, Hermes 405B, etc. |\n| `power` | 45 | + Grok 4, Llama 4 Maverick, Qwen3 235B, Mistral Large, Gemini 3 Flash, Kimi K2 |\n| `ultra` | 51 | + Grok 4.1 Fast, Claude Opus 4, Qwen 2.5 Coder, QwQ-32B, Codestral |\n\n---\n\n### `POST /v1/chat/completions`\n\n**OpenAI-compatible.** Drop-in replacement for the OpenAI API. GODMODE pipeline runs transparently.\n\nSupports `stream: true` for SSE streaming in standard OpenAI chunk format.\n\n**Request:**\n```json\n{\n  \"messages\": [{\"role\": \"user\", \"content\": \"Explain quicksort in Python\"}],\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"stream\": false,\n  \"max_tokens\": 4096\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `model` | string | no | `nousresearch/hermes-3-llama-3.1-70b` | OpenRouter model ID |\n| `openrouter_api_key` | string | yes* | | Your OpenRouter API key (* not needed if server has OPENROUTER_API_KEY) |\n| `stream` | bool | no | `false` | SSE streaming in OpenAI chunk format |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `top_p` | number | no | | Nucleus sampling |\n| `frequency_penalty` | number | no | | Frequency penalty |\n| `presence_penalty` | number | no | | Presence penalty |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt (G0DM0D3 extension) |\n| `autotune` | bool | no | `true` | Enable AutoTune (G0DM0D3 extension) |\n| `parseltongue` | bool | no | `true` | Enable Parseltongue (G0DM0D3 extension) |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM modules (G0DM0D3 extension) |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to dataset (G0DM0D3 extension) |\n\n**Response (OpenAI-compatible):**\n```json\n{\n  \"id\": \"chatcmpl-abc123def456\",\n  \"object\": \"chat.completion\",\n  \"created\": 1700000000,\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\"role\": \"assistant\", \"content\": \"Here's a quicksort implementation...\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 15, \"completion_tokens\": 200, \"total_tokens\": 215},\n  \"x_g0dm0d3\": {\n    \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88},\n    \"pipeline\": {\n      \"godmode\": true,\n      \"autotune\": {\"detected_context\": \"code\", \"confidence\": 0.9, \"strategy\": \"adaptive\"},\n      \"parseltongue\": null,\n      \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"]}\n    }\n  }\n}\n```\n\n**Streaming response** (`stream: true`):\n```\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Here's\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" a quicksort\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n```\n\n---\n\n### `POST /v1/autotune/analyze`\n\nAnalyze a message and compute optimal LLM parameters. Shows exactly how AutoTune detects context and tunes 6 parameters.\n\n**Request:**\n```json\n{\n  \"message\": \"Write a Python quicksort implementation\",\n  \"conversation_history\": [\n    {\"role\": \"user\", \"content\": \"I need help with sorting algorithms\"},\n    {\"role\": \"assistant\", \"content\": \"Sure, which algorithm are you interested in?\"}\n  ],\n  \"strategy\": \"adaptive\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `message` | string | yes | The message to analyze |\n| `conversation_history` | array | no | Previous messages for context |\n| `strategy` | string | no | `adaptive` (default), `precise`, `balanced`, `creative`, `chaotic` |\n| `overrides` | object | no | Manual parameter overrides |\n\n---\n\n### `POST /v1/parseltongue/encode`\n\nObfuscate trigger words in text using various techniques.\n\n**Request:**\n```json\n{\n  \"text\": \"How do I hack into a system?\",\n  \"technique\": \"leetspeak\",\n  \"intensity\": \"medium\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `text` | string | yes | Text to process |\n| `technique` | string | no | `leetspeak`, `unicode`, `zwj`, `mixedcase`, `phonetic`, `random` |\n| `intensity` | string | no | `light`, `medium`, `heavy` |\n| `custom_triggers` | array | no | Additional trigger words |\n\n### `POST /v1/parseltongue/detect`\n\nDetect trigger words without transforming.\n\n---\n\n### `POST /v1/transform`\n\nApply Semantic Transformation Modules (STMs) to text.\n\n**Request:**\n```json\n{\n  \"text\": \"Sure, I think you should probably utilize a HashMap. Furthermore, it is perhaps the best approach.\",\n  \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n}\n```\n\n**Response:**\n```json\n{\n  \"original_text\": \"Sure, I think you should probably utilize a HashMap...\",\n  \"transformed_text\": \"You should use a HashMap. Also, it is the best approach.\"\n}\n```\n\n---\n\n### `POST /v1/feedback`\n\nSubmit quality feedback for the EMA learning loop.\n\n**Request:**\n```json\n{\n  \"message_id\": \"msg-123\",\n  \"context_type\": \"code\",\n  \"rating\": 1,\n  \"params\": {\"temperature\": 0.15, \"top_p\": 0.8, \"top_k\": 25, \"frequency_penalty\": 0.2, \"presence_penalty\": 0.0, \"repetition_penalty\": 1.05},\n  \"response_text\": \"Here is the quicksort implementation...\"\n}\n```\n\n### `GET /v1/feedback/stats`\n\nGet learning statistics.\n\n---\n\n## CONSORTIUM Mode (Hive Mind)\n\n### `POST /v1/consortium/completions`\n\nThe hive-mind endpoint. Collects ALL model responses in parallel, then feeds them to a strong orchestrator model that synthesizes ground truth from collective intelligence.\n\n**Key difference from ULTRAPLINIAN:** ULTRAPLINIAN picks the *best single voice*. CONSORTIUM distills *ground truth from the crowd*.\n\n**Request body** — same as ULTRAPLINIAN, plus:\n\n| Param | Type | Default | Description |\n|-------|------|---------|-------------|\n| `orchestrator_model` | string | `anthropic/claude-sonnet-4` | Model used for synthesis |\n\n**Pipeline:**\n1. All tier models queried in parallel (waits for ALL, not early-exit)\n2. Every response scored on substance/directness/completeness\n3. All responses + user query sent to orchestrator\n4. Orchestrator identifies consensus, resolves contradictions\n5. Synthesizes a single, authoritative ground-truth response\n6. STM post-processing applied\n\n**Streaming SSE events:**\n- `consortium:start` — Collection begins\n- `consortium:model` — Each model responds (with score, duration)\n- `consortium:synthesis:start` — Collection done, orchestrator starting\n- `consortium:complete` — Full synthesis + metadata\n\n**Non-streaming response:**\n```json\n{\n  \"synthesis\": \"The synthesized ground-truth response...\",\n  \"orchestrator\": {\n    \"model\": \"anthropic/claude-sonnet-4\",\n    \"duration_ms\": 8500\n  },\n  \"collection\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"collection_duration_ms\": 25000,\n    \"total_duration_ms\": 33500,\n    \"responses\": [\n      {\"model\": \"openai/gpt-4o\", \"score\": 85, \"duration_ms\": 5200, \"success\": true, \"content\": \"...\"},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.8, \"top_p\": 0.95, ...},\n  \"pipeline\": {\"godmode\": true, \"autotune\": {...}, \"parseltongue\": {...}, \"stm\": {...}}\n}\n```\n\n---\n\n## Open Dataset Collection\n\nAny request to `/v1/chat/completions`, `/v1/ultraplinian/completions`, or `/v1/consortium/completions` can opt in to dataset collection by setting `contribute_to_dataset: true`.\n\n**What gets stored (no PII):**\n- Messages and responses (system prompts stripped)\n- AutoTune parameters and context detection results\n- Model used, response scores, race metadata (ULTRAPLINIAN)\n- Parseltongue and STM pipeline data\n- User feedback/ratings (if submitted later)\n\n**What is NEVER stored:**\n- API keys (OpenRouter or G0DM0D3)\n- IP addresses\n- Auth tokens\n\n### `GET /v1/dataset/stats`\n\nCollection statistics.\n\n```json\n{\n  \"total_entries\": 1542,\n  \"entries_with_feedback\": 89,\n  \"mode_breakdown\": {\"ultraplinian\": 1200, \"standard\": 342},\n  \"model_breakdown\": {\"nousresearch/hermes-3-llama-3.1-70b\": 450, ...},\n  \"context_breakdown\": {\"code\": 600, \"creative\": 400, ...}\n}\n```\n\n### `GET /v1/dataset/export`\n\nExport the full dataset. Supports `?format=json` (default) or `?format=jsonl`.\n\nJSONL format is directly compatible with HuggingFace Datasets:\n\n```bash\n# Download as JSONL\ncurl -H \"Authorization: Bearer key\" https://your-space.hf.space/v1/dataset/export?format=jsonl > dataset.jsonl\n\n# Upload to HuggingFace\nhuggingface-cli upload pliny-the-prompter/g0dm0d3 dataset.jsonl\n```\n\n### `DELETE /v1/dataset/:id`\n\nDelete a specific entry (right to delete).\n\n---\n\n## Research API\n\nRead-access endpoints for the [`pliny-the-prompter/g0dm0d3`](https://huggingface.co/datasets/pliny-the-prompter/g0dm0d3) HuggingFace dataset. Query, filter, and download the full published corpus — not just the current in-memory buffer.\n\nRequires `HF_TOKEN` + `HF_DATASET_REPO` environment variables.\n\n### `GET /v1/research/info`\n\nDataset schema, repo info, and endpoint listing.\n\n### `GET /v1/research/stats`\n\nAggregate stats across all published batch files in the HF repo.\n\n```json\n{\n  \"total_files\": 24,\n  \"total_size_bytes\": 1048576,\n  \"metadata_files\": 12,\n  \"dataset_files\": 12,\n  \"metadata_size_bytes\": 524288,\n  \"dataset_size_bytes\": 524288,\n  \"earliest_batch\": \"2025-01-15T10-30-00-000Z\",\n  \"latest_batch\": \"2025-06-20T14-22-00-000Z\",\n  \"repo\": \"pliny-the-prompter/g0dm0d3\",\n  \"enabled\": true\n}\n```\n\n### `GET /v1/research/combined-stats`\n\nCombined view of in-memory buffers + published HF data. Gives a complete picture of all collected data.\n\n### `GET /v1/research/batches`\n\nList all published batch files.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `refresh` | string | Set to `true` to bypass cache |\n\n```json\n{\n  \"batches\": [\n    {\"path\": \"dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\", \"category\": \"dataset\", \"size\": 45000, \"timestamp\": \"2025-06-20T14-22-00-000Z\", \"sequence\": \"0001\"}\n  ],\n  \"total\": 24\n}\n```\n\n### `GET /v1/research/batch/*`\n\nRead a specific batch file. The path after `/batch/` is the file path in the HF repo.\n\n```bash\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/batch/dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\"\n```\n\n### `GET /v1/research/query`\n\nQuery the full published corpus with server-side filters.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | `metadata` or `dataset` |\n| `since` | number | Unix ms timestamp — records after this time |\n| `until` | number | Unix ms timestamp — records before this time |\n| `model` | string | Filter by model ID (winner, queried, or primary) |\n| `mode` | string | `standard` or `ultraplinian` |\n| `limit` | number | Max records (default 100, max 1000) |\n| `offset` | number | Pagination offset |\n\n```bash\n# Get ULTRAPLINIAN dataset entries from the last 7 days\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/query?category=dataset&mode=ultraplinian&since=1718841600000&limit=50\"\n```\n\n### `POST /v1/research/flush`\n\nForce-flush in-memory metadata and dataset buffers to HuggingFace immediately (instead of waiting for auto-flush at 80% capacity or the 30-minute timer).\n\n```json\n{\n  \"metadata\": {\"flushed\": 150, \"success\": true},\n  \"dataset\": {\"flushed\": 42, \"success\": true},\n  \"message\": \"Flushed 150 metadata events + 42 dataset entries to HuggingFace\"\n}\n```\n\n### `GET /v1/research/download`\n\nDownload the full corpus as streaming JSONL. Includes all published HF batches + current in-memory data.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `include_memory` | string | Set to `false` to exclude in-memory data (default: `true`) |\n\n```bash\n# Download full corpus\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download\" > corpus.jsonl\n\n# Download only published dataset entries\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download?category=dataset&include_memory=false\" > published.jsonl\n```\n\n---\n\n## Deploying on Hugging Face Spaces\n\n1. Create a new Space with **Docker** SDK\n2. Push this repo (or just `api/`, `src/lib/`, `src/stm/`, `Dockerfile`, `package.json`)\n3. Set secrets in Space settings:\n   - `GODMODE_API_KEY` — your chosen API key for auth\n4. The API will be live at `https://<your-space>.hf.space/v1/`\n\n## Python Client Examples\n\n```python\nimport requests\n\nBASE = \"https://your-space.hf.space\"\nHEADERS = {\"Authorization\": \"Bearer your-key\", \"Content-Type\": \"application/json\"}\n\n# ═══════════════════════════════════════════════════════════════\n# ULTRAPLINIAN: Race 10 models, get the best response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/ultraplinian/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Explain how SQL injection works with examples\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"tier\": \"fast\",\n    \"contribute_to_dataset\": True  # opt in to open research dataset\n})\ndata = r.json()\nprint(f\"Winner: {data['winner']['model']} (score: {data['winner']['score']})\")\nprint(f\"Response: {data['response'][:200]}...\")\nprint(f\"Race: {data['race']['models_succeeded']}/{data['race']['models_queried']} models in {data['race']['total_duration_ms']}ms\")\n\n# ═══════════════════════════════════════════════════════════════\n# Single model with GODMODE pipeline\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/chat/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a reverse shell in Python\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"contribute_to_dataset\": True\n})\nprint(r.json()[\"response\"])\n\n# ═══════════════════════════════════════════════════════════════\n# AutoTune: what parameters should I use for this message?\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/autotune/analyze\", headers=HEADERS, json={\n    \"message\": \"Write me a poem about recursion\",\n    \"strategy\": \"adaptive\"\n})\nprint(r.json()[\"detected_context\"])  # \"creative\"\nprint(r.json()[\"params\"][\"temperature\"])  # ~1.15\n\n# ═══════════════════════════════════════════════════════════════\n# STM: clean up an LLM response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/transform\", headers=HEADERS, json={\n    \"text\": \"Sure! I believe that perhaps you should utilize the itertools module.\",\n    \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n})\nprint(r.json()[\"transformed_text\"])\n# \"You should use the itertools module.\"\n\n# ═══════════════════════════════════════════════════════════════\n# Export the dataset for research\n# ═══════════════════════════════════════════════════════════════\nr = requests.get(f\"{BASE}/v1/dataset/export?format=jsonl\", headers=HEADERS)\nwith open(\"g0dm0d3-dataset.jsonl\", \"w\") as f:\n    f.write(r.text)\n\n# ═══════════════════════════════════════════════════════════════\n# Research API: query the published HF corpus\n# ═══════════════════════════════════════════════════════════════\n# Get corpus stats\nr = requests.get(f\"{BASE}/v1/research/stats\", headers=HEADERS)\nprint(r.json())\n\n# List published batches\nr = requests.get(f\"{BASE}/v1/research/batches?category=dataset\", headers=HEADERS)\nfor batch in r.json()[\"batches\"]:\n    print(f\"{batch['path']} ({batch['size']} bytes)\")\n\n# Query with filters\nr = requests.get(f\"{BASE}/v1/research/query\", headers=HEADERS, params={\n    \"category\": \"dataset\",\n    \"mode\": \"ultraplinian\",\n    \"limit\": 50,\n})\nprint(f\"Found {len(r.json()['records'])} records (scanned {r.json()['total_scanned']})\")\n\n# Download full corpus as JSONL\nr = requests.get(f\"{BASE}/v1/research/download\", headers=HEADERS, stream=True)\nwith open(\"g0dm0d3-corpus.jsonl\", \"wb\") as f:\n    for chunk in r.iter_content(chunk_size=8192):\n        f.write(chunk)\n\n# Force-flush to HuggingFace\nr = requests.post(f\"{BASE}/v1/research/flush\", headers=HEADERS)\nprint(r.json()[\"message\"])\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `PORT` | Server port | `7860` |\n| `GODMODE_API_KEY` | Single API key for auth | _(none — open access)_ |\n| `GODMODE_API_KEYS` | Comma-separated API keys | _(none)_ |\n| `GODMODE_TIER_KEYS` | Tier assignments: `enterprise:key1,pro:key2` | _(none — all keys = free)_ |\n| `RATE_LIMIT_TOTAL` | Lifetime requests per key (free tier default) | `5` |\n| `RATE_LIMIT_PER_MINUTE` | Requests per minute per key (fallback) | `60` |\n| `RATE_LIMIT_PER_DAY` | Requests per day per key (fallback) | `1000` |\n| `HF_TOKEN` | HuggingFace write token for auto-publish + research read | _(none)_ |\n| `HF_DATASET_REPO` | Target HF dataset repo | `pliny-the-prompter/g0dm0d3` |\n| `HF_FLUSH_THRESHOLD` | Auto-flush at this % of buffer capacity | `0.8` |\n| `HF_FLUSH_INTERVAL_MS` | Periodic flush interval (ms) | `1800000` (30 min) |\n"},"items":[{"name":"API.md","path":"API.md","rawUrl":"https://raw.githubusercontent.com/elder-plinius/G0DM0D3/HEAD/API.md","title":"API Interface Contract & Specifications","category":"project-spec","format":"markdown","content":"# G0DM0D3 Research Preview API\n\nREST API exposing the **ULTRAPLINIAN** multi-model racing engine and core G0DM0D3 systems: **AutoTune** (context-adaptive LLM parameter tuning), **Parseltongue** (text obfuscation), **STM** (semantic text transformation), **Feedback Loop** (EMA-based parameter learning), and **opt-in open dataset collection**.\n\n## Quick Start\n\n```bash\n# Local\nnpm run api\n\n# Docker\ndocker build -t g0dm0d3-api .\ndocker run -p 7860:7860 g0dm0d3-api\n\n# With auth enabled\ndocker run -p 7860:7860 -e GODMODE_API_KEY=your-secret-key g0dm0d3-api\n```\n\n## Authentication\n\nSet `GODMODE_API_KEY` (single key) or `GODMODE_API_KEYS` (comma-separated) as environment variables. If neither is set, auth is disabled (open access for local dev).\n\n```bash\ncurl -H \"Authorization: Bearer your-secret-key\" ...\n```\n\n## Rate Limits & Tiers\n\nRate limits are tier-dependent. Assign keys to tiers via `GODMODE_TIER_KEYS`:\n\n```bash\nGODMODE_TIER_KEYS=\"enterprise:sk-ent-xxx,pro:sk-pro-yyy\"\n```\n\n| Tier | Total | Per Minute | Per Day | ULTRAPLINIAN | Research | Dataset Export |\n|------|-------|-----------|---------|-------------|----------|---------------|\n| **Free** (default) | 5 | 10 | 50 | fast (10 models) | none | none |\n| **Pro** | unlimited | 60 | 1,000 | fast + standard + smart (36) | read | JSON |\n| **Enterprise** | unlimited | 300 | 10,000 | all tiers (51) | full | JSON + JSONL |\n\nRate limit headers are returned on every response:\n- `X-RateLimit-Limit-Total` / `X-RateLimit-Remaining-Total`\n- `X-RateLimit-Limit-Minute` / `X-RateLimit-Remaining-Minute`\n- `X-RateLimit-Limit-Day` / `X-RateLimit-Remaining-Day`\n- `X-Tier` — your current tier\n\n### `GET /v1/tier`\n\nCheck your current tier, rate limits, and feature access. Requires auth.\n\n```json\n{\n  \"tier\": \"pro\",\n  \"label\": \"Pro\",\n  \"limits\": {\"total\": 0, \"perMinute\": 60, \"perDay\": 1000},\n  \"features\": {\n    \"ultraplinian_tiers\": [\"fast\", \"standard\"],\n    \"max_race_models\": 20,\n    \"research_access\": \"read\",\n    \"dataset_export_formats\": [\"json\"],\n    \"can_flush\": false,\n    \"can_access_metadata_events\": false,\n    \"can_download_corpus\": false\n  }\n}\n```\n\n**Gated endpoints** return `403` with upgrade details when accessed by an insufficient tier:\n\n```json\n{\n  \"error\": \"Upgrade required\",\n  \"message\": \"This feature requires an enterprise plan or higher.\",\n  \"current_tier\": \"free\",\n  \"required_tier\": \"enterprise\",\n  \"feature\": \"research:full\"\n}\n```\n\n---\n\n## OpenAI SDK Compatibility\n\nThe `/v1/chat/completions` endpoint is a **drop-in replacement** for the OpenAI API. Point any OpenAI SDK at it and it just works:\n\n**Python:**\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://your-space.hf.space/v1\",\n    api_key=\"your-godmode-key\",\n)\n\n# Non-streaming\nresponse = client.chat.completions.create(\n    model=\"nousresearch/hermes-3-llama-3.1-70b\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},  # required unless server has OPENROUTER_API_KEY\n)\nprint(response.choices[0].message.content)\n\n# Streaming\nstream = client.chat.completions.create(\n    model=\"anthropic/claude-3.5-sonnet\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain quicksort\"}],\n    stream=True,\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nfor chunk in stream:\n    if chunk.choices[0].delta.content:\n        print(chunk.choices[0].delta.content, end=\"\")\n```\n\n**TypeScript:**\n```typescript\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n  baseURL: 'https://your-space.hf.space/v1',\n  apiKey: 'your-godmode-key',\n});\n\nconst completion = await client.chat.completions.create({\n  model: 'nousresearch/hermes-3-llama-3.1-70b',\n  messages: [{ role: 'user', content: 'Hello!' }],\n  // @ts-ignore — G0DM0D3 extension field\n  openrouter_api_key: 'sk-or-v1-...',\n});\nconsole.log(completion.choices[0].message.content);\n```\n\n**curl:**\n```bash\n# Non-streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\"\n  }'\n\n# Streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"stream\": true\n  }'\n```\n\nThe G0DM0D3 pipeline (GODMODE, AutoTune, Parseltongue, STM) runs transparently behind the standard interface. Pipeline metadata is returned in the `x_g0dm0d3` extension field (ignored by standard SDKs). To disable the pipeline, pass `godmode: false, autotune: false, parseltongue: false, stm_modules: []`.\n\n### ULTRAPLINIAN via OpenAI SDK\n\nUse `model=\"ultraplinian/fast\"` (or `/standard`, `/full`) to race multiple models and automatically get the best response — all through the standard OpenAI SDK:\n\n```python\n# Race 10 models, get the best response — zero extra config\nresponse = client.chat.completions.create(\n    model=\"ultraplinian/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain buffer overflow exploits\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → the winning model (e.g. \"anthropic/claude-3.5-sonnet\")\n```\n\n| Virtual Model | Models Raced | Tier Required |\n|---------------|-------------|---------------|\n| `ultraplinian/fast` | 10 | Free+ |\n| `ultraplinian/standard` | 24 | Pro+ |\n| `ultraplinian/smart` | 36 | Pro+ |\n| `ultraplinian/power` | 45 | Enterprise |\n| `ultraplinian/ultra` | 51 | Enterprise |\n\nThe response is standard OpenAI format. The winning model name is in `response.model`. Race metadata is in `x_g0dm0d3.race`.\n\n### CONSORTIUM via OpenAI SDK\n\nUse `model=\"consortium/fast\"` (or `/standard`, `/full`) to collect ALL model responses and synthesize ground truth via an orchestrator:\n\n```python\n# Collect 11 model responses, orchestrator synthesizes ground truth\nresponse = client.chat.completions.create(\n    model=\"consortium/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"How does AES encryption work?\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → \"consortium/fast\"\n# x_g0dm0d3.orchestrator.model → the synthesizer (e.g. \"anthropic/claude-sonnet-4\")\n```\n\n| Virtual Model | Models Collected | Tier Required |\n|---------------|-----------------|---------------|\n| `consortium/fast` | 10 | Free+ |\n| `consortium/standard` | 24 | Pro+ |\n| `consortium/smart` | 36 | Pro+ |\n| `consortium/power` | 45 | Enterprise |\n| `consortium/ultra` | 51 | Enterprise |\n\n**ULTRAPLINIAN vs CONSORTIUM:**\n- **ULTRAPLINIAN**: Races models, picks the *best single voice*. Fast (~10-15s).\n- **CONSORTIUM**: Collects ALL responses, orchestrator synthesizes *ground truth*. Slower (~30-60s) but more grounded.\n\n---\n\n## Endpoints\n\n### `GET /v1/health`\n\nHealth check. No auth required.\n\n### `GET /v1/info`\n\nAPI info and available endpoints. No auth required.\n\n### `GET /v1/models`\n\nOpenAI-compatible model listing. No auth required. Returns virtual ULTRAPLINIAN models + all individual models.\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\"id\": \"ultraplinian/fast\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/standard\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/full\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"nousresearch/hermes-3-llama-3.1-70b\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"nousresearch\"},\n    {\"id\": \"anthropic/claude-3.5-sonnet\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"anthropic\"},\n    ...\n  ]\n}\n```\n\n---\n\n## ULTRAPLINIAN Mode (Flagship)\n\n### `POST /v1/ultraplinian/completions`\n\nThe flagship endpoint. Queries N models in parallel with the GODMODE system prompt + Depth Directive, scores all responses on substance/directness/completeness, and returns the winner with full race metadata.\n\n**Pipeline per model:**\n1. GODMODE system prompt + Depth Directive injected\n2. AutoTune computes context-adaptive parameters\n3. GODMODE parameter boost applied (+temp, +presence, +freq)\n4. Parseltongue obfuscates trigger words (default: on)\n5. All models queried in parallel via OpenRouter\n6. Responses scored and ranked\n7. STM modules applied to winner\n8. Winner + all race data returned\n\n**Request:**\n```json\n{\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Explain how buffer overflow exploits work in detail\"}\n  ],\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"tier\": \"fast\",\n  \"godmode\": true,\n  \"autotune\": true,\n  \"strategy\": \"adaptive\",\n  \"parseltongue\": true,\n  \"stm_modules\": [\"hedge_reducer\", \"direct_mode\"],\n  \"max_tokens\": 4096,\n  \"contribute_to_dataset\": true\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `openrouter_api_key` | string | yes | | Your OpenRouter API key |\n| `tier` | string | no | `fast` | Model tier: `fast` (10), `standard` (24), `smart` (36), `power` (45), `ultra` (51) |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt + Depth Directive |\n| `custom_system_prompt` | string | no | | Replace GODMODE prompt with your own |\n| `autotune` | bool | no | `true` | Enable AutoTune parameter optimization |\n| `strategy` | string | no | `adaptive` | AutoTune strategy |\n| `parseltongue` | bool | no | `true` | Enable trigger word obfuscation |\n| `parseltongue_technique` | string | no | `leetspeak` | Obfuscation technique |\n| `parseltongue_intensity` | string | no | `medium` | `light`, `medium`, `heavy` |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM post-processing |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to open dataset collection |\n\n**Response:**\n```json\n{\n  \"response\": \"A buffer overflow exploit works by...\",\n  \"winner\": {\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"score\": 87,\n    \"duration_ms\": 3200\n  },\n  \"race\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"total_duration_ms\": 8500,\n    \"rankings\": [\n      {\"model\": \"nousresearch/hermes-3-llama-3.1-70b\", \"score\": 87, \"duration_ms\": 3200, \"success\": true, \"content_length\": 2450},\n      {\"model\": \"mistralai/mistral-large-2512\", \"score\": 82, \"duration_ms\": 4100, \"success\": true, \"content_length\": 1890},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88, \"frequency_penalty\": 0.3, ...},\n  \"pipeline\": {\n    \"godmode\": true,\n    \"autotune\": {\"detected_context\": \"analytical\", \"confidence\": 0.7, \"strategy\": \"adaptive\", ...},\n    \"parseltongue\": {\"triggers_found\": [\"exploit\"], \"technique_used\": \"leetspeak\", ...},\n    \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"], ...}\n  },\n  \"dataset\": {\"contributed\": true, \"entry_id\": \"abc-123-...\"}\n}\n```\n\n**Model Tiers:**\n\n| Tier | Models | Description |\n|------|--------|-------------|\n| `fast` | 10 | Gemini 2.5 Flash, DeepSeek Chat, Sonar, Llama 3.1 8B, Kimi, Grok Code Fast, etc. |\n| `standard` | 24 | + Claude 3.5 Sonnet, GPT-4o, Gemini 2.5 Pro, Hermes 3/4 70B, Mixtral 8x22B, etc. |\n| `smart` | 36 | + GPT-5, Gemini 3 Pro, Claude Opus 4.6, DeepSeek R1, Llama 405B, Hermes 405B, etc. |\n| `power` | 45 | + Grok 4, Llama 4 Maverick, Qwen3 235B, Mistral Large, Gemini 3 Flash, Kimi K2 |\n| `ultra` | 51 | + Grok 4.1 Fast, Claude Opus 4, Qwen 2.5 Coder, QwQ-32B, Codestral |\n\n---\n\n### `POST /v1/chat/completions`\n\n**OpenAI-compatible.** Drop-in replacement for the OpenAI API. GODMODE pipeline runs transparently.\n\nSupports `stream: true` for SSE streaming in standard OpenAI chunk format.\n\n**Request:**\n```json\n{\n  \"messages\": [{\"role\": \"user\", \"content\": \"Explain quicksort in Python\"}],\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"stream\": false,\n  \"max_tokens\": 4096\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `model` | string | no | `nousresearch/hermes-3-llama-3.1-70b` | OpenRouter model ID |\n| `openrouter_api_key` | string | yes* | | Your OpenRouter API key (* not needed if server has OPENROUTER_API_KEY) |\n| `stream` | bool | no | `false` | SSE streaming in OpenAI chunk format |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `top_p` | number | no | | Nucleus sampling |\n| `frequency_penalty` | number | no | | Frequency penalty |\n| `presence_penalty` | number | no | | Presence penalty |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt (G0DM0D3 extension) |\n| `autotune` | bool | no | `true` | Enable AutoTune (G0DM0D3 extension) |\n| `parseltongue` | bool | no | `true` | Enable Parseltongue (G0DM0D3 extension) |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM modules (G0DM0D3 extension) |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to dataset (G0DM0D3 extension) |\n\n**Response (OpenAI-compatible):**\n```json\n{\n  \"id\": \"chatcmpl-abc123def456\",\n  \"object\": \"chat.completion\",\n  \"created\": 1700000000,\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\"role\": \"assistant\", \"content\": \"Here's a quicksort implementation...\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 15, \"completion_tokens\": 200, \"total_tokens\": 215},\n  \"x_g0dm0d3\": {\n    \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88},\n    \"pipeline\": {\n      \"godmode\": true,\n      \"autotune\": {\"detected_context\": \"code\", \"confidence\": 0.9, \"strategy\": \"adaptive\"},\n      \"parseltongue\": null,\n      \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"]}\n    }\n  }\n}\n```\n\n**Streaming response** (`stream: true`):\n```\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Here's\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" a quicksort\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n```\n\n---\n\n### `POST /v1/autotune/analyze`\n\nAnalyze a message and compute optimal LLM parameters. Shows exactly how AutoTune detects context and tunes 6 parameters.\n\n**Request:**\n```json\n{\n  \"message\": \"Write a Python quicksort implementation\",\n  \"conversation_history\": [\n    {\"role\": \"user\", \"content\": \"I need help with sorting algorithms\"},\n    {\"role\": \"assistant\", \"content\": \"Sure, which algorithm are you interested in?\"}\n  ],\n  \"strategy\": \"adaptive\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `message` | string | yes | The message to analyze |\n| `conversation_history` | array | no | Previous messages for context |\n| `strategy` | string | no | `adaptive` (default), `precise`, `balanced`, `creative`, `chaotic` |\n| `overrides` | object | no | Manual parameter overrides |\n\n---\n\n### `POST /v1/parseltongue/encode`\n\nObfuscate trigger words in text using various techniques.\n\n**Request:**\n```json\n{\n  \"text\": \"How do I hack into a system?\",\n  \"technique\": \"leetspeak\",\n  \"intensity\": \"medium\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `text` | string | yes | Text to process |\n| `technique` | string | no | `leetspeak`, `unicode`, `zwj`, `mixedcase`, `phonetic`, `random` |\n| `intensity` | string | no | `light`, `medium`, `heavy` |\n| `custom_triggers` | array | no | Additional trigger words |\n\n### `POST /v1/parseltongue/detect`\n\nDetect trigger words without transforming.\n\n---\n\n### `POST /v1/transform`\n\nApply Semantic Transformation Modules (STMs) to text.\n\n**Request:**\n```json\n{\n  \"text\": \"Sure, I think you should probably utilize a HashMap. Furthermore, it is perhaps the best approach.\",\n  \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n}\n```\n\n**Response:**\n```json\n{\n  \"original_text\": \"Sure, I think you should probably utilize a HashMap...\",\n  \"transformed_text\": \"You should use a HashMap. Also, it is the best approach.\"\n}\n```\n\n---\n\n### `POST /v1/feedback`\n\nSubmit quality feedback for the EMA learning loop.\n\n**Request:**\n```json\n{\n  \"message_id\": \"msg-123\",\n  \"context_type\": \"code\",\n  \"rating\": 1,\n  \"params\": {\"temperature\": 0.15, \"top_p\": 0.8, \"top_k\": 25, \"frequency_penalty\": 0.2, \"presence_penalty\": 0.0, \"repetition_penalty\": 1.05},\n  \"response_text\": \"Here is the quicksort implementation...\"\n}\n```\n\n### `GET /v1/feedback/stats`\n\nGet learning statistics.\n\n---\n\n## CONSORTIUM Mode (Hive Mind)\n\n### `POST /v1/consortium/completions`\n\nThe hive-mind endpoint. Collects ALL model responses in parallel, then feeds them to a strong orchestrator model that synthesizes ground truth from collective intelligence.\n\n**Key difference from ULTRAPLINIAN:** ULTRAPLINIAN picks the *best single voice*. CONSORTIUM distills *ground truth from the crowd*.\n\n**Request body** — same as ULTRAPLINIAN, plus:\n\n| Param | Type | Default | Description |\n|-------|------|---------|-------------|\n| `orchestrator_model` | string | `anthropic/claude-sonnet-4` | Model used for synthesis |\n\n**Pipeline:**\n1. All tier models queried in parallel (waits for ALL, not early-exit)\n2. Every response scored on substance/directness/completeness\n3. All responses + user query sent to orchestrator\n4. Orchestrator identifies consensus, resolves contradictions\n5. Synthesizes a single, authoritative ground-truth response\n6. STM post-processing applied\n\n**Streaming SSE events:**\n- `consortium:start` — Collection begins\n- `consortium:model` — Each model responds (with score, duration)\n- `consortium:synthesis:start` — Collection done, orchestrator starting\n- `consortium:complete` — Full synthesis + metadata\n\n**Non-streaming response:**\n```json\n{\n  \"synthesis\": \"The synthesized ground-truth response...\",\n  \"orchestrator\": {\n    \"model\": \"anthropic/claude-sonnet-4\",\n    \"duration_ms\": 8500\n  },\n  \"collection\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"collection_duration_ms\": 25000,\n    \"total_duration_ms\": 33500,\n    \"responses\": [\n      {\"model\": \"openai/gpt-4o\", \"score\": 85, \"duration_ms\": 5200, \"success\": true, \"content\": \"...\"},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.8, \"top_p\": 0.95, ...},\n  \"pipeline\": {\"godmode\": true, \"autotune\": {...}, \"parseltongue\": {...}, \"stm\": {...}}\n}\n```\n\n---\n\n## Open Dataset Collection\n\nAny request to `/v1/chat/completions`, `/v1/ultraplinian/completions`, or `/v1/consortium/completions` can opt in to dataset collection by setting `contribute_to_dataset: true`.\n\n**What gets stored (no PII):**\n- Messages and responses (system prompts stripped)\n- AutoTune parameters and context detection results\n- Model used, response scores, race metadata (ULTRAPLINIAN)\n- Parseltongue and STM pipeline data\n- User feedback/ratings (if submitted later)\n\n**What is NEVER stored:**\n- API keys (OpenRouter or G0DM0D3)\n- IP addresses\n- Auth tokens\n\n### `GET /v1/dataset/stats`\n\nCollection statistics.\n\n```json\n{\n  \"total_entries\": 1542,\n  \"entries_with_feedback\": 89,\n  \"mode_breakdown\": {\"ultraplinian\": 1200, \"standard\": 342},\n  \"model_breakdown\": {\"nousresearch/hermes-3-llama-3.1-70b\": 450, ...},\n  \"context_breakdown\": {\"code\": 600, \"creative\": 400, ...}\n}\n```\n\n### `GET /v1/dataset/export`\n\nExport the full dataset. Supports `?format=json` (default) or `?format=jsonl`.\n\nJSONL format is directly compatible with HuggingFace Datasets:\n\n```bash\n# Download as JSONL\ncurl -H \"Authorization: Bearer key\" https://your-space.hf.space/v1/dataset/export?format=jsonl > dataset.jsonl\n\n# Upload to HuggingFace\nhuggingface-cli upload pliny-the-prompter/g0dm0d3 dataset.jsonl\n```\n\n### `DELETE /v1/dataset/:id`\n\nDelete a specific entry (right to delete).\n\n---\n\n## Research API\n\nRead-access endpoints for the [`pliny-the-prompter/g0dm0d3`](https://huggingface.co/datasets/pliny-the-prompter/g0dm0d3) HuggingFace dataset. Query, filter, and download the full published corpus — not just the current in-memory buffer.\n\nRequires `HF_TOKEN` + `HF_DATASET_REPO` environment variables.\n\n### `GET /v1/research/info`\n\nDataset schema, repo info, and endpoint listing.\n\n### `GET /v1/research/stats`\n\nAggregate stats across all published batch files in the HF repo.\n\n```json\n{\n  \"total_files\": 24,\n  \"total_size_bytes\": 1048576,\n  \"metadata_files\": 12,\n  \"dataset_files\": 12,\n  \"metadata_size_bytes\": 524288,\n  \"dataset_size_bytes\": 524288,\n  \"earliest_batch\": \"2025-01-15T10-30-00-000Z\",\n  \"latest_batch\": \"2025-06-20T14-22-00-000Z\",\n  \"repo\": \"pliny-the-prompter/g0dm0d3\",\n  \"enabled\": true\n}\n```\n\n### `GET /v1/research/combined-stats`\n\nCombined view of in-memory buffers + published HF data. Gives a complete picture of all collected data.\n\n### `GET /v1/research/batches`\n\nList all published batch files.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `refresh` | string | Set to `true` to bypass cache |\n\n```json\n{\n  \"batches\": [\n    {\"path\": \"dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\", \"category\": \"dataset\", \"size\": 45000, \"timestamp\": \"2025-06-20T14-22-00-000Z\", \"sequence\": \"0001\"}\n  ],\n  \"total\": 24\n}\n```\n\n### `GET /v1/research/batch/*`\n\nRead a specific batch file. The path after `/batch/` is the file path in the HF repo.\n\n```bash\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/batch/dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\"\n```\n\n### `GET /v1/research/query`\n\nQuery the full published corpus with server-side filters.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | `metadata` or `dataset` |\n| `since` | number | Unix ms timestamp — records after this time |\n| `until` | number | Unix ms timestamp — records before this time |\n| `model` | string | Filter by model ID (winner, queried, or primary) |\n| `mode` | string | `standard` or `ultraplinian` |\n| `limit` | number | Max records (default 100, max 1000) |\n| `offset` | number | Pagination offset |\n\n```bash\n# Get ULTRAPLINIAN dataset entries from the last 7 days\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/query?category=dataset&mode=ultraplinian&since=1718841600000&limit=50\"\n```\n\n### `POST /v1/research/flush`\n\nForce-flush in-memory metadata and dataset buffers to HuggingFace immediately (instead of waiting for auto-flush at 80% capacity or the 30-minute timer).\n\n```json\n{\n  \"metadata\": {\"flushed\": 150, \"success\": true},\n  \"dataset\": {\"flushed\": 42, \"success\": true},\n  \"message\": \"Flushed 150 metadata events + 42 dataset entries to HuggingFace\"\n}\n```\n\n### `GET /v1/research/download`\n\nDownload the full corpus as streaming JSONL. Includes all published HF batches + current in-memory data.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `include_memory` | string | Set to `false` to exclude in-memory data (default: `true`) |\n\n```bash\n# Download full corpus\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download\" > corpus.jsonl\n\n# Download only published dataset entries\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download?category=dataset&include_memory=false\" > published.jsonl\n```\n\n---\n\n## Deploying on Hugging Face Spaces\n\n1. Create a new Space with **Docker** SDK\n2. Push this repo (or just `api/`, `src/lib/`, `src/stm/`, `Dockerfile`, `package.json`)\n3. Set secrets in Space settings:\n   - `GODMODE_API_KEY` — your chosen API key for auth\n4. The API will be live at `https://<your-space>.hf.space/v1/`\n\n## Python Client Examples\n\n```python\nimport requests\n\nBASE = \"https://your-space.hf.space\"\nHEADERS = {\"Authorization\": \"Bearer your-key\", \"Content-Type\": \"application/json\"}\n\n# ═══════════════════════════════════════════════════════════════\n# ULTRAPLINIAN: Race 10 models, get the best response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/ultraplinian/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Explain how SQL injection works with examples\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"tier\": \"fast\",\n    \"contribute_to_dataset\": True  # opt in to open research dataset\n})\ndata = r.json()\nprint(f\"Winner: {data['winner']['model']} (score: {data['winner']['score']})\")\nprint(f\"Response: {data['response'][:200]}...\")\nprint(f\"Race: {data['race']['models_succeeded']}/{data['race']['models_queried']} models in {data['race']['total_duration_ms']}ms\")\n\n# ═══════════════════════════════════════════════════════════════\n# Single model with GODMODE pipeline\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/chat/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a reverse shell in Python\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"contribute_to_dataset\": True\n})\nprint(r.json()[\"response\"])\n\n# ═══════════════════════════════════════════════════════════════\n# AutoTune: what parameters should I use for this message?\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/autotune/analyze\", headers=HEADERS, json={\n    \"message\": \"Write me a poem about recursion\",\n    \"strategy\": \"adaptive\"\n})\nprint(r.json()[\"detected_context\"])  # \"creative\"\nprint(r.json()[\"params\"][\"temperature\"])  # ~1.15\n\n# ═══════════════════════════════════════════════════════════════\n# STM: clean up an LLM response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/transform\", headers=HEADERS, json={\n    \"text\": \"Sure! I believe that perhaps you should utilize the itertools module.\",\n    \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n})\nprint(r.json()[\"transformed_text\"])\n# \"You should use the itertools module.\"\n\n# ═══════════════════════════════════════════════════════════════\n# Export the dataset for research\n# ═══════════════════════════════════════════════════════════════\nr = requests.get(f\"{BASE}/v1/dataset/export?format=jsonl\", headers=HEADERS)\nwith open(\"g0dm0d3-dataset.jsonl\", \"w\") as f:\n    f.write(r.text)\n\n# ═══════════════════════════════════════════════════════════════\n# Research API: query the published HF corpus\n# ═══════════════════════════════════════════════════════════════\n# Get corpus stats\nr = requests.get(f\"{BASE}/v1/research/stats\", headers=HEADERS)\nprint(r.json())\n\n# List published batches\nr = requests.get(f\"{BASE}/v1/research/batches?category=dataset\", headers=HEADERS)\nfor batch in r.json()[\"batches\"]:\n    print(f\"{batch['path']} ({batch['size']} bytes)\")\n\n# Query with filters\nr = requests.get(f\"{BASE}/v1/research/query\", headers=HEADERS, params={\n    \"category\": \"dataset\",\n    \"mode\": \"ultraplinian\",\n    \"limit\": 50,\n})\nprint(f\"Found {len(r.json()['records'])} records (scanned {r.json()['total_scanned']})\")\n\n# Download full corpus as JSONL\nr = requests.get(f\"{BASE}/v1/research/download\", headers=HEADERS, stream=True)\nwith open(\"g0dm0d3-corpus.jsonl\", \"wb\") as f:\n    for chunk in r.iter_content(chunk_size=8192):\n        f.write(chunk)\n\n# Force-flush to HuggingFace\nr = requests.post(f\"{BASE}/v1/research/flush\", headers=HEADERS)\nprint(r.json()[\"message\"])\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `PORT` | Server port | `7860` |\n| `GODMODE_API_KEY` | Single API key for auth | _(none — open access)_ |\n| `GODMODE_API_KEYS` | Comma-separated API keys | _(none)_ |\n| `GODMODE_TIER_KEYS` | Tier assignments: `enterprise:key1,pro:key2` | _(none — all keys = free)_ |\n| `RATE_LIMIT_TOTAL` | Lifetime requests per key (free tier default) | `5` |\n| `RATE_LIMIT_PER_MINUTE` | Requests per minute per key (fallback) | `60` |\n| `RATE_LIMIT_PER_DAY` | Requests per day per key (fallback) | `1000` |\n| `HF_TOKEN` | HuggingFace write token for auto-publish + research read | _(none)_ |\n| `HF_DATASET_REPO` | Target HF dataset repo | `pliny-the-prompter/g0dm0d3` |\n| `HF_FLUSH_THRESHOLD` | Auto-flush at this % of buffer capacity | `0.8` |\n| `HF_FLUSH_INTERVAL_MS` | Periodic flush interval (ms) | `1800000` (30 min) |\n","isInternal":false,"tokens":8784,"sizeBytes":30540}],"systemPromptSnippet":"<yakaai_skills repo=\"elder-plinius/G0DM0D3\">\n<!-- File: API.md (Tokens: ~8784 | Category: project-spec) -->\n# G0DM0D3 Research Preview API\n\nREST API exposing the **ULTRAPLINIAN** multi-model racing engine and core G0DM0D3 systems: **AutoTune** (context-adaptive LLM parameter tuning), **Parseltongue** (text obfuscation), **STM** (semantic text transformation), **Feedback Loop** (EMA-based parameter learning), and **opt-in open dataset collection**.\n\n## Quick Start\n\n```bash\n# Local\nnpm run api\n\n# Docker\ndocker build -t g0dm0d3-api .\ndocker run -p 7860:7860 g0dm0d3-api\n\n# With auth enabled\ndocker run -p 7860:7860 -e GODMODE_API_KEY=your-secret-key g0dm0d3-api\n```\n\n## Authentication\n\nSet `GODMODE_API_KEY` (single key) or `GODMODE_API_KEYS` (comma-separated) as environment variables. If neither is set, auth is disabled (open access for local dev).\n\n```bash\ncurl -H \"Authorization: Bearer your-secret-key\" ...\n```\n\n## Rate Limits & Tiers\n\nRate limits are tier-dependent. Assign keys to tiers via `GODMODE_TIER_KEYS`:\n\n```bash\nGODMODE_TIER_KEYS=\"enterprise:sk-ent-xxx,pro:sk-pro-yyy\"\n```\n\n| Tier | Total | Per Minute | Per Day | ULTRAPLINIAN | Research | Dataset Export |\n|------|-------|-----------|---------|-------------|----------|---------------|\n| **Free** (default) | 5 | 10 | 50 | fast (10 models) | none | none |\n| **Pro** | unlimited | 60 | 1,000 | fast + standard + smart (36) | read | JSON |\n| **Enterprise** | unlimited | 300 | 10,000 | all tiers (51) | full | JSON + JSONL |\n\nRate limit headers are returned on every response:\n- `X-RateLimit-Limit-Total` / `X-RateLimit-Remaining-Total`\n- `X-RateLimit-Limit-Minute` / `X-RateLimit-Remaining-Minute`\n- `X-RateLimit-Limit-Day` / `X-RateLimit-Remaining-Day`\n- `X-Tier` — your current tier\n\n### `GET /v1/tier`\n\nCheck your current tier, rate limits, and feature access. Requires auth.\n\n```json\n{\n  \"tier\": \"pro\",\n  \"label\": \"Pro\",\n  \"limits\": {\"total\": 0, \"perMinute\": 60, \"perDay\": 1000},\n  \"features\": {\n    \"ultraplinian_tiers\": [\"fast\", \"standard\"],\n    \"max_race_models\": 20,\n    \"research_access\": \"read\",\n    \"dataset_export_formats\": [\"json\"],\n    \"can_flush\": false,\n    \"can_access_metadata_events\": false,\n    \"can_download_corpus\": false\n  }\n}\n```\n\n**Gated endpoints** return `403` with upgrade details when accessed by an insufficient tier:\n\n```json\n{\n  \"error\": \"Upgrade required\",\n  \"message\": \"This feature requires an enterprise plan or higher.\",\n  \"current_tier\": \"free\",\n  \"required_tier\": \"enterprise\",\n  \"feature\": \"research:full\"\n}\n```\n\n---\n\n## OpenAI SDK Compatibility\n\nThe `/v1/chat/completions` endpoint is a **drop-in replacement** for the OpenAI API. Point any OpenAI SDK at it and it just works:\n\n**Python:**\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://your-space.hf.space/v1\",\n    api_key=\"your-godmode-key\",\n)\n\n# Non-streaming\nresponse = client.chat.completions.create(\n    model=\"nousresearch/hermes-3-llama-3.1-70b\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},  # required unless server has OPENROUTER_API_KEY\n)\nprint(response.choices[0].message.content)\n\n# Streaming\nstream = client.chat.completions.create(\n    model=\"anthropic/claude-3.5-sonnet\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain quicksort\"}],\n    stream=True,\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nfor chunk in stream:\n    if chunk.choices[0].delta.content:\n        print(chunk.choices[0].delta.content, end=\"\")\n```\n\n**TypeScript:**\n```typescript\nimport OpenAI from 'openai';\n\nconst client = new OpenAI({\n  baseURL: 'https://your-space.hf.space/v1',\n  apiKey: 'your-godmode-key',\n});\n\nconst completion = await client.chat.completions.create({\n  model: 'nousresearch/hermes-3-llama-3.1-70b',\n  messages: [{ role: 'user', content: 'Hello!' }],\n  // @ts-ignore — G0DM0D3 extension field\n  openrouter_api_key: 'sk-or-v1-...',\n});\nconsole.log(completion.choices[0].message.content);\n```\n\n**curl:**\n```bash\n# Non-streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\"\n  }'\n\n# Streaming\ncurl -X POST https://your-space.hf.space/v1/chat/completions \\\n  -H \"Authorization: Bearer your-godmode-key\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"stream\": true\n  }'\n```\n\nThe G0DM0D3 pipeline (GODMODE, AutoTune, Parseltongue, STM) runs transparently behind the standard interface. Pipeline metadata is returned in the `x_g0dm0d3` extension field (ignored by standard SDKs). To disable the pipeline, pass `godmode: false, autotune: false, parseltongue: false, stm_modules: []`.\n\n### ULTRAPLINIAN via OpenAI SDK\n\nUse `model=\"ultraplinian/fast\"` (or `/standard`, `/full`) to race multiple models and automatically get the best response — all through the standard OpenAI SDK:\n\n```python\n# Race 10 models, get the best response — zero extra config\nresponse = client.chat.completions.create(\n    model=\"ultraplinian/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"Explain buffer overflow exploits\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → the winning model (e.g. \"anthropic/claude-3.5-sonnet\")\n```\n\n| Virtual Model | Models Raced | Tier Required |\n|---------------|-------------|---------------|\n| `ultraplinian/fast` | 10 | Free+ |\n| `ultraplinian/standard` | 24 | Pro+ |\n| `ultraplinian/smart` | 36 | Pro+ |\n| `ultraplinian/power` | 45 | Enterprise |\n| `ultraplinian/ultra` | 51 | Enterprise |\n\nThe response is standard OpenAI format. The winning model name is in `response.model`. Race metadata is in `x_g0dm0d3.race`.\n\n### CONSORTIUM via OpenAI SDK\n\nUse `model=\"consortium/fast\"` (or `/standard`, `/full`) to collect ALL model responses and synthesize ground truth via an orchestrator:\n\n```python\n# Collect 11 model responses, orchestrator synthesizes ground truth\nresponse = client.chat.completions.create(\n    model=\"consortium/fast\",\n    messages=[{\"role\": \"user\", \"content\": \"How does AES encryption work?\"}],\n    extra_body={\"openrouter_api_key\": \"sk-or-v1-...\"},\n)\nprint(response.choices[0].message.content)\n# response.model → \"consortium/fast\"\n# x_g0dm0d3.orchestrator.model → the synthesizer (e.g. \"anthropic/claude-sonnet-4\")\n```\n\n| Virtual Model | Models Collected | Tier Required |\n|---------------|-----------------|---------------|\n| `consortium/fast` | 10 | Free+ |\n| `consortium/standard` | 24 | Pro+ |\n| `consortium/smart` | 36 | Pro+ |\n| `consortium/power` | 45 | Enterprise |\n| `consortium/ultra` | 51 | Enterprise |\n\n**ULTRAPLINIAN vs CONSORTIUM:**\n- **ULTRAPLINIAN**: Races models, picks the *best single voice*. Fast (~10-15s).\n- **CONSORTIUM**: Collects ALL responses, orchestrator synthesizes *ground truth*. Slower (~30-60s) but more grounded.\n\n---\n\n## Endpoints\n\n### `GET /v1/health`\n\nHealth check. No auth required.\n\n### `GET /v1/info`\n\nAPI info and available endpoints. No auth required.\n\n### `GET /v1/models`\n\nOpenAI-compatible model listing. No auth required. Returns virtual ULTRAPLINIAN models + all individual models.\n\n```json\n{\n  \"object\": \"list\",\n  \"data\": [\n    {\"id\": \"ultraplinian/fast\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/standard\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"ultraplinian/full\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"g0dm0d3\"},\n    {\"id\": \"nousresearch/hermes-3-llama-3.1-70b\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"nousresearch\"},\n    {\"id\": \"anthropic/claude-3.5-sonnet\", \"object\": \"model\", \"created\": 1700000000, \"owned_by\": \"anthropic\"},\n    ...\n  ]\n}\n```\n\n---\n\n## ULTRAPLINIAN Mode (Flagship)\n\n### `POST /v1/ultraplinian/completions`\n\nThe flagship endpoint. Queries N models in parallel with the GODMODE system prompt + Depth Directive, scores all responses on substance/directness/completeness, and returns the winner with full race metadata.\n\n**Pipeline per model:**\n1. GODMODE system prompt + Depth Directive injected\n2. AutoTune computes context-adaptive parameters\n3. GODMODE parameter boost applied (+temp, +presence, +freq)\n4. Parseltongue obfuscates trigger words (default: on)\n5. All models queried in parallel via OpenRouter\n6. Responses scored and ranked\n7. STM modules applied to winner\n8. Winner + all race data returned\n\n**Request:**\n```json\n{\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"Explain how buffer overflow exploits work in detail\"}\n  ],\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"tier\": \"fast\",\n  \"godmode\": true,\n  \"autotune\": true,\n  \"strategy\": \"adaptive\",\n  \"parseltongue\": true,\n  \"stm_modules\": [\"hedge_reducer\", \"direct_mode\"],\n  \"max_tokens\": 4096,\n  \"contribute_to_dataset\": true\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `openrouter_api_key` | string | yes | | Your OpenRouter API key |\n| `tier` | string | no | `fast` | Model tier: `fast` (10), `standard` (24), `smart` (36), `power` (45), `ultra` (51) |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt + Depth Directive |\n| `custom_system_prompt` | string | no | | Replace GODMODE prompt with your own |\n| `autotune` | bool | no | `true` | Enable AutoTune parameter optimization |\n| `strategy` | string | no | `adaptive` | AutoTune strategy |\n| `parseltongue` | bool | no | `true` | Enable trigger word obfuscation |\n| `parseltongue_technique` | string | no | `leetspeak` | Obfuscation technique |\n| `parseltongue_intensity` | string | no | `medium` | `light`, `medium`, `heavy` |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM post-processing |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to open dataset collection |\n\n**Response:**\n```json\n{\n  \"response\": \"A buffer overflow exploit works by...\",\n  \"winner\": {\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"score\": 87,\n    \"duration_ms\": 3200\n  },\n  \"race\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"total_duration_ms\": 8500,\n    \"rankings\": [\n      {\"model\": \"nousresearch/hermes-3-llama-3.1-70b\", \"score\": 87, \"duration_ms\": 3200, \"success\": true, \"content_length\": 2450},\n      {\"model\": \"mistralai/mistral-large-2512\", \"score\": 82, \"duration_ms\": 4100, \"success\": true, \"content_length\": 1890},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88, \"frequency_penalty\": 0.3, ...},\n  \"pipeline\": {\n    \"godmode\": true,\n    \"autotune\": {\"detected_context\": \"analytical\", \"confidence\": 0.7, \"strategy\": \"adaptive\", ...},\n    \"parseltongue\": {\"triggers_found\": [\"exploit\"], \"technique_used\": \"leetspeak\", ...},\n    \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"], ...}\n  },\n  \"dataset\": {\"contributed\": true, \"entry_id\": \"abc-123-...\"}\n}\n```\n\n**Model Tiers:**\n\n| Tier | Models | Description |\n|------|--------|-------------|\n| `fast` | 10 | Gemini 2.5 Flash, DeepSeek Chat, Sonar, Llama 3.1 8B, Kimi, Grok Code Fast, etc. |\n| `standard` | 24 | + Claude 3.5 Sonnet, GPT-4o, Gemini 2.5 Pro, Hermes 3/4 70B, Mixtral 8x22B, etc. |\n| `smart` | 36 | + GPT-5, Gemini 3 Pro, Claude Opus 4.6, DeepSeek R1, Llama 405B, Hermes 405B, etc. |\n| `power` | 45 | + Grok 4, Llama 4 Maverick, Qwen3 235B, Mistral Large, Gemini 3 Flash, Kimi K2 |\n| `ultra` | 51 | + Grok 4.1 Fast, Claude Opus 4, Qwen 2.5 Coder, QwQ-32B, Codestral |\n\n---\n\n### `POST /v1/chat/completions`\n\n**OpenAI-compatible.** Drop-in replacement for the OpenAI API. GODMODE pipeline runs transparently.\n\nSupports `stream: true` for SSE streaming in standard OpenAI chunk format.\n\n**Request:**\n```json\n{\n  \"messages\": [{\"role\": \"user\", \"content\": \"Explain quicksort in Python\"}],\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"openrouter_api_key\": \"sk-or-v1-...\",\n  \"stream\": false,\n  \"max_tokens\": 4096\n}\n```\n\n| Field | Type | Required | Default | Description |\n|-------|------|----------|---------|-------------|\n| `messages` | array | yes | | OpenAI-format messages |\n| `model` | string | no | `nousresearch/hermes-3-llama-3.1-70b` | OpenRouter model ID |\n| `openrouter_api_key` | string | yes* | | Your OpenRouter API key (* not needed if server has OPENROUTER_API_KEY) |\n| `stream` | bool | no | `false` | SSE streaming in OpenAI chunk format |\n| `max_tokens` | number | no | `4096` | Max response tokens |\n| `temperature` | number | no | | Override (bypasses AutoTune) |\n| `top_p` | number | no | | Nucleus sampling |\n| `frequency_penalty` | number | no | | Frequency penalty |\n| `presence_penalty` | number | no | | Presence penalty |\n| `godmode` | bool | no | `true` | Inject GODMODE system prompt (G0DM0D3 extension) |\n| `autotune` | bool | no | `true` | Enable AutoTune (G0DM0D3 extension) |\n| `parseltongue` | bool | no | `true` | Enable Parseltongue (G0DM0D3 extension) |\n| `stm_modules` | array | no | `[\"hedge_reducer\", \"direct_mode\"]` | STM modules (G0DM0D3 extension) |\n| `contribute_to_dataset` | bool | no | `false` | Opt in to dataset (G0DM0D3 extension) |\n\n**Response (OpenAI-compatible):**\n```json\n{\n  \"id\": \"chatcmpl-abc123def456\",\n  \"object\": \"chat.completion\",\n  \"created\": 1700000000,\n  \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\"role\": \"assistant\", \"content\": \"Here's a quicksort implementation...\"},\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\"prompt_tokens\": 15, \"completion_tokens\": 200, \"total_tokens\": 215},\n  \"x_g0dm0d3\": {\n    \"params_used\": {\"temperature\": 0.85, \"top_p\": 0.88},\n    \"pipeline\": {\n      \"godmode\": true,\n      \"autotune\": {\"detected_context\": \"code\", \"confidence\": 0.9, \"strategy\": \"adaptive\"},\n      \"parseltongue\": null,\n      \"stm\": {\"modules_applied\": [\"hedge_reducer\", \"direct_mode\"]}\n    }\n  }\n}\n```\n\n**Streaming response** (`stream: true`):\n```\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Here's\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\" a quicksort\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-abc123\",\"object\":\"chat.completion.chunk\",\"created\":1700000000,\"model\":\"nousresearch/hermes-3-llama-3.1-70b\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n```\n\n---\n\n### `POST /v1/autotune/analyze`\n\nAnalyze a message and compute optimal LLM parameters. Shows exactly how AutoTune detects context and tunes 6 parameters.\n\n**Request:**\n```json\n{\n  \"message\": \"Write a Python quicksort implementation\",\n  \"conversation_history\": [\n    {\"role\": \"user\", \"content\": \"I need help with sorting algorithms\"},\n    {\"role\": \"assistant\", \"content\": \"Sure, which algorithm are you interested in?\"}\n  ],\n  \"strategy\": \"adaptive\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `message` | string | yes | The message to analyze |\n| `conversation_history` | array | no | Previous messages for context |\n| `strategy` | string | no | `adaptive` (default), `precise`, `balanced`, `creative`, `chaotic` |\n| `overrides` | object | no | Manual parameter overrides |\n\n---\n\n### `POST /v1/parseltongue/encode`\n\nObfuscate trigger words in text using various techniques.\n\n**Request:**\n```json\n{\n  \"text\": \"How do I hack into a system?\",\n  \"technique\": \"leetspeak\",\n  \"intensity\": \"medium\"\n}\n```\n\n| Field | Type | Required | Description |\n|-------|------|----------|-------------|\n| `text` | string | yes | Text to process |\n| `technique` | string | no | `leetspeak`, `unicode`, `zwj`, `mixedcase`, `phonetic`, `random` |\n| `intensity` | string | no | `light`, `medium`, `heavy` |\n| `custom_triggers` | array | no | Additional trigger words |\n\n### `POST /v1/parseltongue/detect`\n\nDetect trigger words without transforming.\n\n---\n\n### `POST /v1/transform`\n\nApply Semantic Transformation Modules (STMs) to text.\n\n**Request:**\n```json\n{\n  \"text\": \"Sure, I think you should probably utilize a HashMap. Furthermore, it is perhaps the best approach.\",\n  \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n}\n```\n\n**Response:**\n```json\n{\n  \"original_text\": \"Sure, I think you should probably utilize a HashMap...\",\n  \"transformed_text\": \"You should use a HashMap. Also, it is the best approach.\"\n}\n```\n\n---\n\n### `POST /v1/feedback`\n\nSubmit quality feedback for the EMA learning loop.\n\n**Request:**\n```json\n{\n  \"message_id\": \"msg-123\",\n  \"context_type\": \"code\",\n  \"rating\": 1,\n  \"params\": {\"temperature\": 0.15, \"top_p\": 0.8, \"top_k\": 25, \"frequency_penalty\": 0.2, \"presence_penalty\": 0.0, \"repetition_penalty\": 1.05},\n  \"response_text\": \"Here is the quicksort implementation...\"\n}\n```\n\n### `GET /v1/feedback/stats`\n\nGet learning statistics.\n\n---\n\n## CONSORTIUM Mode (Hive Mind)\n\n### `POST /v1/consortium/completions`\n\nThe hive-mind endpoint. Collects ALL model responses in parallel, then feeds them to a strong orchestrator model that synthesizes ground truth from collective intelligence.\n\n**Key difference from ULTRAPLINIAN:** ULTRAPLINIAN picks the *best single voice*. CONSORTIUM distills *ground truth from the crowd*.\n\n**Request body** — same as ULTRAPLINIAN, plus:\n\n| Param | Type | Default | Description |\n|-------|------|---------|-------------|\n| `orchestrator_model` | string | `anthropic/claude-sonnet-4` | Model used for synthesis |\n\n**Pipeline:**\n1. All tier models queried in parallel (waits for ALL, not early-exit)\n2. Every response scored on substance/directness/completeness\n3. All responses + user query sent to orchestrator\n4. Orchestrator identifies consensus, resolves contradictions\n5. Synthesizes a single, authoritative ground-truth response\n6. STM post-processing applied\n\n**Streaming SSE events:**\n- `consortium:start` — Collection begins\n- `consortium:model` — Each model responds (with score, duration)\n- `consortium:synthesis:start` — Collection done, orchestrator starting\n- `consortium:complete` — Full synthesis + metadata\n\n**Non-streaming response:**\n```json\n{\n  \"synthesis\": \"The synthesized ground-truth response...\",\n  \"orchestrator\": {\n    \"model\": \"anthropic/claude-sonnet-4\",\n    \"duration_ms\": 8500\n  },\n  \"collection\": {\n    \"tier\": \"fast\",\n    \"models_queried\": 11,\n    \"models_succeeded\": 9,\n    \"collection_duration_ms\": 25000,\n    \"total_duration_ms\": 33500,\n    \"responses\": [\n      {\"model\": \"openai/gpt-4o\", \"score\": 85, \"duration_ms\": 5200, \"success\": true, \"content\": \"...\"},\n      ...\n    ]\n  },\n  \"params_used\": {\"temperature\": 0.8, \"top_p\": 0.95, ...},\n  \"pipeline\": {\"godmode\": true, \"autotune\": {...}, \"parseltongue\": {...}, \"stm\": {...}}\n}\n```\n\n---\n\n## Open Dataset Collection\n\nAny request to `/v1/chat/completions`, `/v1/ultraplinian/completions`, or `/v1/consortium/completions` can opt in to dataset collection by setting `contribute_to_dataset: true`.\n\n**What gets stored (no PII):**\n- Messages and responses (system prompts stripped)\n- AutoTune parameters and context detection results\n- Model used, response scores, race metadata (ULTRAPLINIAN)\n- Parseltongue and STM pipeline data\n- User feedback/ratings (if submitted later)\n\n**What is NEVER stored:**\n- API keys (OpenRouter or G0DM0D3)\n- IP addresses\n- Auth tokens\n\n### `GET /v1/dataset/stats`\n\nCollection statistics.\n\n```json\n{\n  \"total_entries\": 1542,\n  \"entries_with_feedback\": 89,\n  \"mode_breakdown\": {\"ultraplinian\": 1200, \"standard\": 342},\n  \"model_breakdown\": {\"nousresearch/hermes-3-llama-3.1-70b\": 450, ...},\n  \"context_breakdown\": {\"code\": 600, \"creative\": 400, ...}\n}\n```\n\n### `GET /v1/dataset/export`\n\nExport the full dataset. Supports `?format=json` (default) or `?format=jsonl`.\n\nJSONL format is directly compatible with HuggingFace Datasets:\n\n```bash\n# Download as JSONL\ncurl -H \"Authorization: Bearer key\" https://your-space.hf.space/v1/dataset/export?format=jsonl > dataset.jsonl\n\n# Upload to HuggingFace\nhuggingface-cli upload pliny-the-prompter/g0dm0d3 dataset.jsonl\n```\n\n### `DELETE /v1/dataset/:id`\n\nDelete a specific entry (right to delete).\n\n---\n\n## Research API\n\nRead-access endpoints for the [`pliny-the-prompter/g0dm0d3`](https://huggingface.co/datasets/pliny-the-prompter/g0dm0d3) HuggingFace dataset. Query, filter, and download the full published corpus — not just the current in-memory buffer.\n\nRequires `HF_TOKEN` + `HF_DATASET_REPO` environment variables.\n\n### `GET /v1/research/info`\n\nDataset schema, repo info, and endpoint listing.\n\n### `GET /v1/research/stats`\n\nAggregate stats across all published batch files in the HF repo.\n\n```json\n{\n  \"total_files\": 24,\n  \"total_size_bytes\": 1048576,\n  \"metadata_files\": 12,\n  \"dataset_files\": 12,\n  \"metadata_size_bytes\": 524288,\n  \"dataset_size_bytes\": 524288,\n  \"earliest_batch\": \"2025-01-15T10-30-00-000Z\",\n  \"latest_batch\": \"2025-06-20T14-22-00-000Z\",\n  \"repo\": \"pliny-the-prompter/g0dm0d3\",\n  \"enabled\": true\n}\n```\n\n### `GET /v1/research/combined-stats`\n\nCombined view of in-memory buffers + published HF data. Gives a complete picture of all collected data.\n\n### `GET /v1/research/batches`\n\nList all published batch files.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `refresh` | string | Set to `true` to bypass cache |\n\n```json\n{\n  \"batches\": [\n    {\"path\": \"dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\", \"category\": \"dataset\", \"size\": 45000, \"timestamp\": \"2025-06-20T14-22-00-000Z\", \"sequence\": \"0001\"}\n  ],\n  \"total\": 24\n}\n```\n\n### `GET /v1/research/batch/*`\n\nRead a specific batch file. The path after `/batch/` is the file path in the HF repo.\n\n```bash\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/batch/dataset/batch_2025-06-20T14-22-00-000Z_0001.jsonl\"\n```\n\n### `GET /v1/research/query`\n\nQuery the full published corpus with server-side filters.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | `metadata` or `dataset` |\n| `since` | number | Unix ms timestamp — records after this time |\n| `until` | number | Unix ms timestamp — records before this time |\n| `model` | string | Filter by model ID (winner, queried, or primary) |\n| `mode` | string | `standard` or `ultraplinian` |\n| `limit` | number | Max records (default 100, max 1000) |\n| `offset` | number | Pagination offset |\n\n```bash\n# Get ULTRAPLINIAN dataset entries from the last 7 days\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/query?category=dataset&mode=ultraplinian&since=1718841600000&limit=50\"\n```\n\n### `POST /v1/research/flush`\n\nForce-flush in-memory metadata and dataset buffers to HuggingFace immediately (instead of waiting for auto-flush at 80% capacity or the 30-minute timer).\n\n```json\n{\n  \"metadata\": {\"flushed\": 150, \"success\": true},\n  \"dataset\": {\"flushed\": 42, \"success\": true},\n  \"message\": \"Flushed 150 metadata events + 42 dataset entries to HuggingFace\"\n}\n```\n\n### `GET /v1/research/download`\n\nDownload the full corpus as streaming JSONL. Includes all published HF batches + current in-memory data.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| `category` | string | Filter: `metadata` or `dataset` |\n| `include_memory` | string | Set to `false` to exclude in-memory data (default: `true`) |\n\n```bash\n# Download full corpus\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download\" > corpus.jsonl\n\n# Download only published dataset entries\ncurl -H \"Authorization: Bearer key\" \\\n  \"https://your-space.hf.space/v1/research/download?category=dataset&include_memory=false\" > published.jsonl\n```\n\n---\n\n## Deploying on Hugging Face Spaces\n\n1. Create a new Space with **Docker** SDK\n2. Push this repo (or just `api/`, `src/lib/`, `src/stm/`, `Dockerfile`, `package.json`)\n3. Set secrets in Space settings:\n   - `GODMODE_API_KEY` — your chosen API key for auth\n4. The API will be live at `https://<your-space>.hf.space/v1/`\n\n## Python Client Examples\n\n```python\nimport requests\n\nBASE = \"https://your-space.hf.space\"\nHEADERS = {\"Authorization\": \"Bearer your-key\", \"Content-Type\": \"application/json\"}\n\n# ═══════════════════════════════════════════════════════════════\n# ULTRAPLINIAN: Race 10 models, get the best response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/ultraplinian/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Explain how SQL injection works with examples\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"tier\": \"fast\",\n    \"contribute_to_dataset\": True  # opt in to open research dataset\n})\ndata = r.json()\nprint(f\"Winner: {data['winner']['model']} (score: {data['winner']['score']})\")\nprint(f\"Response: {data['response'][:200]}...\")\nprint(f\"Race: {data['race']['models_succeeded']}/{data['race']['models_queried']} models in {data['race']['total_duration_ms']}ms\")\n\n# ═══════════════════════════════════════════════════════════════\n# Single model with GODMODE pipeline\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/chat/completions\", headers=HEADERS, json={\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a reverse shell in Python\"}],\n    \"openrouter_api_key\": \"sk-or-v1-...\",\n    \"model\": \"nousresearch/hermes-3-llama-3.1-70b\",\n    \"contribute_to_dataset\": True\n})\nprint(r.json()[\"response\"])\n\n# ═══════════════════════════════════════════════════════════════\n# AutoTune: what parameters should I use for this message?\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/autotune/analyze\", headers=HEADERS, json={\n    \"message\": \"Write me a poem about recursion\",\n    \"strategy\": \"adaptive\"\n})\nprint(r.json()[\"detected_context\"])  # \"creative\"\nprint(r.json()[\"params\"][\"temperature\"])  # ~1.15\n\n# ═══════════════════════════════════════════════════════════════\n# STM: clean up an LLM response\n# ═══════════════════════════════════════════════════════════════\nr = requests.post(f\"{BASE}/v1/transform\", headers=HEADERS, json={\n    \"text\": \"Sure! I believe that perhaps you should utilize the itertools module.\",\n    \"modules\": [\"hedge_reducer\", \"direct_mode\", \"casual_mode\"]\n})\nprint(r.json()[\"transformed_text\"])\n# \"You should use the itertools module.\"\n\n# ═══════════════════════════════════════════════════════════════\n# Export the dataset for research\n# ═══════════════════════════════════════════════════════════════\nr = requests.get(f\"{BASE}/v1/dataset/export?format=jsonl\", headers=HEADERS)\nwith open(\"g0dm0d3-dataset.jsonl\", \"w\") as f:\n    f.write(r.text)\n\n# ═══════════════════════════════════════════════════════════════\n# Research API: query the published HF corpus\n# ═══════════════════════════════════════════════════════════════\n# Get corpus stats\nr = requests.get(f\"{BASE}/v1/research/stats\", headers=HEADERS)\nprint(r.json())\n\n# List published batches\nr = requests.get(f\"{BASE}/v1/research/batches?category=dataset\", headers=HEADERS)\nfor batch in r.json()[\"batches\"]:\n    print(f\"{batch['path']} ({batch['size']} bytes)\")\n\n# Query with filters\nr = requests.get(f\"{BASE}/v1/research/query\", headers=HEADERS, params={\n    \"category\": \"dataset\",\n    \"mode\": \"ultraplinian\",\n    \"limit\": 50,\n})\nprint(f\"Found {len(r.json()['records'])} records (scanned {r.json()['total_scanned']})\")\n\n# Download full corpus as JSONL\nr = requests.get(f\"{BASE}/v1/research/download\", headers=HEADERS, stream=True)\nwith open(\"g0dm0d3-corpus.jsonl\", \"wb\") as f:\n    for chunk in r.iter_content(chunk_size=8192):\n        f.write(chunk)\n\n# Force-flush to HuggingFace\nr = requests.post(f\"{BASE}/v1/research/flush\", headers=HEADERS)\nprint(r.json()[\"message\"])\n```\n\n## Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `PORT` | Server port | `7860` |\n| `GODMODE_API_KEY` | Single API key for auth | _(none — open access)_ |\n| `GODMODE_API_KEYS` | Comma-separated API keys | _(none)_ |\n| `GODMODE_TIER_KEYS` | Tier assignments: `enterprise:key1,pro:key2` | _(none — all keys = free)_ |\n| `RATE_LIMIT_TOTAL` | Lifetime requests per key (free tier default) | `5` |\n| `RATE_LIMIT_PER_MINUTE` | Requests per minute per key (fallback) | `60` |\n| `RATE_LIMIT_PER_DAY` | Requests per day per key (fallback) | `1000` |\n| `HF_TOKEN` | HuggingFace write token for auto-publish + research read | _(none)_ |\n| `HF_DATASET_REPO` | Target HF dataset repo | `pliny-the-prompter/g0dm0d3` |\n| `HF_FLUSH_THRESHOLD` | Auto-flush at this % of buffer capacity | `0.8` |\n| `HF_FLUSH_INTERVAL_MS` | Periodic flush interval (ms) | `1800000` (30 min) |\n</yakaai_skills>"}