Connecting AI Agents, IDEs & RAG Pipelines

Because api/llm.php exposes an unauthenticated OpenAPI 3.0 schema (?mode=schema), a standard llms.txt catalog (?mode=tree&format=llms.txt), and offset/limit chunking (?mode=doc), you can wire Standalone Qwiki into AI assistants and retrieval pipelines in minutes.

1. Point Coding Assistants at llms.txt & OpenAPI

  • OpenAPI Tool Registration: Give your agent platform or custom GPT the URL https://<your-wiki>/api/llm.php?mode=schema along with your scoped qwk_llm_... Bearer token. The agent discovers tree, doc, search, comments, and talk automatically.
  • System Prompt / Context Bootstrap: Fetch ?mode=tree&format=llms.txt once at session start so the assistant knows every valid slug, title, and category in scope before pulling full chapters on demand.

2. Efficient Context-Window Slicing (offset & limit)

For large manuals or strict token budgets, avoid pulling every chapter blindly:

import os
import urllib.request
import json

BASE = "https://home.qwiki.wiki/manual/api/llm.php"
KEY = os.environ["QWIKI_LLM_KEY"]

def qwiki_get(params: str) -> dict:
    req = urllib.request.Request(
        f"{BASE}?{params}",
        headers={"Authorization": f"Bearer {KEY}"},
    )
    with urllib.request.urlopen(req) as resp:
        return json.loads(resp.read().decode("utf-8"))

# 1. Search first instead of scanning every chapter
hits = qwiki_get("mode=search&q=revision+history&limit=5")

# 2. Fetch the top match in bounded chunks (offset/limit in characters)
if hits["matches"]:
    slug = hits["matches"][0]["slug"]
    chunk = qwiki_get(f"mode=doc&slug={slug}&offset=0&limit=6000")
    print(chunk["document"]["title"])
    print(chunk["document"]["content"])

3. Conditional Sync for RAG Indexers

When syncing a Qwiki portal into a local vector store or SQLite FTS index:

  • Send the previous ETag in If-None-Match on GET /api/llm.php?mode=tree.
  • If nothing has changed since your last crawl, Qwiki returns 304 Not Modified immediately without re-serializing the tree.
  • Pair mode=tree mtime timestamps with mode=doc&format=raw to re-embed only modified chapters.

4. Scoped Tokens by Environment

Use Case Recommended Category Scope Allowed Types
Customer Support Bot Public User Guide branch markdown
Engineering Coding Agent Technical & AI Reference branches markdown, html
Editorial Review Assistant All published branches + include_talk=1 markdown