Skip to main content

Usage

login [OPTIONS] [KEY]...

Description

Authenticate your machine with W&B. Store an API key locally for authenticating with W&B services. By default, credentials are stored without server-side verification. If no API key is provided as an argument, the command looks for credentials in the following order:
  1. The WANDB_API_KEY environment variable
  2. The api_key setting in a system or workspace settings file (use wandb status to see which settings file is used)
  3. The .netrc file (~/.netrc, ~/_netrc, or the NETRC env var path)
  4. An interactive prompt (if a TTY is available)
For self-hosted or dedicated cloud deployments, specify the server URL with --host, or set the WANDB_BASE_URL environment variable. For example, to log in interactively (prompts for API key):
wandb login
To log in with an explicit API key (WANDB_API_KEY_EXAMPLE):
wandb login WANDB_API_KEY_EXAMPLE
To log in and verify the API key is valid:
wandb login --verify
To log in to the W&B public cloud instead of a configured self-hosted instance:
wandb login --cloud
To log in to a self-hosted W&B instance:
wandb login --host https://my-wandb-server.example.com
To force a new login prompt even if already authenticated:
wandb login --relogin

API key formats

W&B issues API keys in the wandb_v1_ format (about 92 characters). Older SDK versions expect exactly 40 characters and reject the new format with API key must be 40 characters long. Upgrade the SDK (pip install -U wandb) and run wandb login --relogin. Keys generated at wandb.ai/authorize are shown only once at creation. Copy them immediately; you cannot retrieve them again after closing the dialog. For pinned SDK versions, legacy keys, and related errors, see Why does my API key fail with ‘must be 40 characters long’?.

Arguments

NameDefaultType
keySTRFalse

Options

FlagTypeDescription
--cloudBOOL FlagLog in to the W&B public cloud (https://api.wandb.ai). Mutually exclusive with —host. Default: False
--host, --base-urlSTRLog in to a specific W&B server instance by URL (e.g. https://my-wandb.example.com). Mutually exclusive with —cloud. Default: None
--reloginBOOL FlagForce a new login prompt, ignoring any existing credentials. Default: None
--verifyBOOL FlagVerify the API key with W&B after storing it. If verification is successful, display the source of the credentials and the default team. Default: False