HTML to PDF CLI & Image Generation CLI
AgentGen gives you a fast HTML to PDF CLI and HTML to image CLI for your terminal, shell scripts, and CI pipelines. Install in one command, render directly from HTML, and save locally or print a hosted URL.
Best fit for developers who want a simple PDF CLI for invoices, reports, receipts, OG images, and other generated files without building a full rendering pipeline from scratch.
Installation
One-liner (Linux & macOS)
curl -fsSL https://raw.githubusercontent.com/Agent-Gen-com/agent-gen-lib/main/install.sh | shInstalls to ~/.local/bin/agentgen. Override the destination with AGENTGEN_INSTALL=/usr/local/bin.
Homebrew
brew tap Agent-Gen-com/agentgen
brew install agentgenFrom source (Cargo)
cargo install agentgen-cliAuthentication
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 --helpOr pass it inline with the global --api-key flag:
agentgen --api-key agk_... balanceGet 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). Output dimensions are inferred from the rendered HTML by default.
agentgen image --html "<h1>Hello World</h1>" --output hello.pngagentgen image \
--html "<h1>Hello World</h1>" \
--viewport-width 1200 \
--selector "#card" \
--format png \
--device-scale-factor 2.0 \
--output og-image.png| --html <HTML> | HTML content to render (required) |
| --viewport-width <WIDTH> | Viewport width used for layout before capture, 1–5000 (default: 1200) |
| --viewport-height <HEIGHT> | Viewport height used for layout before capture, 1–5000 (default: 800) |
| --selector <CSS> | Capture a specific element instead of the full rendered document |
| --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. CSS @page size is preferred by default.
agentgen pdf --html "<h1>Invoice #42</h1>" --output invoice.pdfagentgen pdf \
--html "<h1>Invoice #42</h1><p>Amount due: $99.00</p>" \
--page-size-source css \
--format a4 \
--margin-top 20mm \
--margin-bottom 20mm \
--margin-left 15mm \
--margin-right 15mm \
--print-background true \
--output invoice.pdf| --html <HTML> | HTML content to render (required) |
| --page-size-source <MODE> | css or format. css prefers @page size from the document (default: css) |
| --format <FORMAT> | Fallback page size when CSS does not define one: 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:00ZThen 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.pngagentgen balance
Check your remaining token balance.
$ agentgen balance
Tokens: 1000Global 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 it1 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.