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

# bt login

> Log in to Braintrust from the CLI or refresh an OAuth login.

`bt login` creates or updates a saved Braintrust login profile. A profile stores credentials and connection details, while organization and project context are selected separately. One profile can be used with every organization its credentials can access.

After logging in, use [`bt switch`](https://docs.braintrust.dev/reference/cli/switch) to select your active organization and project. Use [`bt profiles`](https://docs.braintrust.dev/reference/cli/profiles) to list, rename, or delete saved profiles.

In an interactive terminal, `bt login` prompts you to choose OAuth or API key authentication. OAuth is selected by default.

If `BRAINTRUST_API_KEY` is set, `bt login` offers to save that key in a profile instead of prompting for an authentication method. The command asks for confirmation before storing the key. In a non-interactive environment, pass `--save-env-api-key` to provide that confirmation. Pass `--oauth` to log in with OAuth instead. To save a different API key, unset `BRAINTRUST_API_KEY` first so `bt login` prompts you to enter one.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
bt login
bt login --oauth --profile work
bt login --refresh --profile work
```

## Flags

| Flag | Description |
| - | - |
| `--oauth` | Use OAuth login instead of API key login |
| `--refresh` | Immediately refresh credentials for a saved OAuth profile. OAuth credentials otherwise refresh automatically when needed |
| `--client-id CLIENT_ID` | OAuth client ID. Defaults to `bt_cli_<profile>` |
| `--no-browser` | For OAuth, do not open a browser automatically |
| `--save-env-api-key` | Save `BRAINTRUST_API_KEY` in a profile without prompting for confirmation |

`bt login` also accepts credential-related [global flags](https://docs.braintrust.dev/reference/cli/overview.md#global-flags), such as `--profile`, `--api-url`, and `--app-url`. It does not accept `--org` or `--project`; select those with [`bt switch`](https://docs.braintrust.dev/reference/cli/switch).

## Authentication

For the full credential resolution order, see [Credential precedence](https://docs.braintrust.dev/reference/cli/overview.md#credential-precedence).


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