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

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"

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

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