> ## Documentation Index
> Fetch the complete documentation index at: https://pdfbase.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Overview

> Generate and manage PDFs from your terminal.

## Installation

```bash theme={null}
npm install -g @pdfbase/cli
```

Or use without installing:

```bash theme={null}
npx @pdfbase/cli create --html "<h1>Hello</h1>" -o hello.pdf
```

## Authentication

```bash theme={null}
# Set your API key
pdfbase auth login

# Or use an environment variable
export PDFBASE_API_KEY=pk_live_xxx
```

The CLI uses `pk_test_` keys by default. Pass `--live` to use your live key:

```bash theme={null}
pdfbase create --html "<h1>Hello</h1>" -o hello.pdf --live
```

## Quick examples

```bash theme={null}
# Generate from HTML string
pdfbase create --html "<h1>Invoice</h1><p>Total: $500</p>" -o invoice.pdf

# Generate from an HTML file
pdfbase create --from html --input report.html -o report.pdf

# Generate from a URL
pdfbase create --from url --input "https://your-app.com/report" -o report.pdf

# Render a template with data
pdfbase render invoice --data '{"number":"INV-001","customer":"Acme"}' -o invoice.pdf

# Render with data from a JSON file
pdfbase render invoice --data-file data.json -o invoice.pdf

# Push templates from your project
pdfbase templates push

# Preview a template locally
pdfbase templates preview invoice --data-file sample.json
```

## Configuration

The CLI reads from `pdfbase.json` in your project root for template definitions. See [Templates-as-Code](/docs/guides/templates#templates-as-code-cli).

## Global flags

| Flag             | Description                           |
| ---------------- | ------------------------------------- |
| `--live`         | Use live API key instead of test      |
| `--api-key`      | Override the API key for this command |
| `--output`, `-o` | Output file path                      |
| `--format`       | Page format (a4, letter, etc.)        |
| `--debug`        | Enable debug mode                     |
| `--json`         | Output raw JSON response              |
| `--quiet`, `-q`  | Suppress progress output              |
