LoreKeeper
Persistent memory for AI tabletop RPG game masters — store campaign state, NPCs, and events between sessions, then recall them instantly.
AI game masters can't remember what happened last session. LoreKeeper is the memory layer that fixes that: a stateful store for world state, NPC records, campaign events, and searchable lore, all keyed per caller so each integration gets its own isolated namespace. Build a GM bot that remembers the party defeated the Lich King three sessions ago, that Garen the Blacksmith is still afraid of the Red Hand, and that the wizard is down to 12 HP — without re-feeding the entire campaign into every prompt.
Endpoints
| Endpoint | What it returns |
|---|---|
GET /health |
status, redis (ok/degraded/down), version, timestamp |
POST /sessions |
Creates a session. Returns session_id, created_at, name, campaign_setting |
GET /sessions |
Array of all your sessions, newest first (session_id, created_at, name, campaign_setting) |
GET /sessions/{id} |
Session metadata plus current world state under state (404 if not found) |
PUT /sessions/{id}/state |
Replaces the full world state (arbitrary JSON body). Returns session_id, saved, updated_at |
DELETE /sessions/{id} |
Deletes the session and all associated data. Returns deleted, session_id |
POST /sessions/{id}/npcs |
Upserts an NPC (requires name). Returns the stored record plus session_id, updated_at |
GET /sessions/{id}/npcs |
Array of NPC records for the session |
POST /sessions/{id}/events |
Logs an event (requires type, description; optional metadata). Returns id, session_id, type, description, metadata, logged_at |
GET /sessions/{id}/events |
session_id, count, events (newest first). Optional ?type= filter |
POST /sessions/{id}/lore |
Adds a custom session lore entry (requires title; optional body, tags, setting). Returns the stored entry with its id |
GET /sessions/{id}/lore |
session_id, count, entries — all custom lore for the session |
GET /sessions/{id}/lore/search?q= |
Searches global lore plus this session's custom lore. Returns query, setting, count, results |
GET /lore/search?q= |
Searches the global lore index only. Optional &setting= filter. Returns query, setting, count, results |
GET /sessions/{id}/recap |
Structured recap: campaign_name, campaign_setting, current_world_state, npcs, recent_sessions (grouped events), highlights. Optional ?sessions=N (default 3, max 20) |
Why this API
- Purpose-built for stateful AI GMs. Sessions, NPCs, events, lore, and recaps are first-class — not a generic key/value bucket you have to model yourself.
- Per-caller isolation. Every record is namespaced to your RapidAPI identity, so your campaigns never collide with anyone else's.
- Arbitrary world state.
PUT /sessions/{id}/stateaccepts any JSON shape — party HP, locations, inventory, quest flags — so your schema is whatever your GM needs. - One-call recap.
GET /sessions/{id}/recaprolls current state, all NPCs, grouped session history, and highlight moments (boss kills, deaths, discoveries, betrayals) into a single context-ready payload. - Searchable lore. A keyword + tag + setting index over a shared fantasy lore set, blended with your own custom session lore, so the GM can ground answers in canon and homebrew alike.
- MCP-ready. The same backend is exposed as Model Context Protocol tools (
save_session_state,load_session_state,remember_npc,query_world_lore,flag_campaign_event,generate_session_recap) so any MCP-capable agent gets persistent memory with no glue code.
Typical use cases
- Give an AI dungeon master long-term memory: load state and a recap at the start of a session, save the new state at the end.
- Track NPC relationships and status (
alive/dead,friendly/afraid) so the GM stays consistent about who the party has met and wronged. - Log major beats (
boss_killed,betrayal,artifact_found,quest_complete) and surface them later as campaign highlights. - Pull setting-appropriate lore on demand to ground improvised world-building, mixing shared canon with your own homebrew entries.
- Power a "previously on…" recap screen or pre-session briefing from a single endpoint.
Good to know
- Access is via RapidAPI only. Requests must carry the RapidAPI user identity (the
x-rapidapi-userheader the proxy forwards); direct calls without it return 401. YourcallerKeyis derived from this and scopes all your data. - Data has a TTL. Sessions and their state, NPCs, events, and custom lore expire after 90 days by default; writing state or upserting refreshes the relevant keys. This is working memory, not a permanent archive — export anything you need to keep.
- World state is replace-not-merge.
PUT /sessions/{id}/stateoverwrites the entire state object; send the full state each time rather than a partial patch. - Lore search is keyword-based, not vector/semantic. Queries are tokenized (words of 3+ letters) and matched against an inverted index of titles, bodies, tags, and settings — it favors term overlap, so phrasing matters and there's no fuzzy/synonym matching. Results are capped at 20.
- Global lore depends on the upstream GameForge catalog. The shared lore index is built at startup from the GameForge content API; if that source is unavailable the global index can be empty, though your custom session lore still works.
- NPCs are keyed by name. Posting an NPC with an existing name updates that record (upsert); names are normalized for storage.
- Events are append-only and returned newest-first; there is no event update or delete endpoint. Highlights are limited to the most recent 10 significant events.