AbraTabia AI Storyteller: Self-Hosted AI Storyteller and Game Host API

Updated July 2026
AbraTabia AI Storyteller is our open source AI storyteller and game host API. It is one small PHP application with one SQLite file, you bring your own LLM API key, and any device that can make an HTTPS call can use it: web games, Unity, mobile, or anything else that talks to the web. It gives your game an AI narrator that remembers each player's journey, a turn-based game master for up to 10 players, or a question answering assistant grounded in your own lore, all through a single chat endpoint. The code is free on GitHub under the MIT license.

What AbraTabia AI Storyteller Is

Most games that want AI dialogue end up wiring an LLM provider's API directly into the client, and then hit the same wall: no memory between sessions, no grounding in the game's actual lore, no way to run a shared game with multiple players, and an API key sitting exposed in the client. AbraTabia AI Storyteller is the server that solves those problems once, so your game just sends a player's message and gets back a reply, an action signal, and a conversation ID.

The whole system is deliberately small. One PHP application, one SQLite database file, no framework, and no dependency install. It runs on shared hosting, a VPS, a Docker container, or your laptop during development. You connect it to the LLM provider you prefer: Anthropic directly, or any OpenAI compatible API, which covers OpenAI itself, OpenRouter, and local model runners like Ollama and LM Studio.

On top of the raw model, the server adds the parts a game actually needs. A knowledge base holds your world lore, rules, and content, and every prompt automatically retrieves the most relevant pieces. Per-player memories let the bot remember what each player did across sessions. Conversation summaries keep long sessions coherent without runaway token costs. And an action field on every response tells your UI when something game-relevant happened, a choice point, a chapter break, an encounter, or any custom action you define.

The project is written and maintained by Paul Crinigan of AI Apps API, and the full source lives at github.com/AIAppsAPI/AbraTabia-AI-Storyteller.

The Three Bot Types

Storyteller bots are immersive narrators. A storyteller treats your knowledge base as canonical story lore, narrates in character, and tracks each player's personal journey with long-term memories. It signals story events to your UI through the action field: choice when the player faces a real decision point, chapter at a scene break, encounter when someone or something important appears. Your game renders those moments however it wants, a choice overlay, a chapter card, a combat transition. The storyteller bots guide covers the details.

Gamehost bots are turn-based game masters for 1 to 10 players. The gamehost collects secret setup data from each player before the game starts, tracks whose turn it is, tells you when all players have submitted their moves, and applies whatever game rules you send it as text. You can define custom actions per request, so the bot signals your client about the game events you care about. This turns a shared AI conversation into a real multiplayer game session. The gamehost guide walks through the full flow.

Assistant bots are plain question answerers that stick to your knowledge base. They are useful for in-game help, an FAQ NPC, a tutorial guide, or any situation where you want accurate answers from your own content rather than creative narration. The assistant signals an angry action when it detects a frustrated user, which is handy for escalation.

Feature Overview

Knowledge base with retrieval. Paste text in the admin area, push content through the API, or point the built-in crawler at a website. Content is chunked, embedded, and retrieved by relevance on every prompt, so bots answer from your world's actual lore instead of inventing their own. Embeddings come from OpenAI (stored locally in SQLite) or from Upstash Vector, or can be switched off entirely to run bots from rules alone. The knowledge base and memory guide explains the options.

Per-player memories. Give each player their own memory tag and the bot saves key facts after each response, then recalls the relevant ones in later sessions. The elf ranger who betrayed the innkeeper in chapter one gets remembered in chapter nine, per player, automatically.

Conversation memory with self-cleanup. Each reply includes distilled bullet summaries used as compact history, and the model can trigger a cleanup that collapses a drifting conversation down to its important facts. Long play sessions stay coherent and token costs stay flat.

Admin area and demo page. Bots are created and tuned in a browser admin area, where you also manage knowledge content, run website crawls, and read recent conversations. A built-in demo chat page lets you talk to any bot before a single line of game code exists.

One endpoint for everything. Your game talks to api.php/chat for all three bot types, with a JSON request and response documented field by field in the chat API reference.

Quick Start

Requires PHP 8.1 or newer with the curl, pdo_sqlite, and dom extensions, all standard. Locally:

cp config.sample.php config.php
# edit config.php: add your LLM key, set apiKey and adminPassword
php -S localhost:8080 -t public

Then open admin.php, log in, create a bot, and try it at demo.php. Docker users run docker compose up --build instead, and shared hosting users upload the project and point a docroot or subdomain at the public/ folder. The getting started guide covers each path plus every config setting.

Works With Any Engine or Device

The API is plain HTTPS with JSON, so the client side is whatever your project already is. A browser game calls it with fetch. A Unity game uses UnityWebRequest, and a Unity client package with storyteller and gamehost integration is on the roadmap. Godot, Phaser, Three.js, Babylon.js, native mobile, a Discord bot, all the same three lines of HTTP. If your platform can make a POST request, it can have a storyteller.

That pairs naturally with the topics covered across this site: LLM NPCs for dialogue design, AI game development for the broader workflow, and the per-engine guides for wiring HTTP calls into your game loop. Voice input and output provider hooks are also on the roadmap, and the response format already reserves space for audio fields.

Documentation and Guides

Setup and Reference

Building With the Bots

The GitHub README is the fastest technical overview, and issues and contributions are welcome there.

Beyond Games: SMS and Email Bots

The chat API is not limited to games. Our open source SMS Campaign Engine and Email Campaign Engine both include chatbot hooks that speak this exact API, so an AbraTabia install can answer incoming text messages and email replies automatically, grounded in the same knowledge base. An assistant bot loaded with your business content becomes a support line across chat, SMS, and email from one server.

Security Notes

Every chat call spends your LLM credits, so set apiKey and adminPassword to long random strings before exposing the server, serve over HTTPS in production, and lock corsOrigin to your game's origin once you are live. One caveat deserves emphasis for browser games: a key shipped inside client code is visible to players. Either accept that and set spending limits with your LLM provider, or route calls through your own game server so the key stays private.

Key Takeaway

AbraTabia AI Storyteller gives your game an AI narrator, game master, or assistant through one self-hosted endpoint: your lore in a retrieval knowledge base, per-player memory across sessions, turn tracking for up to 10 players, and action signals your UI can react to. One PHP app, one SQLite file, your own LLM key, MIT licensed on GitHub.