Skip to content

AI Portrait Mod Installation & Getting Started

Welcome to the AI Portrait Mod documentation. This mod brings dynamic, context-aware AI-generated visuals to text-based and interactive fiction games powered by SugarCube.

Currently, the mod officially supports two games:

Whether you want realistic photography or rich anime illustrations, this guide will walk you through every step to get up and runningโ€”even if you have zero prior experience with AI generation tools.

The mod


The Big Picture: How Does This Mod Work?

If you are new to AI generation, the mod might seem complex at first because it offers so many settings. However, the basic principle is very straightforward.

Every time a character portrait or event image is created, two separate systems work together:

graph LR
    A["๐ŸŽฎ Game State<br/>(Characters, Outfits, Scene)"] --> B["๐Ÿ“ Prompt Generator<br/>(The Screenwriter)"]
    B -->|"Detailed Text Prompt"| C["๐ŸŽจ Image Generator<br/>(The Artist)"]
    C -->|"Visual Artwork"| D["๐Ÿ’พ Local Cache"]
    D --> E["๐Ÿ–ผ๏ธ In-Game Display<br/>(Sidebar, Cards, etc.)"]

The Prompt Generator ("The Screenwriter"):

  • Inspects what is currently happening in the game: who the character is, what clothes they are wearing, what room they are in, and their current mood or status.
  • Translates these game details into a rich, structured text description (a prompt) that an image AI can understand.
  • Options include: Fast offline JavaScript rules, local offline LLMs (via LM Studio or Ollama), or cloud LLMs (via OpenRouter).

The Image Generator ("The Artist"):

  • Receives the text description from the Prompt Generator.
  • Uses an image model to draw the actual character portrait or illustration.
  • Options include: Local GPU software (Stable Diffusion WebUI Forge, ComfyUI), cloud APIs (NovelAI, OpenRouter), or a 100% free cloud bridge (Perchance AI).

Smart State Caching:

  • Once an image is generated, the mod stores it inside your browser's local storage, so the images persist even if you close the game.
  • If the character doesn't change, the cached portrait loads instantly with zero wait time and zero GPU/API cost.
  • If the character changes (clothes, location, ...), the mod detects the change and can automatically craft an updated portrait.

Supported Games Overview

The mod uses a shared, high-performance core engine, but tailors its visual injection to the gameplay and layout of each supported game:

Feature Course of Temptation Shady Deals
Player Character (PC) Full dynamic portrait in left sidebar N/A
NPC Portraits Dedicated right sidebar with action cards Replaces static gang members photos & dialogue avatars
Other images Event images, phone messages, clothing, items N/A
Context Injections Outfits, room background, needs, weather, shoes/feet Character archetype, appearance traits, scene dialogue
Dedicated Guide Read Course of Temptation Guide Read Shady Deals Guide

Step 1: Choose Your Generators

Before patching the game, decide which backend generators you want to use.

Overwhelmed by choices?

If you're unsure what your computer can run, read our "Which Setup to Choose?" Guide for 4 clear, tested recommendations ranging from completely free zero-GPU setups to maximum-quality power-user rigs.

1. Choose a Prompt Generator (The Screenwriter)

  • Basic (JavaScript)


    Instant & zero-setup. Built directly into the mod. Combines character tags and clothing descriptions instantly with no external tools required.

    Read Basic Guide

  • OpenRouter LLM


    Smart cloud LLM. Connects to the latest LLM models to write natural, expressive prompts for a fraction of a cent per hour of play.

    Read OpenRouter LLM Guide

  • OpenAI-Compatible / Local LLM


    Generic endpoint. Connects to local language models running in LM Studio or Ollama on your computer, or any 3rd party API endpoint that is OpenAI-compatible. Can be online or 100% offline and uncensored.

    Read Local LLM Guide

2. Choose an Image Generator (The Artist)

  • Perchance AI (Free & Easy)


    Recommended for beginners. Free, unlimited generations running in the cloud via a lightweight Python companion server. No GPU or API keys needed.

    Read Perchance Guide

  • Local Stable Diffusion


    100% offline & private. Runs on your own PC using SD WebUI Forge or AUTOMATIC1111. Requires a dedicated GPU (6GB+ VRAM).

    Read Local SD Guide

  • ComfyUI Integration


    For power users. Integrates custom ComfyUI node workflows directly into the game. Fast, flexible, and supports on-the-fly workflow switching.

    Read ComfyUI Guide

  • NovelAI API


    Cloud anime specialist. High-speed, beautiful anime illustrations via the official NovelAI subscription service. No GPU needed.

    Read NovelAI Guide

  • OpenRouter Image API


    Cloud pay-per-generation. Access bleeding-edge diffusion models like Flux.1 without installing heavy local software.

    Read OpenRouter Guide

  • External Tool Hand-off


    Generate anywhere. Copy in-game prompts, generate using any external tool or website (Midjourney, DALL-E, Fooocus, etc.), and paste (Ctrl+V) or drop images right into the game.

    Read Hand-off Guide


Step 2: Install the Mod with Kitty Patcher

The mod is distributed as a .mod file and is installed using Kitty Patcher, an automated patching tool for SugarCube games.

Prerequisites

  1. The Game HTML File: CourseOfTemptation.html or Shady Deals.html
  2. Kitty Patcher: Download the Kitty Patcher package (KittyEcosystem.v1.zip or v0.7.x) from the Google Drive.
  3. The Mod File: Download the latest .mod release file matching your game from the mod release page.

