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: ~$0.10 in / $0.40 out per 1M tokens (verified 2026-10-14)
Framework
- Godot Engine: Free, open source (MIT)
- BepInEx (Unity mod loader): Free, open source
Hosting
- Fly.io: No free tier for new users; pay-as-you-go, small VMs from ~ $2/mo (verified 2026-10-14)
No-code alternative
- Bolt.new: Free tier + paid (not verified - check site)
Rough monthly cost
$0–5/mo (local models via Ollama are free)ApproximateDifficulty
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.