Fill these in once
- Save the key in your shell settings and load it
echo 'export ANTHROPIC_API_KEY="paste-your-key-here"' >> ~/.zshrc source ~/.zshrcKeep keys out of your code and out of Git. Anyone with the key can spend on your account.
Check it worked
- Check it's set, without printing it
[ -n "$ANTHROPIC_API_KEY" ] && echo "ANTHROPIC_API_KEY is set"
Undo it
- Remove it
sed -i '' '/^export ANTHROPIC_API_KEY=/d' ~/.zshrc && unset ANTHROPIC_API_KEY
- Save the key in your shell settings and load it
echo 'export ANTHROPIC_API_KEY="paste-your-key-here"' >> ~/.bashrc source ~/.bashrcKeep keys out of your code and out of Git. Anyone with the key can spend on your account.
Check it worked
- Check it's set, without printing it
[ -n "$ANTHROPIC_API_KEY" ] && echo "ANTHROPIC_API_KEY is set"
Undo it
- Remove it
sed -i '/^export ANTHROPIC_API_KEY=/d' ~/.bashrc && unset ANTHROPIC_API_KEY
- Save the key for your user
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "paste-your-key-here", "User")Close and reopen PowerShell afterwards. Keep keys out of your code and out of Git.
Check it worked
- Check it's set, without printing it
if ([Environment]::GetEnvironmentVariable("ANTHROPIC_API_KEY", "User")) { "ANTHROPIC_API_KEY is set" }
Undo it
- Remove it
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")