Build-tool for bulk-generating AI images.
Find a file
Konstantin Fickel 61f30a8bb1
All checks were successful
Continuous Integration / Build Package (push) Successful in 31s
Continuous Integration / Lint, Check & Test (push) Successful in 50s
fix: don't pass response_format to gpt-image-* models
gpt-image-* models return b64_json by default and reject the
response_format parameter with a 400 error. Only pass it for
DALL-E models which default to url.
2026-02-15 14:47:52 +01:00
.forgejo/workflows ci: add forgejo pipeline with nix flake check and build 2026-02-14 10:45:28 +01:00
bulkgen fix: don't pass response_format to gpt-image-* models 2026-02-15 14:47:52 +01:00
nix feat: add home-manager module for programs.bulkgen.enable 2026-02-14 10:33:33 +01:00
tests refactor: use project-named state file and store prompt/params directly 2026-02-15 13:56:12 +01:00
.envrc build: set up project for bulkgen 2026-02-13 19:32:47 +01:00
.gitignore refactor: use project-named state file and store prompt/params directly 2026-02-15 13:56:12 +01:00
.python-version build: set up project for bulkgen 2026-02-13 19:32:47 +01:00
CLAUDE.md refactor: switch to basedpyright, remove pydantic-settings 2026-02-13 20:25:28 +01:00
devenv.lock build: set up project for bulkgen 2026-02-13 19:32:47 +01:00
devenv.nix refactor: switch to basedpyright, remove pydantic-settings 2026-02-13 20:25:28 +01:00
devenv.yaml build: set up project for bulkgen 2026-02-13 19:32:47 +01:00
flake.lock feat: add git-hooks.nix pre-commit checks to flake 2026-02-14 10:42:33 +01:00
flake.nix feat: add git-hooks.nix pre-commit checks to flake 2026-02-14 10:42:33 +01:00
LICENSE.md docs: add MIT license 2026-02-14 10:48:13 +01:00
main.py feat: wire entry point to typer CLI app 2026-02-13 20:14:37 +01:00
pyproject.toml feat: add GPT-5 generation models to OpenAI providers 2026-02-15 14:42:43 +01:00
pyrightconfig.json refactor: switch to basedpyright, remove pydantic-settings 2026-02-13 20:25:28 +01:00
README.md docs: add home-manager installation instructions to README 2026-02-14 11:19:15 +01:00
renovate.json chore: Configure Renovate (#1) 2026-02-15 07:57:18 +01:00
uv.lock feat: add GPT-5 generation models to OpenAI providers 2026-02-15 14:42:43 +01:00

bulkgen

A build tool for AI-generated artifacts. Define image and text targets in a YAML config, and bulkgen handles dependency resolution, incremental builds, and parallel execution.

Uses Mistral for text generation and BlackForestLabs (FLUX) for image generation.

Installation

Requires Python 3.13+.

pip install .

Or with uv:

uv sync

Quick start

  1. Set your API keys:
export MISTRAL_API_KEY="your-key"
export BFL_API_KEY="your-key"
  1. Create a config file (e.g. my-project.bulkgen.yaml):
defaults:
  text_model: mistral-large-latest
  image_model: flux-pro

targets:
  hero.png:
    prompt: "A dramatic sunset over mountains, photorealistic"
    width: 1024
    height: 768

  blog-post.md:
    prompt: prompts/write-blog.txt
    inputs:
      - hero.png
      - notes.md
  1. Build:
bulkgen build

Config format

The config file must be named <anything>.bulkgen.yaml and placed in your project directory. One config file per directory.

Top-level fields

Field Description
defaults Default model names (optional)
targets Map of output filenames to their configuration

Defaults

defaults:
  text_model: mistral-large-latest   # used for .md, .txt targets
  image_model: flux-pro              # used for .png, .jpg, .jpeg, .webp targets

Target fields

Field Type Description
prompt string Inline prompt text, or path to a prompt file
model string Override the default model for this target
inputs list[string] Files this target depends on (other targets or existing files)
reference_image string Image file for image-to-image generation
control_images list[string] Control images (for canny/depth models)
width int Image width in pixels
height int Image height in pixels

Target type is inferred from the file extension:

  • Image: .png, .jpg, .jpeg, .webp
  • Text: .md, .txt

Prompts

Prompts can be inline strings or file references:

targets:
  # Inline prompt
  image.png:
    prompt: "A cat sitting on a windowsill"

  # File reference (reads the file contents as the prompt)
  article.md:
    prompt: prompts/article-prompt.txt

If the prompt value is a path to an existing file, its contents are read. Otherwise the string is used directly.

Dependencies

Targets can depend on other targets or on existing files in the project directory:

targets:
  base.png:
    prompt: "A landscape scene"

  variant.png:
    prompt: "Same scene but in winter"
    reference_image: base.png    # image-to-image, depends on base.png

  summary.md:
    prompt: "Summarize these notes"
    inputs:
      - base.png                 # depends on a generated target
      - research-notes.md        # depends on an existing file

bulkgen resolves dependencies automatically. If you build a single target, its transitive dependencies are included.

CLI

bulkgen build [target]

Build all targets, or a specific target and its dependencies.

  • Skips targets that are already up to date (incremental builds)
  • Runs independent targets in parallel
  • Continues building if a target fails (dependents of the failed target are skipped)

bulkgen clean

Remove all generated target files and the build state file (.bulkgen.state.yaml). Input files are preserved.

bulkgen graph

Print the dependency graph showing build stages:

Stage 0 (inputs): research-notes.md
Stage 0 (targets): base.png
Stage 1 (targets): variant.png, summary.md
  variant.png <- base.png
  summary.md <- base.png, research-notes.md

Incremental builds

bulkgen tracks the state of each build in .bulkgen.state.yaml (auto-generated, add to .gitignore). A target is rebuilt when any of these change:

  • Input file contents (SHA-256 hash)
  • Prompt text
  • Model name
  • Extra parameters (width, height, etc.)

Installation with Nix / home-manager

bulkgen provides a Nix flake with a home-manager module. Add the flake as an input and enable the module:

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    bulkgen.url = "github:kfickel/bulkgen";  # adjust to your actual repo URL
  };

  outputs = { nixpkgs, home-manager, bulkgen, ... }: {
    # ... your existing config, then in homeConfigurations:
    homeConfigurations."user" = home-manager.lib.homeManagerConfiguration {
      # ...
      modules = [
        bulkgen.homeManagerModules.bulkgen
        {
          programs.bulkgen.enable = true;
        }
      ];
    };
  };
}

This places the bulkgen binary on your $PATH. To use a different package build (e.g. from a different system or overlay), set programs.bulkgen.package.

The flake also exposes:

  • packages.<system>.bulkgen — the standalone package, usable without home-manager (e.g. nix run github:kfickel/bulkgen)
  • devShells.<system>.default — development shell with all dependencies

Environment variables

Variable Required for
MISTRAL_API_KEY Text targets (.md, .txt)
BFL_API_KEY Image targets (.png, .jpg, .jpeg, .webp)