Skip to main content

新しい APIキー を作成する

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, click your user profile icon, then click 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.
The full API key is only shown once at creation time. After you close the dialog, you cannot view the full API key again. Only the key ID (first part of the key) is visible in your settings. If you lose the full API key, you must create a new API key.
For secure storage options, see Store API keys securely.

APIキー を確認する

In Dedicated Cloud and Self-Managed:
  • Organization admins can find or list API keys for all organization users and service accounts.
  • Team admins can find or list API keys for service accounts in teams they administer.
  • Non-admin users can find or list their own API keys.
To find an API key, select the Personal API key or Service Account API key tab for details.
To find a personal API key owned by your user ID:
  1. Log in to W&B, click your user profile icon, then click User Settings.
  2. Scroll to the API Keys section.
The API keys table shows the key ID (the first part of each API key) for identification purposes. The full secret API key is only displayed once when you create it. If you need to use an existing key but do not have the full secret stored, you must create a new API key.

APIキー を削除する

APIキー を削除すると、その キー を使用しているすべての スクリプト やサービスからの アクセス 権が即座に無効になります。古い キー を削除する前に、すべてのシステムを新しい キー を使用するように更新したことを確認してください。
アクセス 権を無効にするには、APIキー を削除します。詳細については、Personal API key または Service Account API key タブを選択してください。
  1. wandb.ai/settings に移動します。
  2. API Keys セクションで、削除したい キー の横にある削除ボタンをクリックします。

APIキー を置換(ローテーション)する

APIキー を置換(ローテーション)するには:
  1. 新しい APIキー を作成します
  2. すべての スクリプト、サービス、および 環境 を新しい APIキー を使用するように更新します。
  3. すべての場所で新しい APIキー が正常に動作することをテストします。
  4. 古い APIキー を削除します。

Store and handle API keys securely

API keys provide access to your W&B account and should be protected like passwords. Follow these best practices:

What to avoid

  • Never commit API keys to version control systems such as Git.
  • Do not store API keys in plain text configuration files.
  • Do not pass API keys on the command line, because they will be visible in the output of OS commands like ps.
  • Avoid sharing API keys through email, chat, or other unencrypted channels.
  • Do not hard-code API keys in your source code.
If an API key is exposed, delete the API key from your W&B account immediately and contact support or your AISE.

Environment variables

When using API keys in your code, pass them through environment variables:
export WANDB_API_KEY="your-api-key-here"
This approach keeps keys out of your source code and makes it easier to rotate them when needed.
Avoid setting the environment variable in line with the command, because it will be visible in the output of OS commands like ps:
# Avoid this pattern, which can expose the API key in process managers
export WANDB_API_KEY="your-api-key-here" ./my-script.sh

SDK version compatibility

New API keys are longer than legacy keys. When authenticating with older versions of the wandb or weave SDKs, you may encounter an API key length error. Solution: Update to a newer SDK version:
  • wandb SDK v0.22.3+
    pip install --upgrade wandb==0.22.3
    
  • weave SDK v0.52.17+
    pip install --upgrade weave==0.52.17
    
If you cannot upgrade the SDK immediately, set the API key using the WANDB_API_KEY environment variable as a workaround.