Skip to content

Set up the real thing

Read · 1 of 3

Get an API key

Create an account at the Anthropic Console and make an API key. New accounts usually get some free credit to experiment with; small agent runs cost fractions of a rupee.

Treat the key like a password. Never paste it into your code or commit it to GitHub: bots scan public repositories for keys within minutes. Put it in an environment variable instead, and the SDK reads it from there.

Open the Anthropic Console
Read this lesson as text

An API key, one package, and a rule: the key never goes in your code.

Get an API key

Create an account at the Anthropic Console and make an API key. New accounts usually get some free credit to experiment with; small agent runs cost fractions of a rupee.

Treat the key like a password. Never paste it into your code or commit it to GitHub: bots scan public repositories for keys within minutes. Put it in an environment variable instead, and the SDK reads it from there.

Install the SDK (Windows)

In a terminal (PowerShell):

py -m pip install anthropic

Save your key (Windows)

Replace the placeholder with your key, then close and reopen the terminal so it sees the new variable.

setx ANTHROPIC_API_KEY "paste-your-key-here"

Install the SDK (macOS)

In Terminal:

python3 -m pip install anthropic

Save your key (macOS)

This adds it to your shell's settings so every new terminal has it. Replace the placeholder with your key, then open a new terminal.

echo 'export ANTHROPIC_API_KEY="paste-your-key-here"' >> ~/.zshrc

Install the SDK (Linux)

In a terminal:

python3 -m pip install anthropic

Save your key (Linux)

Replace the placeholder with your key, then open a new terminal.

echo 'export ANTHROPIC_API_KEY="paste-your-key-here"' >> ~/.bashrc