---
title: Authentication
description: Sign in to TheGitAI without an API key or provider account, check the active account, view remaining usage, and sign out. One flow for desktop, SSH, and headless machines.
---

# Authentication

TheGitAI authenticates through the website. Website and CLI login tokens expire
after 48 hours without an authenticated request. Active use extends that rolling
window.

## Sign in

```bash
ai
```

There is no separate step to remember. If you aren't signed in, `ai` shows the
sign-in screen first and then starts your session. `ai login` does the same
thing, and when you are already signed in it simply starts the session.

The sign-in screen opens your browser to the TheGitAI website, where you sign
in or create an account. After you approve the device, your terminal is signed
in automatically — the CLI never asks for or handles your password. The client
stores a local auth token on your machine until you sign out, the token is
revoked, or it expires after 48 hours of inactivity.

If authentication expires during any CLI request, TheGitAI removes the invalid
credential and asks you to sign in again.

### Headless, remote, or the browser opened somewhere else

There is no separate command for this. The same sign-in screen prints a URL you
can open on any device — your phone, your laptop, anything with a browser — and
keeps a box open for an authorization code the whole time it waits.

If the terminal is not on the machine where you opened that URL, choose **Not on
this machine?** on the authorization page. Instead of handing the credential
straight back to your terminal, it shows a one-time code to paste into the code
box. Whichever route completes first is the one that signs you in.

## Check the signed-in account

```bash
ai whoami
```

Shows which account is currently signed in. Use it when you hit a permission or
saved-session error, or to confirm that you signed in with the intended account.

Each person may maintain only one personal TheGitAI account unless TheGitAI
approves an organisation, testing, or operator exception in writing. If you
accidentally created another account, contact `support@thegit.ai` rather than
continuing to use both.

## View your usage

```bash
ai --usage
```

Shows your account usage percentage and when it resets.

## Sign out

```bash
ai logout
```

Signs out the current account. From inside a session, `/logout` does the same
thing and then quits.

::tip
Signed in with the wrong account? Run `/logout` (or `ai logout`), then `ai`, and
sign in as the account you intended to use. Because `ai login` no longer
re-prompts once you are signed in, signing out is how you switch accounts.
::
