Anthropic() is created successfully, but the first call returns an invalid-key error.
Why this happens
The environment variable may be absent in the process that runs the program, the key may have been copied incorrectly, or the account/project may not authorize the request.
Answer 1: Set ANTHROPIC_API_KEY outside the source code
$env:ANTHROPIC_API_KEY = "your_key_here"
python app.py
from anthropic import Anthropic
client = Anthropic()
