PDA

View Full Version : Integrating Claude AI into Fantasy Grounds Unity — a GM tool for real-time NPC dialog



judesudbury
April 25th, 2026, 00:31
I'm currently running a Curse of Strahd campaign. Like a lot of GMs I have a busy life, we aim for weekly sessions, and preparation time is always under pressure. I've been using AI (Claude specifically) heavily for prep: developing NPCs, writing scene descriptions, planning encounters, and also during sessions to generate dialogue and narration on the fly.

The problem was workflow. I was running the AI in a separate browser window, manually copying across what the players were saying, what had just happened in combat, what the current scene looked like. Keeping it contextually aware of a live session is genuinely difficult when you're also trying to run the game. I kept finding myself either neglecting the AI because I was too busy GMing, or breaking immersion to type context updates.

Worth mentioning that I run all my games through the FGU chat window. We play online, and keep a Discord open purely for out of game chat and clarification, so everything that matters happens in FGU chat. That turned out to be important to how this solution works.

So I set about integrating Claude directly into FGU.

What it does

The bridge has two components: a small FGU Lua extension and a Python server running locally on your machine. Here's how they work together.

The Python server monitors your campaign's `chatlog.html` continuously. Every piece of player dialogue, every attack roll, every turn marker that appears in FGU is silently fed into Claude's context in real time. No manual updating. Claude is watching the session as it unfolds.

When you want Claude to do something, you type a GM slash command in the FGU chat box. Players never see these. The command is picked up by the Python server, sent to the Anthropic API with all the accumulated session context, and the response is copied to your clipboard automatically. Ctrl+V into the chat box, edit if needed, and hit Enter.

The commands

/describe the party approaching Old Bonegrinder at dusk — posts a sensory scene description to chat
/npctalk (Morgantha) how does she respond to Ireena's accusation? — generates Morgantha's spoken dialogue only, ready to paste while talking as her character
/npcaction (Ireena) she's just seen the children in the cage — generates physical reaction and body language only, no dialogue
/combatsummary — reads the recent attack rolls and actions from the chatlog and writes a vivid narrative recap
/claude what leverage does Morgantha have if the party attacks? — private GM query, whispered to you only, players never see it
/setscene the party has reached the upper floor — updates Claude's scene context
/claudereset — clears conversation history for a fresh start

Context and cost

Claude's awareness of the session builds continuously throughout play at no cost: the chatlog monitoring and context accumulation involves no API calls. You only pay when you issue a command. Each call sends your campaign notes (two markdown files you prepare before the session, one for campaign history and one for the current session's scenes and NPCs) plus the accumulated session history to that point.

Cost control is straightforward. The default model in the config is Claude Haiku, which is Anthropic's fastest and cheapest model. A full session, including campaign notes, live chatlog context, and however many commands you fire, will likely cost no more than a couple of dollars, probably less. That said, cost does depend on session length, how detailed your notes files are, and how many commands you send. Switching to Sonnet is one line in a config file if you want higher quality responses for a particular session.

The repo

Everything is at https://github.com/heyjudeuk/fgu-claude-bridge: the README covers installation step by step including the FGU 5.x extensions folder location, which differs from older versions. You'll need a free Anthropic API account to get a key, loaded with at least $20 of credit and Python installed on your machine. That's it.

It was built and debugged against FGU 5.1.8.

Happy to answer questions. It's made a real difference to how I run sessions and I hope it's useful to others.

claedawg
April 25th, 2026, 11:52
can this be "reworked" to connect to a ChatGPT account?

judesudbury
April 25th, 2026, 14:42
Good question. Technically yes, the Python server could be adapted to call the OpenAI API instead of Anthropic's, as the two are broadly similar in how they work. The important thing to understand, however, is that what the bridge connects to is an API, not an account. This is a meaningful distinction. When you use ChatGPT in a browser, it maintains a conversational session for you, remembers previous chats, and has a persistent interface. The API is completely different: it is stateless, meaning every single call starts from zero with no memory of anything that came before. There is no such thing as "your ChatGPT account" at the API level. You are simply sending text and receiving text back, billed per token.

This means the bridge works identically regardless of which AI provider you use. The session context, the NPC memory, the awareness of what just happened at the table — none of that comes from the AI provider. All of it is managed locally by the Python server, which builds up context from the chatlog, campaign and session notes markdown files, and sends it with every call. The AI itself is essentially stateless plumbing.

