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, then sign in.

Shell
tdx auth login --host http://127.0.0.1:4000
code
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:

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

CommandsWhat they doConcepts
api-keysCreate, rotate, disable and revoke API keysAPI keys
budgetsCreate, change and remove budgetsBudgets
usage, spendRead usage reports and spendSpend and usage
workspaces, users, invitesManage workspaces and their policy, people's roles, and invitationsPeople and workspaces
providersSet and remove provider credentialsProvider credentials
models, pricingTurn models on and off, manage routers and aliases, and override pricesFind a model, Routers and fallback
observabilityRead traces and callsFind and inspect a request
auditRead and follow the audit logAudit log
alertsRead and mark spend alertsBudget alerts
auth, doctorSign in, sign out and check the connectionCLI quickstart
apiSend any management request, with secrets masked in the replyScripts and agents

Every command prints its own help, as in tdx api-keys create --help. The Command 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. 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 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, Scripts and agents or the Command reference.