> ## 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.

# Authentication

> Configure your LinkModel API key for local CLI usage, scripts, and CI jobs.

Run the interactive setup flow:

```bash theme={null}
lkm setup
```

Or configure your API key directly:

```bash theme={null}
lkm auth login --api-key <your-api-key>
lkm auth status
```

Saved credentials are stored in `~/.linkmodel/config.json` with file mode `0600`. API keys are masked in normal command output.

Authentication is resolved in this order:

```text theme={null}
--api-key > LINKMODEL_API_KEY > ~/.linkmodel/config.json
```

## Environment Variable

Use `LINKMODEL_API_KEY` when running the CLI in CI, containers, or short-lived shell sessions:

```bash theme={null}
export LINKMODEL_API_KEY="<your-api-key>"
lkm auth status
```

For a single command:

```bash theme={null}
LINKMODEL_API_KEY="<your-api-key>" lkm image "a product photo"
```

## One-Off Key

Pass `--api-key` when you do not want to write credentials to disk:

```bash theme={null}
lkm image "a product photo" --api-key <your-api-key>
```

## Next

Generate your first asset with [Image Generation](/cli-image-generation) or [Video Generation](/cli-video-generation).