So there is no advantage to using ChatGPT over Claude here, and there is at least one disadvantage: Claude's prompt caching feature (which the bridge uses) reduces costs significantly for repeated calls with the same campaign notes, and that is Anthropic-specific.

If you want to get started, head to platform.anthropic.com, create an account (free), and add credits. The minimum top-up is $20, which at typical usage rates should last you a considerable number of sessions. You are not signing up for a subscription: you simply buy credits and spend them as you go.

anstett
April 25th, 2026, 15:08
This would be effectively a new subscription to add to FG like Syrinscape is.

So how much per month to pay for the tokens used?
Token costs are going up and there is no such thing as free AI usage.

It is always a 'do I have more time or more money' consideration.

judesudbury
April 26th, 2026, 09:49
It is not a subscription. There is no monthly fee, no recurring charge, and no minimum commitment beyond an initial credit top-up on the Anthropic platform. You pay only for what you use, and usage is measured in tokens: roughly the amount of text sent and received per API call.

At typical usage for this bridge, running a three hour session with Claude Haiku (the default, cheapest model) will cost somewhere between $0.02 and $0.10 depending on how detailed your campaign notes are and how many commands you send. That $20 initial credit will realistically last many sessions, possibly an entire campaign.

The comparison to Syrinscape is not quite right. Syrinscape charges a monthly subscription regardless of whether you use it. The FGU-Claude bridge charges only when you make a request, and the per-request cost is very small. And anyway, for me at least, having a cheap to run and integrated AI is far more useful for me as a GM than ambient sound effects and music.

On the broader point about time versus money: absolutely true, and it is a legitimate consideration for everyone. But the economics here are unusually favourable. The time saved in session prep and live narration is measured in hours. The cost is measured in cents. For most GMs that ratio is comfortable, but you are right that it will not suit everyone and nobody should feel obligated.

Token costs have generally been going down over time as models improve and competition increases, not up. Haiku today costs a fraction of what comparable models cost two years ago. That trend may not continue indefinitely, but it is the current direction of travel.

I put this together because I thought it might be useful to someone; I'm not a sales rep for Anthropic!

anstett
April 26th, 2026, 14:39
Thanks for clarifying.

I tend to not use generative LLMs because of copyright issues.
What I do hear from many others in the field is that they run out of tokens quickly and are feeling resentful they have to pay for more.

Trenloe
April 26th, 2026, 16:48
This is very interesting @judesudbury - thanks for putting this together.

I've recently started dabbling with Claude, firstly because it was the recommended LLM to use for Dungeon Matters excellent AI driven adventures (check them out on Drive Thru RPG if you're interested in playing some solo Sherlock Holmes like investigative adventures - they're very good). From using Claude for the AI Solo adventures, I've started using it for some adventure prep - bouncing around ideas for key encounters and storylines - and I've found it excellent for that too. So, I'm very interested in what can be done with integration to FG. I'm starting to give this a try - the minimum financial commitment is $5 to give it a go (select "Other" in the payment screen). Unfortunately, most of my adventures are ran using voice, or I use FG at the table for face-to-face games, so the data to draw on from the FG chat is quite limited - some location descriptions and dice rolls. But I'll try to get more information into chat and see what I could do with this. I may investigate adding a button to a story entry that could allow the data in a specific location/story section to be included in a query and see if that adds more value for the way I run my games in FG.

Thanks again for making this available and discussing how it all works.

Tempered7
April 26th, 2026, 17:06
...Unfortunately, most of my adventures are ran using voice, or I use FG at the table for face-to-face games, so the data to draw on from the FG chat is quite limited - some location descriptions and dice rolls.

I dont know if Discord bots can do that but there are Speech-to-Text software that can transcribe spoken words into text and print it to their own window.
If a discord bot or FG extension can be integrated with this functionality, and if judesudbury's software can draw info from there, it can also involve narration/dialogue.
Win 11 has something called Voice Typing for example.

