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 inwandb v0.22.3, so upgrading to that version or later resolves the error:
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_KEYin the environment instead of usingwandb login. Some older SDK versions skip local length checks. Replace[API-KEY]with your W&B 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