Trickery supports generating and editing images using OpenAI's Responses API with the image_generation tool. This allows you to create images from text descriptions, edit existing images, and highlight or modify areas in images.
Input prompt: file path or direct text (auto-detected). Supports Jinja2-style {{ variable }} substitution when using a file.
Output file path for the generated image. If not provided, a filename is auto-generated from the input file name with a random 5-character suffix (e.g., diagram-a3f5x.png).
Input image for editing. Can be:
- A local file path (automatically encoded as base64)
- An HTTP/HTTPS URL
This argument can be repeated multiple times to include multiple images (up to 16).
Image dimensions. Options:
auto(default) - Let the model decide1024x1024orsquare- Square format1024x1536orportrait- Portrait format1536x1024orlandscape- Landscape format
Image quality. Options:
auto(default) - Let the model decidelow- Faster, lower costmedium- Balancedhigh- Best quality, higher cost
Output format:
png(default) - Lossless, supports transparencyjpeg- Smaller file sizewebp- Modern format, good compression
Background handling:
auto(default) - Let the model decidetransparent- Transparent background (requires PNG or WebP)opaque- Solid background
Generation behavior:
auto(default) - Model decides whether to generate or editgenerate- Always create new imageedit- Always edit input image
Compression level for JPEG and WebP formats. Default is 100 (highest quality).
Model to use. Recommended:
gpt-4.1(default)gpt-5gpt-5.2
Note: These models use GPT Image models internally (gpt-image-1.5, gpt-image-1).
Template variables for prompt substitution.
# Simple generation with explicit filename
trickery image prompts/generate_diagram.md --save docs/images/colorful-architecture.png
# Auto-generated filename (e.g., generate_diagram-a3f5x.png)
trickery image prompts/generate_diagram.md
# With quality settings
trickery image prompts/generate_diagram.md -s architecture.png \
--size 1536x1024 \
--quality highSee prompts/generate_diagram.md for the prompt template.
Result
# Make an image look realistic
trickery image prompts/make_realistic.md \
--image test_data/example_images/image1.png \
--save output.png
# Edit with custom instruction
trickery image prompts/edit_image.md \
--image test_data/example_images/image2.png \
--save modified.png \
-v instruction="make it green on pink"See prompts/make_realistic.md and prompts/edit_image.md.
trickery image prompts/highlight_humans.md \
--image test_data/example_images/image3.jpg \
--save highlighted.pngSee prompts/highlight_humans.md for the prompt template.
trickery image prompts/generate_icon.md \
--save icon.png \
-v subject="rocket" \
-v style="flat design"See prompts/generate_icon.md for the prompt template.
# Combine elements from multiple images
trickery image prompts/edit_image.md \
--image test_data/example_images/image1.png \
--image test_data/example_images/image2.png \
--save composite.png \
-v instruction="combine these images into one scene"trickery image prompts/generate_icon.md \
--save logo.png \
--background transparent \
--format png \
-v subject="star" \
-v style="simple outline"trickery image prompts/generate_diagram.md --save result.png -o jsonOutput:
{
"output_path": "result.png",
"revised_prompt": "A clean system architecture diagram..."
}- Template Processing: Variables in
{{ var }}format are substituted before sending - Input Images: Local files are encoded as base64 data URLs
- API Call: Uses OpenAI's Responses API with
image_generationtool - Prompt Optimization: The model automatically revises your prompt for better results
- Output: Base64 image data is decoded and saved to the output file
- Use action verbs like "draw", "edit", "create", "generate"
- For editing, say "edit the image by..." rather than "merge" or "combine"
- Be specific about style, colors, and composition
- For diagrams, specify the elements and their relationships
Local files are automatically detected by extension:
- PNG (
.png) - JPEG (
.jpg,.jpeg) - WebP (
.webp)
Maximum input image size: 50MB per image, up to 16 images.
Image generation costs vary by quality:
| Quality | Approximate Cost |
|---|---|
low |
~$0.02/image |
medium |
~$0.07/image |
high |
~$0.19/image |
Larger sizes and multiple input images increase costs.
Common errors:
- File not found: Verify the image path exists
- Permission denied: Check file permissions
- No image generated: API didn't return an image (check prompt)
- API error: Ensure your API key has access to image generation