Trenloe
April 26th, 2026, 17:28
I use SessionKeeper (https://www.sessionkeeper.ai/) which does a great job of extracting information from our session conversations and creating wiki entries and session summaries. I'll investigate adding information from SessionKeeper into the session_notes.md (markdown) file used as part of this integration and see how that comes out.

Tempered7
April 26th, 2026, 19:56
I use SessionKeeper (https://www.sessionkeeper.ai/) which does a great job of extracting information from our session conversations and creating wiki entries and session summaries. I'll investigate adding information from SessionKeeper into the session_notes.md (markdown) file used as part of this integration and see how that comes out.

Oh, this site turns session audio into wiki-style pages. 0_o
Way better than speech to (wall-of-)text, I wonder what will they invent next.
Ah but its subscription based.

Btw, how do the Sherlock AI prompts and the adventures unfold? Do they deliver a smooth and non-hallucinating AI game?
They also note NotebookLM among the best 3 AIs, so I think I c an also use them.

Trenloe
April 26th, 2026, 20:08
Btw, how do the Sherlock AI prompts and the adventures unfold? Do they deliver a smooth and non-hallucinating AI game?
I've played the first and third adventures Dungeon Matters have created and I've been very impressed with them both. You get a lot out of it, especially if you engage - speak to NPCs, look at specific things, etc..


They also note NotebookLM among the best 3 AIs, so I think I c an also use them.
Dungeon Matters don't appear to mention NotebookLM, and I'm not sure how well that would work with this as it will tend to use the data from the 15,000 word prompt and not expand on that data too much. I've used Claude Opus very successfully, which expands on the base prompt data significantly and you can get a lot of use with the free account - especially if you play outside of busy times. EDIT: A quick check of NotebookLM and it works quite well, not as verbose or descriptive as Claude (to be expected) but seems to work OK with a quick test. Try different AI tools and see which one you prefer.

Tempered7
April 26th, 2026, 21:10
I've played the first and third adventures Dungeon Matters have created and I've been very impressed with them both. You get a lot out of it, especially if you engage - speak to NPCs, look at specific things, etc..

Dungeon Matters don't appear to mention NotebookLM, and I'm not sure how well that would work with this as it will tend to use the data from the 15,000 word prompt and not expand on that data too much. I've used Claude Opus very successfully, which expands on the base prompt data significantly and you can get a lot of use with the free account - especially if you play outside of busy times. EDIT: A quick check of NotebookLM and it works quite well, not as verbose or descriptive as Claude (to be expected) but seems to work OK with a quick test. Try different AI tools and see which one you prefer.



How to Play Sherlock Solo AI™
Copy and paste the included prompt into your favorite paid AI model: Claude, ChatGPT, Gemini, etc.


Oh, I saw the quote above in Sherlock AI and thought NotebookLM is Gemini.
Thanks for testing it. :) Maybe with some changes it also become more descriptive. Or I create a free Claude account and check it.
My previous tests with NotebookLM as AI GM failed because of the problem as described in Dungeon Matters website [too vague prompts + too long rulebooks].
And of course, I didnt add it any adventure modules because I dont have any in PDF, only rulebooks.
EDIT: Im eyeing on Waterdeep: Dragon Heist to explain how to play it solo with Mythic to add the slide-deck guide into my Mythic Article. I'd love to test it for this too.

15k words prompt... Just checked it, notebookLM has 10k characters in the prompt box. Hmm, problem.

Trenloe
April 26th, 2026, 21:18
15k words prompt... Just checked it, notebookLM has 10k characters in the prompt box. Hmm, problem.
Upload it as a document file (source) then say "start the game".

Tempered7
April 26th, 2026, 21:21
Upload it as a document file.
Ah right. And then I can use the prompt to execute the rules in the document.
And make 1 notebook for 1 adventure and add nothing irrelevant.

LordEntrails
April 27th, 2026, 01:27
This is awesome. Thanks for putting this together and making it available. Like Trenloe, my games are almost all voice based, so until someone works out the speech to text part I'll be anxiously awaiting :)

One question I do have, is how long does it take for Claude to respond? My experience with Claude (private instance) is it usually takes several minutes for me to get responses back. Now I am using Claude Opus and often going through one or more MCP servers to have it do things.

Trenloe
April 27th, 2026, 22:52
One question I do have, is how long does it take for Claude to respond? My experience with Claude (private instance) is it usually takes several minutes for me to get responses back. Now I am using Claude Opus and often going through one or more MCP servers to have it do things.
The bridge_config.json file allows some fine tuning - which Claude model to use, how many tokens etc.. For the standard setup (400 tokens, claude-haiku-4-5 model) the response to my queries is very quick - 1 second or less. Using 800 tokens and claude-sonnet-4-6 was about 3-4 seconds on average. 1600 tokens and claude-opus-4-7 - took around 15 seconds to response. I used queries like /claude what do you recommend for the next encounter?

LordEntrails
April 27th, 2026, 23:07
The bridge_config.json file allows some fine tuning - which Claude model to use, how many tokens etc.. For the standard setup (400 tokens, claude-haiku-4-5 model) the response to my queries is very quick - 1 second or less. Using 800 tokens and claude-sonnet-4-6 was about 3-4 seconds on average. 1600 tokens and claude-opus-4-7 - took around 15 seconds to response. I used queries like /claude what do you recommend for the next encounter?
That's awesome. Thanks.

Trenloe
May 1st, 2026, 01:49
I'm planning on using this in my Pathfinder 2 Kingmaker game tomorrow evening. I've been doing some setup and testing with /npctalk and /npcaction

https://www.fantasygrounds.com/forums/attachment.php?attachmentid=67241

Tempered7
May 1st, 2026, 09:29
Upload it as a document file (source) then say "start the game".

In between rests, I finished EP1 of Sherlock with the exact Prompt in the document.
I used Gemini [Noltebook LM fails] instead of Claude, and it worked like a charm.
The author found a great way to balance restrictions and trackers/to-do for the AI.
But I played it by choosing multiple-choice options. At some point I started write my own by combining them in a strategic action order.

Next, I will try to go out of the script and try to ask you-know-who [no spoilers] some questions and see if the AI can answer them in character.
Note: You-know-who knew that my Spell Points were depleted and mentioned it in-character by itself.

I think if I apply a similar promt and summarize 3.5 ed rules like in the SRD, an easy 3.5 ed adventure can be played with it.


I'm planning on using this in my Pathfinder 2 Kingmaker game tomorrow evening. I've been doing some setup and testing with /npctalk and /npcaction

Can't wait for how it goes!

Trenloe
May 1st, 2026, 15:54
The author found a great way to balance restrictions and trackers/to-do for the AI.
But I played it by choosing multiple-choice options. At some point I started write my own by combining them in a strategic action order.

Next, I will try to go out of the script and try to ask you-know-who [no spoilers] some questions and see if the AI can answer them in character.
You definitely get what you put in. If you're looking for a more detailed experience, and not just a quick game, expand on your answers and keep scenes going if you want to. Instead of simply selecting the option of going to the scene of the crime (for example), say that you'll leave your apartment, buy some morning papers before hailing a cab to the scene of the crime. On the way look through the newspapers you've just bought checking for any updates on the current investigation. You'll still get a good adventure experience by basically following the prompts, but you'll get so much more if you expand on your activities. One of my friends kept the conversation going at the end of the first scene (the card club) and had a very interesting interaction with the folks there.

One of Dungeon Matters most recent adventures, based on the Rats in the Walls, is less "prompty" (unless you ask) and is more "what do you want to do?" rather than "here are your main options". I'm sure their adventures will only improve over time.

Tempered7
May 1st, 2026, 16:37
One of Dungeon Matters most recent adventures, based on the Rats in the Walls, is less "prompty" (unless you ask) and is more "what do you want to do?" rather than "here are your main options". I'm sure their adventures will only improve over time.

I'll definitely try the detailed approach by starting over EP1, it sounds like "living" a movie!
This is already at peak level of Solo AI experience that I didnt see anywhere else, but if anyone can top that, it would be either Laerun or Dungeon Matters.
I compared this short episode to every other free Solo AI website that I tried so far and from frustrating to meh to ok, none of them sticked with me.
Even the ones with images... I produced "scene images" from gameplay results in Gemini and it is more personal this way.
I think I found how to play the [text part of] Ultimate Undermountain as a showcase to all my solo methods.

Haerilis
May 12th, 2026, 14:32
That’s a great extension. I modified it a little with the help of Gemini, and it also works if you use a Gemini API key. Or, if you’re like me and don’t want to pay anything, it also works with a local LLM running on port 5001, a simple Koboldcpp + Stheno 8B model setup. It whispers into the FGU chat box just fine. You just have to rewrite the .md files with your campaign information too.

RosenMcStern
May 17th, 2026, 17:25
Is this thing going on? I tried to contact the OP but no answer so far.

We have developed something similar for ROL Assistant, although it does more (it reads the combat tracker and any record in the database), and I find the user feedback very interesting. I was afraid people would react negatively to the necessity of installing software on the local machine, but it seems this is not the case.

Trenloe
May 17th, 2026, 23:08
Is this thing going on?
The code is available in post #1 and I've been using it a few times - see post #16 and #18. So, yes, it's "going on" in terms of the code's available and can be used.