Skip to content

Q-efx/fvtt-runware-imagegen

Repository files navigation

Runware AI Image Generator for FoundryVTT

A FoundryVTT module that integrates Runware AI image generation directly into actor sheets. Generate high-quality AI images for your NPCs and player characters with ease!

Features

  • 🎨 Easy Access: Generate images directly from actor sheets with a button in the header bar (next to the prototype token button)
  • 🤖 Multiple AI Models: Support for various AI models including Stable Diffusion, SDXL, and custom models from CivitAI
  • 🧰 GM Presets: Game Masters can curate shared presets (model, LoRA, VAE, embeddings) for players to apply instantly
  • 🎯 Advanced Controls:
    • Positive and negative prompts
    • Adjustable image dimensions (256x256 to 2048x2048)
    • LoRA model support for style adaptation
    • CFG Scale, inference steps, and seed control
    • Generate multiple images at once (1-4) with an in-app gallery to pick your favorite result
  • 💾 Organized Storage: Portraits and token variants are automatically saved to modules/runware-imagegen/images/actor-name/ (tokens live in the /tokens subfolder)
  • 🖼️ Quick Application: Instantly apply the chosen render as the actor portrait, with multi-image preview selection when multiple results are generated
  • 🪄 Token Ready: Backgrounds are removed automatically via Runware RMBG v2.0 and saved as autorenamed token images alongside the portrait
  • 🔐 Secure: API keys stored securely in world settings

Installation

Automatic Installation (Recommended)

  1. In FoundryVTT, go to Add-on Modules
  2. Click Install Module
  3. Search for "Runware AI Image Generator"
  4. Click Install

Manual Installation

  1. Download the latest release from the [GitHub repository]
  2. Extract the zip file into your FoundryVTT Data/modules directory
  3. Restart FoundryVTT
  4. Enable the module in your world's Module Management settings

Configuration

1. Get a Runware API Key

  1. Visit Runware AI
  2. Sign up for an account
  3. Navigate to your API settings
  4. Generate an API key

2. Configure the Module

  1. In FoundryVTT, go to SettingsConfigure SettingsModule Settings
  2. Find Runware AI Image Generator
  3. Enter your API key in the Runware API Key field
  4. Optionally configure default settings:
    • Default Model: The AI model to use by default (e.g., runware:100@1)
    • Image Width: Default width for generated images (512px recommended)
    • Image Height: Default height for generated images (512px recommended)
    • Number of Results: How many images to generate per request (1-4)

Usage

Basic Image Generation

  1. Open an Actor Sheet for any NPC or Character
  2. Click the "Generate Image" button (🎨 palette icon) in the top bar next to the prototype token button
  3. Enter a Prompt: Describe the image you want to generate
    • Example: "A wise elderly wizard with a long white beard, wearing blue robes, fantasy art style"
  4. Select a Model: Choose from the suggested models or enter a custom model ID
  5. Click "Generate Image"
  6. Wait for Generation: The module will display a loading indicator
  7. Review the Results: If multiple images were requested, a gallery lets you preview and choose your favorite; the selected image is then shown in a confirmation dialog
  8. Confirm or Save: The chosen portrait is stored in modules/runware-image-generator/images/[actor-name]/ and a matching background-free token is generated automatically in modules/runware-image-generator/images/[actor-name]/tokens/

Advanced Options

Click Show Advanced Options in the dialog to access:

LoRA Models

Add style-specific fine-tuning to your images:

  • LoRA Model: Enter a LoRA model ID (e.g., civitai:12345@67890)
  • Weight: Adjust the influence of the LoRA (0.0 - 2.0, default 1.0)

Generation Parameters

  • Inference Steps: More steps = higher quality but slower (20-50 recommended)
  • CFG Scale: How closely to follow the prompt (7.0 recommended)
  • Seed: For reproducible results, enter a specific number

Image Dimensions

  • Adjust width and height independently (256-2048px)
  • Use multiples of 64 for best results
  • Square images (512x512) typically work best

Finding Models

Built-in Suggestions

The module includes quick-select buttons for popular models:

  • Stable Diffusion 1.5 (runware:100@1)
  • Stable Diffusion XL (runware:101@1)
  • Realistic Vision (civitai:4201@130072)
  • DreamShaper (civitai:4384@128713)

