CLI guide

AgentGen CLI

Generate PDFs and images from HTML directly in your terminal, shell scripts, and CI pipelines — no code required. Install in one command and start generating in seconds.

Installation

One-liner (Linux & macOS)

curl -fsSL https://raw.githubusercontent.com/Agent-Gen-com/agent-gen-lib/main/install.sh | sh

Installs to ~/.local/bin/agentgen. Override the destination with AGENTGEN_INSTALL=/usr/local/bin.

Homebrew

brew tap Agent-Gen-com/agentgen
brew install agentgen

From source (Cargo)

cargo install agentgen-cli

Authentication

Set your API key once as an environment variable and it will be picked up automatically by every command:

export AGENTGEN_API_KEY="agk_..."
agentgen --help

Or pass it inline with the global --api-key flag:

agentgen --api-key agk_... balance

Get your API key at agent-gen.com/login.

agentgen image

Render HTML to a PNG, JPEG, or WebP image and save it to a file (or print the CDN URL to stdout).

agentgen image --html "<h1>Hello World</h1>" --output hello.png
agentgen image \
  --html "<h1>Hello World</h1>" \
  --width 1200 \
  --height 630 \
  --format png \
  --device-scale-factor 2.0 \
  --output og-image.png
Flags
--html <HTML>HTML content to render (required)
--width <WIDTH>Image width in pixels, 1–5000 (default: 1200)
--height <HEIGHT>Image height in pixels, 1–5000 (default: 630)
--format <FORMAT>png, jpeg, or webp (default: png)
--device-scale-factor <N>Pixel density, 1.0–3.0 (default: 2.0)
--output <PATH>Save to file. Omit to print CDN URL to stdout.

agentgen pdf

Render HTML to a PDF and save it locally.

agentgen pdf --html "<h1>Invoice #42</h1>" --output invoice.pdf
agentgen pdf \
  --html "<h1>Invoice #42</h1><p>Amount due: $99.00</p>" \
  --format a4 \
  --margin-top 20mm \
  --margin-bottom 20mm \
  --margin-left 15mm \
  --margin-right 15mm \
  --print-background true \
  --output invoice.pdf
Flags
--html <HTML>HTML content to render (required)
--format <FORMAT>a4, letter, a3, or legal (default: a4)
--landscape <BOOL>true or false (default: false)
--print-background <BOOL>Render CSS backgrounds (default: true)
--margin-top <VALUE>CSS margin value, e.g. 20mm or 1in
--margin-bottom <VALUE>CSS margin value
--margin-left <VALUE>CSS margin value
--margin-right <VALUE>CSS margin value
--output <PATH>Save to file. Omit to print CDN URL to stdout.

agentgen upload

Upload a local file for 24-hour temporary CDN access. Useful for hosting images or fonts that your HTML references before generating a PDF or image.

agentgen upload ./logo.png

# Output:
# URL: https://cdn.agent-gen.com/temp/abc123.png
# Key: upload_abc123
# Size: 12345 bytes
# Expires at: 2025-01-15T10:30:00Z

Then embed the returned URL in your HTML before calling agentgen image or agentgen pdf:

LOGO=$(agentgen upload ./logo.png | grep '^URL:' | awk '{print $2}')
agentgen image --html "<img src='$LOGO' style='width:200px'>" --output result.png

agentgen balance

Check your remaining token balance.

$ agentgen balance
Tokens: 1000

Global flags

--api-key <KEY>AgentGen API key (or set AGENTGEN_API_KEY env var)
--base-url <URL>Custom API endpoint (default: https://www.agent-gen.com/api)

CI pipeline example

Add document generation to any GitHub Actions workflow:

- name: Generate PDF report
  env:
    AGENTGEN_API_KEY: ${{ secrets.AGENTGEN_API_KEY }}
  run: |
    curl -fsSL https://raw.githubusercontent.com/Agent-Gen-com/agent-gen-lib/main/install.sh | sh
    agentgen pdf --html "$(cat report.html)" --output report.pdf
    # Upload report.pdf as an artifact or email it

1 token

Image generation

2 tokens/page

PDF generation

Free

Upload & balance

Ready to generate from the terminal?

50 free tokens on signup. No credit card required.