Add AI to a game mod or tool
AI NPC dialogue, procedural quests and modding helpers work best with local models: no per-player API cost, works offline, and no keys shipped inside your mod.
Recommended stack
Model
- Ollama (local models): Free, open source; runs on your own hardware
- Google Gemini 2.5 Flash-Lite: Free tier available; paid ~$0.10 in / $0.40 out per 1M tokens (verified 2026-11-22)
Framework
- Godot Engine: Free, open source (MIT)
- BepInEx (Unity mod loader): Free, open source
Hosting
- Fly.io: No free tier (free trial: $1 of credit for 7 days); personal-org bills under $5/mo are waived; smallest always-on VM ~$2.19/mo (verified 2026-11-15)
No-code alternative
- Bolt.new: Free 1M tokens/mo (300K/day); Pro $25/mo (verified 2026-11-15)
Rough monthly cost
$0–5/mo (local models via Ollama are free)Approximate. Tool prices checked 2026-11-15.Difficulty
Intermediate–AdvancedSome links may be affiliate links. Disclosure
Why this stack
- Ollama runs open-weight models locally behind a simple HTTP API.
- Godot is a free, MIT-licensed engine; BepInEx is the standard open-source mod loader for many Unity games.
- A cheap hosted model like Gemini Flash-Lite is a fallback for players without a GPU.
Step-by-step
- Get a hello-world mod or Godot scene running.
- Install Ollama, pull a small model, and call its local HTTP API from your game code.
- Give each NPC a short persona prompt plus recent game state.
- Stream responses and set a timeout so the game never freezes.
Common pitfalls
- Never embed a paid API key in a distributed mod.
- Check the game's modding policy and EULA.
- Small local models can go off-script; constrain output format.
Related stacks
- Build an AI Discord or Telegram bot (Discord / Telegram bot)
- Build an AI voice assistant (Voice assistant)
- Build an AI image generation tool (Image generation)
Last updated 2026-11-22.