CLI for AI Image Generation - Generate Images from Terminal | Inliner.ai

CLI for AI Image Generation

Generate and edit images directly from your terminal with @inliner/cli. Perfect for developers who live in the command line, CI/CD pipelines, and batch processing workflows.

Terminal window showing CLI commands for AI image generation

Quick Start

Installation

Terminal

# Install globally
npm install -g @inliner/cli

# Or run directly with npx (no install needed)
npx @inliner/cli "modern-saas-dashboard-preview_1200x600.png" --project mysite

Setup Your API Key

Get an API key from Account > API Keys in the Inliner dashboard.

For persistent access across terminal sessions, add your API key to your shell configuration file:

macOS (zsh) — ~/.zshrc

# Add to ~/.zshrc
echo 'export INLINER_API_KEY=inl_your-key-here' >> ~/.zshrc
source ~/.zshrc

Linux (bash) — ~/.bashrc

# Add to ~/.bashrc
echo 'export INLINER_API_KEY=inl_your-key-here' >> ~/.bashrc
source ~/.bashrc

Windows (PowerShell)

# Set permanently for current user
[Environment]::SetEnvironmentVariable("INLINER_API_KEY", "inl_your-key-here", "User")

# Or for current session only
$env:INLINER_API_KEY = "inl_your-key-here"
Alternative: Pass per-command with --api-key=YOUR_KEY if you prefer not to set an environment variable.

Smart Mode (Default)

When no command is specified, the CLI intelligently parses your input to extract descriptions, dimensions, and output format:

Smart Mode Examples

# Pattern: filename with dimensions -> saves to local file
inliner-ai "professional-team-collaborating-modern-office_1200x600.png" -p mysite
# -> Generates 1200x600 PNG, saves to file

# Pattern: description with dimensions -> outputs URL
inliner-ai "fluffy orange cats playing with yarn ball 900x900" -p mysite
# -> Generates 900x900 PNG, prints URL to stdout

# Auto-detect project (uses your default project)
inliner-ai "golden-sunset-over-mountain-lake_800x600.jpg"
# -> Uses default project automatically

# Override output filename
inliner-ai "minimalist-workspace-laptop-coffee_1200x600.png" -p mysite -o workspace.png

Smart URL Slugs (Default)

CLI generation commands now use smart URL recommendations by default. You can write long, detailed prompts and still get concise, readable CDN paths without reducing image quality.

Smart URL behavior

# Long descriptive prompt -> concise URL slug automatically
inliner-ai generate "a cinematic elephant eating corn in warm golden hour light with rich jungle detail and shallow depth of field" -p inliner-demo --size 1200x600

# Disable smart URL slugging if needed
inliner-ai generate "same long prompt..." -p inliner-demo --size 1200x600 --no-smart-url

Commands

generate

Generate an AI image from a text prompt. Aliases: gen, g

inliner-ai generate "team brainstorming at whiteboard startup office" -p acme --size 1200x600

edit

Edit an image with AI instructions. Accepts local files, Inliner URLs, or stdin.

inliner-ai edit photo.png "remove background" -p proj -o clean.png

inline

Process HTML files to resolve Inliner image references and embed as data URIs.

inliner-ai inline template.html -p acme > output.html

projects

List your Inliner projects. Alias: proj

inliner-ai projects --json

create-project

Create a new project and reserve a namespace. Alias: create

inliner-ai create-project my-site --name "My Website"

images

List generated images with optional filtering. Alias: img

inliner-ai images -p myproject --search "hero"

tags

List, add, remove, or replace tags on existing assets. Alias: tag

inliner-ai tags add --ids 111,222 --tags hero,banner

metadata

Bulk update metadata on existing assets. Alias: meta

inliner-ai metadata update --ids 111,222 --caption "Homepage hero"

usage

Show credit usage for your account. Alias: u

inliner-ai usage --json

Smart Output

The CLI adapts its output based on how you're using it:

Interactive Terminal (TTY)

Prints the image URL for easy copying

Piped Output

Outputs raw image bytes for piping to other tools

File Output (-o)

Saves to file, prints URL to stderr

Unix Workflow Examples

Standard Unix patterns work naturally:

Unix Pipes & Redirects

# Save to file via redirect
inliner-ai generate "cozy coffee shop interior warm lighting" -p site > coffee-shop.png

# Pipe through ImageMagick
inliner-ai generate "geometric abstract icon blue gradient" -p brand --size 400x400 | convert - -resize 200x200 icon-small.png