Custom Models

You can use any model from:

  • Runware Models: Format runware:MODEL_ID@VERSION
  • CivitAI Models: Format civitai:MODEL_ID@VERSION_ID

Visit CivitAI to browse thousands of community models.

File Organization

Generated images are saved in an organized directory structure:

Data/
  modules/
    runware-image-generator/
      images/
        warrior_character/
          image_1.png
          image_2.png
          image_3.png
          tokens/
            token_1.png
        npc_shopkeeper/
          image_1.png
          image_2.png
          tokens/
            token_1.png
  • Actor names are sanitized (special characters replaced with underscores)
  • Images are numbered sequentially
  • Images persist across sessions
  • You can access these files directly via the FilePicker
  • Background-removed token images are stored alongside portraits under the tokens/ subdirectory

Prompt Tips

Good Prompts

  • Be specific about appearance, style, and mood
  • Include details like clothing, accessories, lighting
  • Mention art style (e.g., "fantasy art", "realistic", "anime style")
  • Use descriptive adjectives

Example Good Prompt:

A fierce female warrior with red hair in a ponytail, wearing silver plate armor
with gold trim, holding a flaming sword, dramatic lighting, fantasy art style,
detailed face, heroic pose

Negative Prompts

Use negative prompts to avoid unwanted elements:

  • Common exclusions: blurry, low quality, deformed, ugly, text, watermark
  • Style exclusions: cartoon, anime (if you want realistic)
  • Content exclusions: Specific unwanted objects or features

Prompt Weight Syntax

You can emphasize parts of your prompt:

  • Use parentheses: (important detail:1.2) increases weight
  • Use brackets: [less important detail:0.8] decreases weight

Troubleshooting

"Please configure your Runware API key"

Solution: Go to Module Settings and enter your valid Runware API key.

"Image generation failed"

Possible causes:

  • Invalid API key
  • Insufficient credits in your Runware account
  • Invalid model ID
  • Network connection issues

Solutions:

  • Verify your API key is correct
  • Check your Runware account balance
  • Try a different model from the suggestions
  • Check browser console for detailed error messages

Images not saving

Possible causes:

  • Insufficient permissions on the Data directory
  • File path issues

Solutions:

  • Ensure FoundryVTT has write permissions to the Data folder
  • Check browser console for specific errors
  • Try generating with a different actor name

Button not appearing

Possible causes:

  • Module not enabled
  • Not viewing as actor owner
  • Sheet template incompatibility

Solutions:

  • Verify module is enabled in Module Management
  • Check that you have OWNER permission on the actor
  • Try with a different actor sheet type

API Integration

This module uses the Runware SDK to communicate with the Runware API. The SDK is loaded dynamically via CDN.

Key Features Used

  • Text-to-Image Generation: Primary image generation
  • Base64 Output: Images are received as base64 for local saving
  • Multiple Models: Support for Runware and CivitAI models
  • LoRA Support: Style adaptation via LoRA models
  • Advanced Parameters: CFG Scale, steps, seed control
  • Background Removal: Automated RMBG v2.0 workflow to create transparent token assets

Credits

License

This module is released under the MIT License. See LICENSE file for details.

Support

For issues, feature requests, or questions:

  • GitHub Issues: [Repository Issues Page]
  • FoundryVTT Discord: Look for the module support channel

Changelog

Version 1.1.0

  • Added multi-result preview gallery so users can pick the best generation before saving
  • Automatic background removal via Runware RMBG v2.0 with token images saved alongside portraits
  • Enlarged image preview dialog for easier inspection of generated art
  • Introduced GM-managed presets covering model, LoRA, VAE, and embeddings shared with players

Version 1.0.0

  • Initial release
  • Basic text-to-image generation
  • Actor sheet integration
  • Multiple model support
  • LoRA support
  • Advanced parameter controls
  • Automatic image saving and organization
  • Quick portrait application

Roadmap

Future planned features:

  • Image-to-image generation
  • Batch generation for multiple actors
  • Image history browser
  • Preset prompt templates
  • Style library

Enjoy creating amazing character art with AI! 🎨✨

About

An AI image generator for NPC and player images, uses the Runware AI API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors