Skip to main content
W&B now issues longer API keys (about 86 characters). Older wandb SDK versions validate exactly 40 characters and reject the new format: ValueError: API key must be 40 characters long, yours was 86 On Dedicated Cloud or Self-Managed instances, the message may instead be ERROR API key must be 40 characters long, yours was 86.

Upgrade the wandb SDK

Support for longer API keys was added in wandb v0.22.3, so upgrading to that version or later resolves the error:
pip install -U wandb
wandb login --relogin

If you cannot upgrade the SDK

  • If a legacy 40-character key is still active on your account, keep using it. New-format keys do not automatically revoke legacy keys.
  • If you deleted the legacy key and cannot upgrade, contact support@wandb.com. Dedicated Cloud and Self-Managed deployments might be able to issue a legacy-format key.
  • As a workaround, set WANDB_API_KEY in the environment instead of using wandb login. Some older SDK versions skip local length checks. Replace [API-KEY] with your W&B API key:
    export WANDB_API_KEY=[API-KEY]
    

Different error: key reported as too short

API key must have 40+ characters, has 20 can appear when calling wandb.Api().viewer.generate_api_key() in certain SDK versions. This is separate from the longer-key format migration. Upgrade the SDK. If the error persists after upgrading, contact support@wandb.com. For more information, see How do I find my API key? and SDK release notes.
API Keys Authentication SDK