Blog Verification

The Death of the Static NPC: Hosting Generative Godot Games

February 12, 2026 • PrevHQ Team

We’ve all been there. You spend 3 weeks hacking together a Godot prototype where the NPCs actually talk to you. You hook up a local Python server running Ollama or LangChain. It feels like magic. The bartender remembers your order. The villain taunts you specifically about that time you tripped over a chair.

Then, you try to send it to a friend.

“Here, just git clone this repo, create a virtual environment, install these 14 dependencies, download this 4GB model weight, start the server on port 8000, and then run the Godot executable.”

They never play it.

The “Itch.io Gap”

Game jams and indie showcases run on web builds. If your game isn’t a link, it doesn’t exist.

Godot 4.x has an incredible HTML5 (WASM) exporter. It turns your game into static files you can drop on Itch.io or GitHub Pages. But there is a catch: Itch.io is static hosting. It doesn’t run Python. It doesn’t run Node.js. It doesn’t run your AI backend.

So you are stuck. You either:

  1. Strip the AI: Go back to static dialogue trees (boring).
  2. Rent a VPS: Spin up a DigitalOcean droplet, configure Nginx, set up SSL for Secure WebSockets (WSS), and pay $10/month even if no one plays.
  3. Give Up: The prototype dies on your hard drive.

Generative Games Need Ephemeral Infrastructure

The problem is that your game is no longer just a “client.” It’s a distributed system. The “Game Logic” is split between the Godot engine (rendering/input) and the Python backend (intelligence).

This is exactly what we built PrevHQ for. We don’t just host static sites. We host Ephemeral Containers that spin up when a user visits your link, and spin down when they leave.

Here is how you can host your Generative Godot game in 30 seconds.

The Architecture

We are going to build a simple “Echo” game where Godot sends text to Python, and Python (the “AI”) sends it back.

1. The Godot Client (GDScript)

In your Godot project, create a WebSocket client. Note that for Web exports, you MUST use wss:// (Secure WebSockets) if your site is HTTPS (which PrevHQ provides automatically).

extends Node

var socket = WebSocketPeer.new()

func _ready():
    # Connect to the backend URL provided by PrevHQ environment variable or hardcoded for testing
    # In production, this will be your PrevHQ backend URL
    socket.connect_to_url("wss://your-backend-url.prevhq.app/ws")

func _process(delta):
    socket.poll()
    var state = socket.get_ready_state()
    if state == WebSocketPeer.STATE_OPEN:
        while socket.get_available_packet_count():
            var packet = socket.get_packet()
            var message = packet.get_string_from_utf8()
            print("AI Said: " + message)

func send_to_ai(text):
    socket.put_packet(text.to_utf8_buffer())

2. The Python Backend (FastAPI)

Create a simple server.py using FastAPI. This handles the WebSocket connection.

from fastapi import FastAPI, WebSocket

app = FastAPI()

@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    while True:
        data = await websocket.receive_text()
        # Imagine a call to LangChain or Ollama here
        response = f"I heard you say: {data}" 
        await websocket.send_text(response)

3. The PrevHQ Config

This is the magic part. Instead of a Dockerfile, just tell PrevHQ what to run. Create a prevhq.json in your repo root.

{
  "build": {
    "command": "godot --headless --export-release 'Web' index.html",
    "output": "dist"
  },
  "run": "uvicorn server:app --host 0.0.0.0 --port $PORT"
}

Wait, what just happened?

  1. Build Phase: We export your Godot game to HTML5.
  2. Run Phase: We start your Python server.
  3. Routing: PrevHQ serves the static files (the game) on / and proxies WebSocket requests to your Python server automatically.

Why This Changes Everything

When you deploy this to PrevHQ:

  1. Instant Links: You get a URL like my-game-preview-xyz.prevhq.app.
  2. No Server Costs: If no one is playing, no containers are running. You pay $0.
  3. Real AI: You can pip install anything. LangChain, OpenAI, HuggingFace.

The era of the “Static NPC” is over. Your game characters should be as alive as your players. Don’t let infrastructure hold back your creativity.


FAQ

Q: Can I use this for multiplayer games too? A: Absolutely. This architecture works perfectly for authoritative game servers written in Godot (Headless mode) or Python.

Q: How do I handle WebSocket latency? A: PrevHQ runs on the edge. Connect to the region closest to your user. For AI text generation, the bottleneck is usually the LLM inference (tokens/sec), not the network.

Q: Does this work with C# Godot projects? A: Yes. Our build environment supports .NET 8. Just ensure your .csproj is configured for Web export.

Q: Is it expensive? A: PrevHQ is designed for previews and prototypes. You pay for active compute time. If your game goes viral, we scale with you, but for development, it’s often free tier eligible.

← Back to Blog