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

# CLI

> The command-line interface for TopK.

Command-line interface for [TopK](https://topk.io).

## Installation

```bash theme={null}
brew tap topk-io/topk
brew install topk
```

## Authentication

To authenticate, run:

```bash theme={null}
topk login
```

Alternatively, you can set `TOPK_API_KEY` environment variable and skip the `topk login` command.

```bash theme={null}
export TOPK_API_KEY=<your-api-key>
```

## Commands

### login

To authenticate, run:

```bash theme={null}
topk login
```

Alternatively, you can set `TOPK_API_KEY` environment variable and skip the `topk login` command.

```bash theme={null}
export TOPK_API_KEY=<your-api-key>
```

### logout

Remove saved credentials:

```bash theme={null}
topk logout
```

## Global flags

These flags are accepted by every command:

### `--output`

Options:

* `text` (default)
* `json`

Output results as NDJSON — one JSON object per line, compatible with `jq`.

### `--api-key`

API key to use for this invocation. Overrides the `TOPK_API_KEY` environment variable and the key saved via `topk login`.

## Updating the CLI

To update CLI to the latest version, run:

```bash theme={null}
brew update
brew upgrade topk
```
