Skip to main content
Install W&B to track, visualize, and manage machine learning experiments of any size.
Are you looking for information on W&B Weave? See the Weave Python SDK quickstart or Weave TypeScript SDK quickstart.

Sign up and create an API key

To authenticate your machine with W&B, you need an API key. To create an API key, select the Personal API key or Service Account API key tab for details.
To create a personal API key owned by your user ID:
  1. Log in to W&B, then click your user profile icon > User Settings.
  2. Click Create new API key.
  3. Provide a descriptive name for your API key.
  4. Click Create.
  5. Copy the displayed API key immediately and store it securely.
W&B shows the full API key only once, when you create it. After you close the dialog, you cannot view the full API key again. Your settings display only the key ID (the first part of the key). If you lose the full API key, you must create a new one.
For secure storage options, see Store API keys securely.

Install the wandb library and log in

  1. Set the WANDB_API_KEY environment variable.
  2. Install the wandb library and log in.

Initialize a run and track hyperparameters

In your Python script or notebook, initialize a W&B run object with wandb.init(). Use a dictionary for the config parameter to specify hyperparameter names and values. Within the with statement, you can log metrics and other information to W&B.
See the next section for a complete example that simulates a training run and logs accuracy and loss metrics to W&B.
A run is a core element of W&B. You use runs to track metrics, create logs, track artifacts, and more.

Create a machine learning training experiment

This mock training script logs simulated accuracy and loss metrics to W&B. Copy and paste the following code into a Python script or notebook cell and run it:
Visit wandb.ai/home to view recorded metrics such as accuracy and loss and how they changed during each training step. The following image shows the loss and accuracy tracked from each run. Each run object appears in the Runs column with generated names.
Shows loss and accuracy tracked from each run.

Next steps

Explore more features of the W&B ecosystem:
  1. Learn about and create your first run.
  2. Track models, datasets, and other files with W&B Artifacts.
  3. Automate hyperparameter searches and optimize models with W&B Sweeps.
  4. Share models, prompts, and datasets with W&B Registry.
  5. Analyze runs, visualize model predictions, view artifacts in your project’s dashboard.
  6. Summarize findings and share updates with collaborators using W&B Reports.
  7. Trace and evaluate LLM applications with W&B Weave.