Installation Instructions

  1. Locate your game folder: Open the folder where the game html file is located.
  2. Extract Kitty Patcher: Extract the Kitty Patcher executable for your operating system (Windows, Linux, or macOS) into your game folder.
  3. Create a mods/ subfolder: If it doesn't already exist, create a folder named mods inside your game folder.
  4. Place the mod file: Copy AI_Portrait_Mod-xxx.mod into the mods/ folder.
  5. Run Kitty Patcher:
    • Windows: Double-click KittyPatcher.exe (or KittyToolbench.exe).
    • Linux / macOS: Open a terminal in the game folder and run ./KittyPatcher (make sure it has execute permissions: chmod +x KittyPatcher).
  6. Check output: The patcher will create xxxxxxx.patched.html. Open this file in your web browser to play!

Screenshot: Patcher Folder Layout

Expected Patcher Output / Warning

KittyPatcher may report Warned mods (1) in ModPatchLog.txt. This is normal and expected. As long as Failed: 0 is reported, the patch was applied successfully.

Never delete the original game HTML

Keep your original CourseOfTemptation.html safe! Kitty Patcher always requires the unmodified original file whenever you re-patch or upgrade to newer mod versions.


Step 3: Setup Wizard & First Launch

When you first launch your patched game, configuring the mod is simple thanks to the built-in interactive Setup Wizard.

Launching the Wizard

  1. Open CourseOfTemptation.patched.html in your browser.
  2. Start a new game or load an existing save.
  3. Once character creation is complete and you are in the game, a glowing welcome banner appears at the top of the left sidebar:

Screenshot: Setup Wizard

  1. Click ๐Ÿš€ Launch Setup Wizard to begin.
  1. Open Shady Deals.patched.html in your browser.
  2. Start or load your game.
  3. Click the AI MOD SETTINGS button in the navigation menu / sidebar to open Settings, then click ๐Ÿง™ Launch Setup Wizard.

Screenshot: Setup Wizard

The 6-Step Wizard Walkthrough

The Setup Wizard walks you through initial configuration in less than two minutes:

Screenshot: Setup Wizard Modal

  1. Welcome: Introduction and links to online documentation.
  2. Prompt Refiner: Pick your prompt builder (Basic JS, OpenRouter LLM, or OpenAI-Compatible Local LLM).
  3. Image Engine: Choose your image generation backend (Perchance, Local SD, ComfyUI, NovelAI, or OpenRouter Image).
  4. Provider Setup: Configure your backend URL, API keys, or models. Includes a live Test Connection button so you know everything works before continuing.
  5. Automation & Context: Set your preferred generation modes (Automatic, Initial Only, Manual with refresh button, or Disabled) and toggle contextual elements like room backgrounds, needs, and weather.
  6. Style & Finish: Choose your default aesthetic style preset (e.g., Realistic Photo, Anime 2D, Candid Snapshot, Retro Polaroid), run a live test generation, and finish!

Re-running the Wizard Anytime

You can re-launch the Setup Wizard at any time by opening the Settings Panel (โš™๏ธ) and clicking ๐Ÿง™ Launch Setup Wizard.


Step 4: Settings Panel Overview

You can fine-tune every detail of the mod via the in-game Settings Modal (click the โš™๏ธ gear icon at any time).

Screenshot: In-game UI Overview

Screenshot: In-game UI Overview

The settings dialog is split into 5 organized tabs:

  • Generation Domains: Control how different visuals are produced:
    • Automatic: The mod generates a portrait whenever changes occur (outfits, rooms, encounters).
    • Initial Only: Generates an initial image automatically on first encounter, then reuses the portrait without generating on room or outfit changes. You can still manually refresh anytime.
    • Manual: Adds a manual refresh button (๐Ÿ”„) to each portrait so you only generate when you want to.
    • Disabled: Hides the visual component entirely.
  • Interface & Display: Options like expanding NPC portrait cards by default in Course of Temptation.
  • Context Injections: Toggle whether room location, weather, physical needs, and shoes/feet are factored into prompt descriptions.
  • Deterministic Seeds (Optional): Freeze text prompt generation (LLM) and/or image generation to fixed numeric seeds for 100% reproducible outputs, or leave empty (-1) for randomized generation.

General Settings

  • Select your active prompt engine (Basic JS, OpenRouter LLM, or OpenAI-Compatible).
  • Choose your Image Style Preset (11 unique aesthetics including Anime, Photorealistic, Retro Polaroid, and Watercolor).
  • Configure Pony quality tags and negative prompt preferences. Read General Prompt Settings for details.

Prompt Settings

  • Switch between Perchance, Local SD, ComfyUI, NovelAI, and OpenRouter.
  • Configure endpoints, API keys, checkpoint models, sampling steps, CFG scale, and VRAM management options.

Image Settings

  • Configuration Backup / Restore: Export your full mod settings to a .json file, or load a previously saved configuration.
  • Export Generated Images (.zip): Export every portrait saved in your cache as an organized .zip file archive (player/, NPCs/, events/, clothes/), with optional accompanying .txt prompt files.

Import Export Settings

  • Built-in diagnostic suite that tests connectivity to your image and prompt backends in one click.
  • Measures latency, lists detected models, verifies CORS settings, checks deterministic seed compatibility, and gives step-by-step troubleshooting suggestions if a test fails.

Doctor Diagnostics


Next Steps

Now that your mod is installed and configured: