Skip to main content
The W&B Python SDK, accessible at wandb, enables you to train and fine-tune models, and manage models from experimentation to production.
After performing your training and fine-tuning operations with this SDK, you can use the Public API to query and analyze the data that was logged, and the Reports and Workspaces API to generate a web-publishable report summarizing your work.

Sign up and create an API key

To authenticate your machine with W&B, you must first generate an API key at https://wandb.ai/authorize.

Install and import packages

Install the W&B Python SDK using pip:
pip install wandb

Import W&B Python SDK

The following code snippet demonstrates how to import the W&B Python SDK and initialize a run. Replace <team_entity> with your team entity name.
import wandb

# Specify your team entity
entity = "<team_entity>"

# Project that the run is recorded to
project = "my-awesome-project"

with wandb.init(entity=entity, project=project) as run:
   run.log({"accuracy": 0.9, "loss": 0.1})

Install optional dependencies

If needed, you can install optional dependencies that extend the functionality of the W&B Python SDK. Replace extra with the desired optional dependency:
pip install wandb[extra]
For example, to install W&B with Google Cloud Storage support, run:
pip install wandb[gcp]
Install more than one optional dependency by separating them with commas:
pip install wandb[gcp,aws,media]
Use extras when you need deeper integration with specific platforms or features. For example:
  • Install gcp if you store datasets, models, or artifacts in Google Cloud Storage.
  • Install aws if you use Amazon S3 or other AWS-backed storage in your workflows.
  • Install media if you frequently log large or complex media (images, audio, video) and want better format support.

Supported optional dependencies

The following table lists supported dependencies for the W&B Python SDK and the extras you can install: