
# CLI overview

`tdx` manages a running gateway from a terminal or a script: API keys, budgets, people, workspaces, models, spend, traces and the audit log. It calls the gateway's management endpoints as you, or with an admin key, and prints every result as versioned JSON, so the same commands serve a person, a CI job and a coding agent.

## Install and sign in

You need a running gateway and an account on its dashboard. [Install the CLI](/cli/quickstart#install-the-cli), then sign in.

```bash
tdx auth login --host http://127.0.0.1:4000
```

```text
Open http://127.0.0.1:4000/cli-sign-in
Enter this code in the browser: SFBB-ZWBT
Only enter a code that your own terminal shows you. The code expires in 10 minutes.
Opened your browser. Waiting for approval… (Ctrl-C to cancel)
```

Enter the code on the page that opens and choose **Approve**. `tdx auth login` then saves a personal access token that acts as you, with the gateway's address, in a profile only your user can read, so later commands need neither:

```bash
tdx api-keys list
```

```json
{
  "schemaVersion": "tokedex.cli.v1",
  "command": "api-keys list",
  "data": {
    "keys": [
      {
        "id": "01M83N53FRJSNFAN03N49RBKSZ",
        "name": "ci-deploy",
        "status": "active",
        "createdAt": "2026-11-23T07:33:00.561Z",
        "expiresAt": null
      }
    ],
    "hasMore": false,
    "nextCursor": null
  }
}
```

The install also provides `tokedex` as a second command name.

## Command groups

| Commands | What they do | Concepts |
|---|---|---|
| [`api-keys`](/cli/reference/api-keys) | Create, rotate, disable and revoke API keys | [API keys](/gateway/api-keys) |
| [`budgets`](/cli/reference/budgets) | Create, change and remove budgets | [Budgets](/gateway/budgets) |
| [`usage`](/cli/reference/usage), [`spend`](/cli/reference/spend) | Read usage reports and spend | [Spend and usage](/gateway/spend-and-usage) |
| [`workspaces`](/cli/reference/workspaces), [`users`](/cli/reference/users), [`invites`](/cli/reference/invites) | Manage workspaces and their policy, people's roles, and invitations | [People and workspaces](/gateway/people-and-workspaces) |
| [`providers`](/cli/reference/providers) | Set and remove provider credentials | [Provider credentials](/gateway/provider-credentials) |
| [`models`](/cli/reference/models), [`pricing`](/cli/reference/pricing) | Turn models on and off, manage routers and aliases, and override prices | [Find a model](/gateway/models), [Routers and fallback](/gateway/router) |
| [`observability`](/cli/reference/observability) | Read traces and calls | [Find and inspect a request](/gateway/requests-and-sessions) |
| [`audit`](/cli/reference/audit) | Read and follow the audit log | [Audit log](/gateway/recording-and-retention#audit-log) |
| [`alerts`](/cli/reference/alerts) | Read and mark spend alerts | [Budget alerts](/gateway/budget-alerts) |
| [`auth`](/cli/reference/auth), [`doctor`](/cli/reference/doctor) | Sign in, sign out and check the connection | [CLI quickstart](/cli/quickstart) |
| [`api`](/cli/reference/api) | Send any management request, with secrets masked in the reply | [Scripts and agents](/cli/scripts-and-agents) |

Every command prints its own help, as in `tdx api-keys create --help`. The [Command reference](/cli/reference) has a page for each group, with every command's flags, output fields and examples.

## How the CLI connects

- **Gateway address.** `tdx` reads it from `--host`, `TOKEDEX_HOST` or the saved profile. It requires HTTPS, except for `localhost`, `127.0.0.1` and `[::1]`.
- **Credential.** It sends the token saved by `tdx auth login`, or `TOKEDEX_TOKEN` for one run, which suits [scripts and agents](/cli/scripts-and-agents#choose-how-to-pass-credentials). The token from browser sign-in lasts 30 days, and `tdx auth logout` revokes it. For a script, use an admin key with the smallest preset that covers the job, so a leaked key can do little. A master key works too, but it can do everything, so keep it for recovery.
- **Permissions.** The gateway decides what the credential may do: a token from browser sign-in can do what your role lets you do, and an admin key what its preset covers. Anything else fails with `FORBIDDEN` and exit code 4. [Give a script an admin key](/gateway/api-keys#give-a-script-an-admin-key) lists the presets.

A few tasks need a person in the dashboard itself, such as changing sign-in settings or alert destinations. The CLI refuses them with `SESSION_REQUIRED`, even after browser sign-in, so do them in the dashboard.

Next: [CLI quickstart](/cli/quickstart), [Scripts and agents](/cli/scripts-and-agents) or the [Command reference](/cli/reference).
