Frontier LLMs paint oil paintings stroke by stroke, with a physical paint engine instead of an image generator.
No diffusion. No GANs. No image models. The language model is the painter: it plans a composition, chooses pigments and brushes, and directs every brushstroke, while a NumPy engine simulates bristles, wet paint, impasto relief and canvas weave.
"A starry night over a sleeping village, a flame-like cypress in the foreground", in the style of Vincent van Gogh.
44 artist commands → about 5,700 simulated brushstrokes.
- Highlights
- Gallery
- Quick start
- LLM providers
- How it works
- Painting in the style of the old masters
- The artist's command language
- Brushes
- Python API
- Project structure
- Testing
- Notes and limitations
- License
- The LLM is the artist. It works through five progressive phases, from underpainting to final accents, like a traditional painter.
- Real-looking oil paint. Every bristle carries its own paint load. Strokes leave grooves, run dry and break up over the canvas tooth, drag the wet paint beneath them, and build impasto relief that is lit by a raking light.
- Stroke fields. Master paintings contain thousands of brushmarks. One field command ("cover the sky with short strokes swirling around the moon, in these blues") expands into hundreds of strokes that follow a flow.
- Old-master style guides for Van Gogh, Monet, Rembrandt, Vermeer, Turner, Cézanne, Seurat, Renoir, Munch and Caravaggio. Each translates the painter's palette, ground and technique into the engine's vocabulary.
- The artist sees its work. Vision models receive a snapshot of the canvas after each phase, plus their own notes, and plan the next phase from there.
- Works offline. The built-in mock artist needs no API key and paints in each master's technique.
- Web studio and CLI. Watch the painting build live in the browser, or render headlessly from the terminal. Export PNG and a replayable stroke log.
The five phases of a painting:
The built-in mock artist (no API key) painting the same landscape in eight styles:
Note
The Van Gogh and Monet paintings were rendered from examples/. Those files hold the five phase replies written by hand in exactly the JSON format a model returns, so you can reproduce them without an API key. Paintings from a live model will differ from run to run and depend on the model's sense of composition.
1. Install (Python 3.10 or newer):
git clone <this-repository-url>
cd <repository-folder>
pip install -e ".[all]"[all] installs the Anthropic, OpenAI and Google SDKs. To install only the ones you need, use .[anthropic], .[openai] or .[gemini], or just pip install -e . for the offline mock artist. pip install -r requirements.txt also works.
2. Paint something right away, with no API key:
aipainter --subject "Starry night over an alpine lake" --style "Vincent van Gogh" --output starry.png3. Open the web studio and watch the painting build live:
aipainter-studio --port 8000Then open http://localhost:8000, pick a provider and a style (the Old Masters (Oil) group lists every master), enter a subject and press Start Painting.
4. Reproduce the example paintings from their phase scripts:
python examples/paint_from_json.py examples/van_gogh_starry_village.json -o starry_village.png --save-phases
python examples/paint_from_json.py examples/monet_lily_pond.json -o lily_pond.pngAll CLI options
aipainter [--subject TEXT] [--style TEXT] [--provider {mock,gemini,openai,anthropic,openrouter}]
[--api-key KEY] [--model NAME] [--size N | --width W --height H]
[--output FILE.png] [--export-replay FILE.json] [--list-brushes] [--list-styles]
| Option | Default | Description |
|---|---|---|
-s, --subject |
Sunset over alpine lake and pines |
What to paint. |
--style |
Impressionist Oil |
Painting style: a master's name (see --list-styles), or a medium such as Watercolor Wash, Japanese Sumi-e Ink, Charcoal & Chalk or Pixel Art. |
-p, --provider |
mock |
Which artist drives the painting. |
-k, --api-key |
environment variable | API key for the provider. |
-m, --model |
provider default | Model name, for example claude-sonnet-5 or gpt-4o. |
--size / --width / --height |
512 |
Canvas size in pixels. |
-o, --output |
painting.png |
Output image. |
--export-replay |
none | Save the full stroke log as JSON. |
--list-brushes, --list-styles |
Print the brush catalog or the master styles and exit. |
python -m aipainter.cli and python -m aipainter.server work as well if you prefer not to use the installed commands.
| Provider | --provider |
API key environment variable | Default model |
|---|---|---|---|
| Built-in mock artist | mock |
none | procedural, offline |
| Anthropic Claude | anthropic |
ANTHROPIC_API_KEY |
claude-sonnet-5 |
| OpenAI | openai |
OPENAI_API_KEY |
gpt-4o |
| Google Gemini | gemini |
GEMINI_API_KEY or GOOGLE_API_KEY |
gemini-2.5-flash |
| OpenRouter | openrouter |
OPENROUTER_API_KEY |
openai/gpt-4o |
Override the model with --model. Vision-capable models give the best results, because they see the canvas after every phase and correct their own mistakes. A painting takes five model calls, one per phase.
export ANTHROPIC_API_KEY=... # PowerShell: $env:ANTHROPIC_API_KEY = "..."
aipainter --provider anthropic --style "Claude Monet" --subject "Poppy field on a windy summer day" --width 768 --height 576 -o poppies.pngflowchart LR
A["Subject + style"] --> B["Style guide<br/>(palette, ground, technique)"]
B --> C{"LLM artist"}
C -- "JSON: strokes + stroke fields" --> D["Parser"]
D --> E["Paint engine<br/>bristles · wet paint · impasto"]
E --> F["Canvas"]
F -- "snapshot + metrics + own notes" --> C
F --> G["PNG + stroke replay log"]
Each painting runs through five phases, the way a traditional painter builds depth:
| Phase | What the artist does |
|---|---|
| 1. Composition & underpainting | Ground tone, a loose lay-in of the big colour zones, horizon and light source. |
| 2. Mass blocking | Silhouettes, big masses, light versus shadow. |
| 3. Colour regions | Midtones, warm and cool temperature shifts, modelling of forms. |
| 4. Brushwork & texture | Directional marks that follow form: foliage, water, sky, fabric. |
| 5. Fine accents | Highlights, contours and small details. |
After each phase the canvas is rendered and sent back to the model: an image for vision models, and an ASCII value map with colour metrics for text-only models. The model's own intent and notes from earlier phases are included too.
The paint engine works in 32-bit float RGBA. Each stroke is rasterized into brush-local coordinates: distance along the stroke and offset across the bristles. That lets the brush lay continuous bristle grooves, deplete paint along the stroke, and smear the wet paint underneath in the stroke direction. Paint thickness accumulates in a height map. The final render lights that relief, together with the linen weave of the canvas, with a raking light from the upper left.
Name a master in the style (for example --style "Vincent van Gogh" or "in the style of Cézanne") and the program:
- Prepares the canvas the way the master did: toned ground colour, linen or fine-linen support, and relief strength. Rembrandt paints on a dark brown ground, Van Gogh on a light one.
- Teaches the model the technique in engine terms: palette with pigment values, which stroke fields and flows to use, typical stroke sizes, impasto and wetness, plus advice for each phase.
| Master | Movement | Signature technique in the engine |
|---|---|---|
| Vincent van Gogh | Post-Impressionism | Thick directional dashes, swirl fields around stars and moon, flame-like cypresses, blue-black contours |
| Claude Monet | Impressionism | Broken colour in short random dabs, no black, coloured shadows, wet-on-wet |
| Rembrandt van Rijn | Dutch Golden Age | Dark brown ground, thin glowing darks, thick sculpted lights, lost edges |
| Johannes Vermeer | Dutch Golden Age | Soft fused modelling, window light from the left, pointillé highlight dots |
| J. M. W. Turner | Romanticism | Vortex compositions, scumbled veils, a blazing impasto light core |
| Paul Cézanne | Post-Impressionism | Constructive parallel hatch strokes, planes of warm and cool colour |
| Georges Seurat | Pointillism | Dots of pure colour for optical mixing, complementary halos |
| Pierre-Auguste Renoir | Impressionism | Feathery wet-in-wet strokes, dappled light, pearly skin |
| Edvard Munch | Expressionism | Long undulating bands of colour, thin paint, raw canvas showing |
| Caravaggio | Baroque | Near-black darkness, hard raking spotlight, smooth modelling |
Other oil styles, such as "Impressionist Oil", "impasto" or "alla prima", get a general oil guide. Watercolour, ink, charcoal, pencil and pixel styles keep their own brushes.
Important
These are homages in the style of public-domain masters, not reproductions or forgeries. The style guides tell the model never to sign a painting with the master's name.
The model replies to each phase with JSON. The engine accepts two kinds of commands in one ordered list:
{
"artistic_intent": "Block the sky in rhythmic currents with a vortex; halo around the moon",
"strokes": [
{"type": "field", "brush": "oil", "region": {"ellipse": [300, 150, 150, 72]},
"flow": {"type": "swirl", "center": [300, 150], "inward": 0.2},
"palette": ["cerulean", "cobalt blue", [0.85, 0.88, 0.8]],
"size": 10, "stroke_length": 34, "density": 1.4, "extra": {"impasto": 1.4, "wetness": 0.15}},
{"brush": "oil", "color": [0.06, 0.08, 0.17], "points": [[196, 371], [220, 352], [244, 371]],
"size": 3.5, "opacity": 0.95, "extra": {"impasto": 1.2}}
],
"next_phase_notes": "Paint the village and the cypress flames next"
}Individual strokes
| Key | Meaning |
|---|---|
brush |
One of the brushes. |
color |
[r, g, b] in 0–1 or 0–255, "#rrggbb", or a pigment name such as "ultramarine" or "chrome yellow". |
points |
[[x, y], ...] or [[x, y, pressure], ...], smoothed with a Catmull-Rom spline. One point makes a dab. |
size, opacity |
Brush diameter in pixels, and opacity from 0 to 1. |
extra |
Brush settings (see below). |
Stroke fields
| Key | Default | Meaning |
|---|---|---|
region |
whole canvas | {"polygon": [[x, y], ...]}, {"ellipse": [cx, cy, rx, ry]}, {"rect": [x0, y0, x1, y1]}, {"circle": [cx, cy, r]}, or a list of these. |
flow |
linear, 0° |
The direction the strokes follow (see below). Angles are in degrees: 0 points right, 90 points down. |
palette |
Each stroke picks one of these colours. weights biases the choice. |
|
gradient |
{"axis": "x" | "y" | "radial", "stops": [...]} colours strokes by position. Palette colours then appear as accents (palette_ratio, default 0.3). |
|
size, stroke_length |
10, 30 | Stroke width and length in pixels. stroke_length: 0 paints dots. |
density |
1.0 | 1 covers the region about once. Use 2–3 for dense dots. |
opacity |
0.95 | |
angle_jitter, size_jitter, length_jitter, color_jitter |
10, 0.25, 0.3, 0.05 | Natural variation between strokes. |
multi_load |
0.3 | Share of strokes that carry a second colour streaked through the bristles. |
clip |
false |
Keep paint strictly inside the region. |
seed |
random | For exact reproduction. The seed is always written to the replay log. |
max_strokes |
2500 | Stroke cap per field (hard limit 6000). |
extra |
Brush settings applied to every stroke. |
Flow type |
Parameters | Good for |
|---|---|---|
linear |
angle |
Parallel strokes, water, rain, planes. |
swirl |
center, radius, clockwise, inward, angle |
Vortices, halos, whirling skies. |
radial |
center, twist |
Rays, petals, explosions. |
wave |
angle, amplitude, wavelength, phase |
Hills, water, wind, hair. |
noise |
angle, spread, scale |
Foliage, flames, cypresses, clouds. |
contour |
Strokes that follow the region's outline to model round forms. | |
random |
Impressionist dabs and broken colour. | |
hatch |
angles |
Parallel hatching patches (Cézanne's constructive stroke). |
Coordinates may be given in pixels or normalized to 0–1; the parser detects which.
Paint settings (extra) for oil, palette knife and dry brush
| Key | Oil default | Meaning |
|---|---|---|
impasto |
1.0 | Paint thickness, which becomes relief catching the light (0–2.5). |
wetness |
0.35 | How much wet paint underneath is picked up and dragged (0–0.9). |
load |
0.9 | Paint on the brush. Low values give dry, broken strokes. |
color2, color2_amount |
none, 0.35 | A second colour streaked through part of the bristles. |
bristle_spacing, bristle_contrast |
1.5, 0.3 | Groove spacing in pixels, and how strongly grooves thin the paint. |
edge_ridge |
0.35 | Paint squeezed out along the stroke's sides. |
tip_roundness |
0.35 | Shape of the stroke ends, from square to round. |
angle |
0 | Orientation of single-point dabs, in degrees. |
seed |
random | Makes an individual stroke reproducible. |
| Brush | Behaviour | Typical use |
|---|---|---|
oil |
Bristle paint model: grooves, depletion over the canvas tooth, wet dragging, impasto relief, multi-colour loads. | Everything in an oil painting. |
palette_knife |
Flat blade: smooth thick plane of paint, square ends, side ridges, marbled streaks. | Rocks, cliffs, architecture, bold planes. |
dry_brush |
Nearly empty stiff brush that only catches the high points of the weave. | Scumbled highlights, bark, grass, spray. |
watercolor |
Transparent glazes with edge pooling and organic bleed. | Washes, skies, petals. |
ink |
Calligraphic ink with tapering and pooling at sharp turns. | Sumi-e, contours, branches. |
pencil |
Graphite with paper-tooth texture. | Sketches, hatching. |
charcoal |
Velvety matte dark with a powdery halo. | Dramatic value studies. |
chalk |
Crumbly dry pastel with porous gaps. | Pastel highlights, stone. |
spray |
Stochastic airbrush droplets. | Mist, dust, stars, glows. |
soft_round |
Smooth cosine-falloff airbrush. | Gradients, soft glows. |
hard_round |
Crisp anti-aliased round. | Clean graphic shapes. |
pixel |
Exact grid-aligned pixels with no anti-aliasing. | Pixel art. |
The canvas surface is configurable with PaintCanvas.set_surface("linen" | "fine_linen" | "panel" | "none"). Master styles choose one automatically.
Drive a painting from your own code:
from aipainter.llm import PaintingOrchestrator, create_artist_client
client = create_artist_client("anthropic") # reads ANTHROPIC_API_KEY; use "mock" to run offline
painter = PaintingOrchestrator(
client,
subject="A wheat field with cypresses under a windy sky",
style="Vincent van Gogh",
canvas_width=768,
canvas_height=576,
)
canvas = painter.run(on_phase_complete=lambda phase, plan: print(phase.value, "-", plan.artistic_intent))
canvas.to_pil().save("wheat_field.png")Or use the paint engine directly, without any LLM:
from aipainter.engine import PaintCanvas
from aipainter.engine.fields import FieldSpec, render_field
canvas = PaintCanvas(640, 480, background_color=(0.93, 0.91, 0.84))
canvas.set_surface("linen")
render_field(canvas, FieldSpec(
region={"rect": [0, 0, 640, 300]},
flow={"type": "swirl", "center": [320, 150], "radius": 220},
palette=[(0.10, 0.20, 0.55), (0.30, 0.50, 0.80), (0.95, 0.85, 0.30)],
size=9, stroke_length=30, density=1.3,
extra={"impasto": 1.6, "wetness": 0.2},
))
canvas.to_pil().save("swirling_sky.png")Web studio HTTP API
| Endpoint | Description |
|---|---|
GET /api/brushes |
Brush catalog. |
GET /api/styles |
Master oil styles. |
WS /ws/paint |
Send {"subject", "style", "provider", "api_key", "model", "canvas_width", "canvas_height", "playback_speed"}. Receive session_start, phase_start, phase_planned, stroke_drawn, phase_complete and painting_complete events. |
GET /api/session/{id}/canvas.png |
Finished painting. |
GET /api/session/{id}/replay.json |
Stroke log. Field entries include their seed. |
aipainter/
├── engine/ # Procedural paint engine (no LLM code)
│ ├── canvas.py # Layers, compositing, relief map, canvas surface, lit render
│ ├── stroke_raster.py # Brush-local stroke coordinates
│ ├── fields.py # Stroke fields: regions, flow fields, stroke expansion
│ ├── noise.py # Noise, linen weave and gesso textures
│ ├── brush_base.py # Stroke data types and spline interpolation
│ ├── registry.py # Brush registry and catalog
│ └── brushes/ # oil, palette_knife, dry_brush, watercolor, ink, ...
├── llm/ # The artist
│ ├── client.py # Provider adapters, response parser, offline mock artist
│ ├── orchestrator.py # Five-phase painting loop with visual feedback
│ ├── prompts.py # System and phase prompts
│ ├── styles.py # Old-master style guides
│ └── schemas.py # Commands, pigments, feedback types
├── ui/ # FastAPI web studio (server + static front end)
├── cli.py # `aipainter` command
└── server.py # `aipainter-studio` command
examples/ # Phase scripts and a renderer that needs no API key
docs/images/ # README images
tests/ # pytest suite
pip install -e ".[dev]"
pytestThe suite covers every brush, the paint model (relief, wet pickup, multi-colour loads), compositing and blend modes, stroke fields (every flow type, regions, clipping, gradients, dots, determinism), style resolution and prompts, parsing of LLM output, the full orchestration loop, and the web studio's HTTP and WebSocket API.
- Results depend on the model. Composition, drawing and spatial accuracy come from the LLM. Stronger vision models produce clearly better paintings. The engine supplies the paint handling, the style guides supply the technique.
- The mock artist paints one fixed landscape (sky, mountains, lake, trees, light source) in the chosen style. Only a real model interprets your subject.
- Speed. Rendering takes roughly 1 ms per brushstroke on a laptop CPU, so a typical painting of 5,000–15,000 strokes renders in 5–15 seconds. Dense pointillism takes longer.
- Cost. A painting uses five model calls, four of which include a canvas image.
- The web studio is meant to run locally. It has no authentication. API keys typed into the studio are stored in your browser's
localStorageand sent to your local server, which passes them on to the provider. Do not expose the studio to a network you don't trust: it binds to127.0.0.1by default, so be careful with--host 0.0.0.0.
This program is free for individual artists to use to make art.



