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

# Generate from the terminal

> Install the Bannerify CLI and generate images and PDFs from your shell.

The Bannerify CLI generates images and PDFs from a terminal. It uses the same templates and API keys as the REST API, so you can render a file in one command and pipe the result into another tool.

Use the CLI when you want to:

* Render a file during a build, a deploy, or a cron job.
* Batch many templates from a shell script.
* Let an agent or a script create files without writing code.

## Before you start

* A Bannerify account with at least one template.
* An API key. Create one in [API keys](/account/project).

## Install

Install the CLI with npm:

```bash theme={null}
npm install -g bannerify-cli
```

To run it without installing:

```bash theme={null}
npx bannerify-cli <command>
```

## Save your API key

Store the key once, like `git config`:

```bash theme={null}
bannerify config set apiKey bnfy_xxxxx
```

The key is written to `$XDG_CONFIG_HOME/bannerify/config.json`, or `~/.config/bannerify/config.json`. The file is created with `0600` permissions.

Confirm the key works:

```bash theme={null}
bannerify whoami
```

The command prints the project name, the project id, the creation date, and where the key came from:

```text theme={null}
Authenticated as Acme
  project id: prj_xxxxx
  created:    2026-01-14T09:12:31.000Z
  key source: config
```

## Generate an image

```bash theme={null}
bannerify create image tpl_xxxxx -o out.png
```

Override the layers of the template with `--modifications`:

```bash theme={null}
bannerify create image tpl_xxxxx -o out.png \
  --modifications '[{"name":"title","text":"Hello world"}]'
```

The array holds one entry per layer. Each entry names the layer with `name` and sets its value with `text`, `src`, or another field of that layer type.

## Generate a PDF

```bash theme={null}
bannerify create pdf tpl_xxxxx -o out.pdf
```

The PDF uses the same modifications format:

```bash theme={null}
bannerify create pdf tpl_invoice -o invoice.pdf \
  --modifications '[{"name":"total","text":"$29.00"}]'
```

## Use it in a pipeline

The CLI keeps stdout for data and stderr for messages, so the bytes of a file pass cleanly to the next command. Write to stdout with `--out=-`:

```bash theme={null}
bannerify create image tpl_xxxxx --out=- --quiet > out.png
```

For long batches, keep the messages and the bytes apart. For example, upload every result as it is generated:

```bash theme={null}
for id in tpl_a tpl_b tpl_c; do
  bannerify create image "$id" --out=- --quiet | rclone rcat "remote:$id.png"
done
```

## Key resolution

The CLI looks for the API key in this order:

1. The `--api-key` flag.
2. The `BANNERIFY_API_KEY` environment variable.
3. The stored config.

This lets you keep one key in the config and override it for a single command or a container:

```bash theme={null}
BANNERIFY_API_KEY=bnfy_yyyyy bannerify create image tpl_xxxxx -o out.png
```

## Configuration file

| Key | Purpose |
| - | - |
| `apiKey` | The API key the CLI sends to the API |
| `baseUrl` | The API base URL. Defaults to `https://api.bannerify.co/v1` |
| `defaultFormat` | The image format used when `--format` is absent. Defaults to `png` |
| `outputDir` | The directory that holds the output file when `--out` is absent |

Manage the file with the `config` commands. See [CLI commands](/cli/commands).

## Usage and limits

Every generation from the CLI counts against the same monthly and daily quota as the REST API and the SDKs. See [Quota and limits](/account/quota).

## Next steps

* [CLI commands](/cli/commands)
* [Create an image](/api-reference/endpoint/create-image)
* [Connect an MCP client](/mcp/overview)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.