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

# Login

> Log in to the Together CLI with your browser.

Log in to the Together CLI with your browser, choose the [project](/docs/projects) it works in, and log out. These commands require CLI version 2.41.0 or later. To authenticate with an API key instead, for example in CI/CD, see [Authenticate with an API key](/reference/cli/getting-started#authenticate-with-an-api-key).

## Login

Log in with your browser. If you don't have a Together AI account yet, you can create one during login.

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

The CLI opens a verification URL in your browser. Approve the request there, and the CLI saves your credentials and refreshes them automatically:

```text theme={null}
$ tg login
To authenticate, visit:
  https://api.together.xyz/login/device?code=ABCDWXYZ

Waiting for authorization...
Logged in.
Switched to project proj_xxxxxxxxxxxxxxxx
```

After you approve the login, the CLI scopes it to a project. If you belong to one project, the CLI switches to it automatically. If you belong to several, it asks you to choose one. With `--json` or `--non-interactive`, it can't ask, so run `tg switch` after you log in.

### Parameters

| Flag | Description |
| :- | :- |
| `--no-browser` | Print the verification URL without opening a browser. Use it over SSH or on a machine without a browser, then open the URL on another device. |

## Switch

Scope the CLI to a different project. Commands you run afterward act in that project.

```bash theme={null}
tg switch [PROJECT_ID]
```

Omit the project ID to choose from every project your login can access. Run `tg login` before you switch.

## Logout

Remove your stored credentials and end your login sessions.

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

After you log out, the CLI uses `TOGETHER_API_KEY` if it's set.

## Credential precedence

The CLI uses the first credential it finds, in this order:

1. The `--api-key` flag.
2. Your `tg login` session.
3. The `TOGETHER_API_KEY` environment variable.

While you're logged in, the CLI ignores `TOGETHER_API_KEY`. To use an API key instead, pass `--api-key` or run `tg logout`.

Only the CLI reads your login credentials. The Python and TypeScript SDKs, and the cURL examples in these docs, authenticate with an [API key](/docs/api-keys-authentication) from `TOGETHER_API_KEY`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.