tModLoader Terraria LLM Chat

Deon

Terrarian
Download

Configuration guide



Screenshots

PREFZ.png
PREF4.png

PREF1.png
PREF2.png


Description

This mod allows you to talk to your Town NPCs using chat.

You need an account with OpenRouter or OpenAI and you must set your API token in the mod settings:
- "Workshop → Manage Mods → Gear icon"
or
- "Settings → Mod Configuration → Terraria LLM Chat"


How to configure

Configure your OpenRouter / OpenAI token in the mod settings. The field is long, but it can be copy-pasted in.
You can also specify your favourite model. The default one is "gpt-4o". Do not use quotation marks, just type the model ID.

For OpenRouter, you can use the following link to query all models:
- https://openrouter.ai/docs/api-reference/list-available-models?explorer=true

I personally use "deepseek/deepseek-chat-v3-0324"

For OpenAI, I can give you the following information myself, but you can also look it up online if you need to.
- gpt-4.1 — $2.00 / 1M input, $8.00 / 1M output — high-quality dialogue, long context, strong instruction following.
- gpt-4o — $1.25 / 1M input, $10.00 / 1M output — versatile, great style and latency even when used text-only.
- o3 — $2.00 / 1M input, $8.00 / 1M output — reasoning-heavy quests/plans; use for important turns.
- o4-mini — (pricing varies; positioned as low-cost reasoning) — snappy logic for RP state/consistency.
- gpt-5 — $1.25 / 1M input, $10.00 / 1M output — strongest general model; overkill for fodder NPCs but great for key scenes.
- gpt-4o-mini — $0.15 / 1M input, $0.60 / 1M output — ultra-cheap text RP at scale.

How to use

- Simply open the NPC standard dialog with right click, and type in local chat using Enter.
- NPC will reply in chat and inside of their dialog window.

The conversation history is saved in a folder (the path shown in "Workshop → Manage Mods → Gear icon" or "Settings → Mod Configuration → Terraria LLM Chat").
You can manually edit or purge select conversations.

NPC awareness and personality

- NPCs remember previous conversations
- NPCs are aware of the time of day
- NPCs are aware of the biome they are in
- NPCs are aware of ongoing world events/disasters.
- NPCs know their likes/dislikes.

Advanced customization

You can delete or modify NPC dialog history in TXT files inside of the Documents\My Games\Terraria\tModLoader\ModData\deon_TLC\ChatLogs folder (guide.txt, pirate.txt etc).

You can customize NPC biographies and behaviors in TXT files inside of the Documents\My Games\Terraria\tModLoader\ModData\deon_TLC\Biographies folder (guide.txt, pirate.txt etc).

For mod-added characters, you want to make a new TXT file in the same folder with the NPC's "Internal Name".
If you delete a vanilla NPC customer entry, it will be re-created automatically with default data.


The exact path is visible in Mod Settings window, as shown on the first screenshot in this mod publication

Example of the default guide bio:
Starter mentor with crafting tips and survival advice.
Likes: Forest biome; likes Merchant, Zoologist.
Dislikes: Ocean biome; dislikes Steampunker, Painter.


Code review

You can find the code of the mod here: https://github.com/DeonUrist/TerrariaLLMChat

Important: You can see full functionality of this mod in the code files. However the mod configuration stores your API key that is visible to the PC users. The author is not responsible if any other software or malware or person finds and uses your API key stored in the mod settings.

All rights reserved. For view only. The mod should not be redistributed in other platforms rather than Steam Workshop.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

I welcome any feedback and suggestions!
 
Last edited:
1.2 is up.

1) Refactored all code and made it more readable, posted it on Github.
2) Made NPC BIOs actually editable (before TModLoader packed TXT files inside of TMOD file, I didnt realize it). Now you can find them in the same place as Chat logs.
 
I've added a setup video to walk you through the configuration and custom NPC prompt process. If anyone has any questions, feel free to ask.

 
Back
Top Bottom