Set API key for Claude Code in Cursor, VS Code, ... instead of personal usage

From Memora, the internal wiki

Setting an environment variable, which works across both Cursor and VS Code.

Environment variable (recommended)

Add your key to your shell profile so it's always available:


Run this in PowerShell — replace sk-ant-... with your actual key:

[System.Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-ant-...", "User")

This sets it as a permanent user-level environment variable (survives reboots)


Important notes:

If you previously logged in with a personal/org account, run claude logout in the terminal first so it stops using the old session.

⚠Auth conflict: Both a token (claude.ai) and an API key (ANTHROPIC_API_KEY) are set. This may lead to unexpected behavior.

• Trying to use claude.ai? Unset the ANTHROPIC_API_KEY environment variable, or claude /logout then say "No" to the API key approval before

login.

• Trying to use ANTHROPIC_API_KEY? claude /logout to sign out of claude.ai.


Uitloggen. Claude Code opnieuw starten.

Settings opnieuw doorlopen, aanmelden met account en dan kom je hier:



==> YES.