# Chain edit operations
inliner-ai edit photo.png "remove background" -p proj | inliner-ai edit - "add soft purple gradient background" -p proj > final.png

# Batch process with xargs
cat prompts.txt | xargs -I {} inliner-ai "{}_800x600.png" -p mysite

CLI Cookbook: Tags & Metadata

Copy these snippets to quickly clean up and standardize large asset libraries.

Cookbook: Tagging Recipes

# 1) View your top tags and counts
inliner-ai tags list

# 2) Add campaign tags to multiple known assets
inliner-ai tags add --ids 11111111-1111-1111-1111-111111111111,22222222-2222-2222-2222-222222222222 --tags spring-2026,homepage,hero

# 3) Remove outdated tag from a set of assets
inliner-ai tags remove --ids 11111111-1111-1111-1111-111111111111,22222222-2222-2222-2222-222222222222 --tags old-campaign

# 4) Replace all tags for strict taxonomy reset
inliner-ai tags replace --ids 11111111-1111-1111-1111-111111111111 --tags product,feature,landing

Cookbook: Metadata Rollouts

# 1) Set shared caption + alt text for multiple assets
inliner-ai metadata update --ids 11111111-1111-1111-1111-111111111111,22222222-2222-2222-2222-222222222222 --caption "Spring launch hero set" --alt-text "Team collaborating in modern office"

# 2) Add structured metadata for campaign tracking
inliner-ai metadata update --ids 11111111-1111-1111-1111-111111111111 --custom-metadata '{"campaign":"spring-2026","channel":"paid-social","owner":"growth"}'

# 3) Update title + description for a polished asset handoff
inliner-ai metadata update --ids 22222222-2222-2222-2222-222222222222 --title "Homepage Hero - Product Team" --description "Primary hero visual for launch week landing pages."

# 4) Use --json for script-friendly output
inliner-ai metadata update --ids 11111111-1111-1111-1111-111111111111 --caption "v2 hero" --json

Edit vs Generate (Important)

If you want to modify an existing image, use the edit command with a clear source file or URL. Requests like "make it 600x600" without a source can be interpreted as generating a new image.

Explicit edit flow

# Edit existing file (recommended for resize/change requests)
inliner-ai edit ./demo/elephant-eating-corn_800x600.png "resize to 600x600 while preserving scene" -p inliner-demo -o ./demo/elephant-eating-corn_600x600.png

# Generate new image (new prompt and concept)
inliner-ai generate "elephant eating corn in nature" -p inliner-demo --size 600x600 -o ./demo/elephant-eating-corn-new_600x600.png

Project Selection

The CLI automatically selects a project in this order:

  1. --project flag (explicit)
  2. INLINER_DEFAULT_PROJECT environment variable
  3. Default project (marked as default in your account)
  4. First project (fallback)

Environment Variables

Environment Variables

INLINER_API_KEY          # API key (required)
INLINER_DEFAULT_PROJECT  # Default project namespace
INLINER_API_URL          # API base URL (default: https://api.inliner.ai)
INLINER_IMG_URL          # Image CDN URL (default: https://img.inliner.ai)
Pro Tip: Add export INLINER_API_KEY=your-key and export INLINER_DEFAULT_PROJECT=mysite to your .bashrc or .zshrc for seamless usage across all terminal sessions.

HTML Inlining for Emails

The inline command is perfect for email templates where you need base64-embedded images:

Email Template Processing

# Embed all Inliner images as base64 data URIs
cat email-template.html | inliner-ai inline --embed > email-ready.html

# Process HTML with placeholder comments
inliner-ai inline template.html -p acme > output.html

Supported HTML patterns:

HTML Patterns

<!-- inliner: hero banner sunset landscape 1200x600 png -->
<!-- Becomes: <img src="https://img.inliner.ai/acme/hero-banner-sunset-landscape_1200x600.png" ...> -->

<img data-inliner="product shot on white background" width="800" height="600">
<!-- Gets an Inliner src URL added -->

CI/CD Integration

Use the CLI in your build pipelines for automated image generation:

GitHub Actions Example

# GitHub Actions example
- name: Generate Social Images
  env:
    INLINER_API_KEY: ${{ secrets.INLINER_API_KEY }}
  run: |
    npx @inliner/cli "abstract-gradient-purple-blue-tech-background_1200x630.png" -p ${{ github.repository }} -o public/og.png
    npx @inliner/cli "colorful-code-editor-dark-theme-programming_800x418.png" -p ${{ github.repository }} -o public/twitter.png

Ready to Generate Images from Your Terminal?

Get your API key and start using the CLI in minutes