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

# Automation

> Use LinkModel CLI JSON output, exit codes, and status commands in scripts and CI workflows.

Use `--json` for scripts and agents:

```bash theme={null}
lkm image "a red panda" --json
lkm video status <task_id> --wait --json
lkm doctor --json
```

In JSON mode, stdout contains exactly one JSON line. Human-readable logs go to stderr.

## Create Now, Poll Later

Use `--no-wait` to create a task and return immediately:

```bash theme={null}
lkm image "a product photo" --no-wait --json
lkm video "a cinematic product orbit" --no-wait --json
```

Store the returned `task_id`, then resume polling later:

```bash theme={null}
lkm image status <task_id> --wait --json
lkm video status <task_id> --wait --json
```

## CI Authentication

Set `LINKMODEL_API_KEY` in your CI secret store, then run CLI commands without writing a local config file:

```bash theme={null}
lkm auth status --json
lkm image "a product photo" --json
```

## Exit Codes

| Code  | Meaning                                                               |
| ----- | --------------------------------------------------------------------- |
| `0`   | Success.                                                              |
| `1`   | Task failed, task cancelled, download failure, or API/network error.  |
| `2`   | Usage error, invalid parameters, missing API key, or unknown command. |
| `3`   | Authentication failed.                                                |
| `4`   | Polling timed out; the server task keeps running.                     |
| `130` | Interrupted with `Ctrl-C`; the server task keeps running.             |

Handle `4` and `130` as resumable states when your workflow stores the `task_id`.
