Guides / How to connect a Claude API key

How to connect a Claude API key: Claude Code, Cursor, your own code

A key with a Claude balance. Takes a couple of minutes to plug into Claude Code, Cursor, Cline or your project.

5 minutes · read

1. What's in the order

Keep the key like a password. Don't put it on GitHub, in screenshots or chats: anyone with it can spend your balance.

2. Claude Code

Claude Code is a coding agent for the terminal. Install it with the official guide.

macOS and Linux. Open a terminal and run (with your own values):

echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.zshrc
echo 'export ANTHROPIC_BASE_URL="address-from-the-order"' >> ~/.zshrc
source ~/.zshrc

No address in the order, skip the second line. On bash, use ~/.bashrc instead of ~/.zshrc.

Windows (PowerShell):

setx ANTHROPIC_API_KEY "your-key"
setx ANTHROPIC_BASE_URL "address-from-the-order"

After setx, close the terminal and open it again.

Now run claude in your project folder. If Claude Code asks whether to use the API key it found, pick Yes. /status inside shows the key is in use.

If you used to sign in to Claude Code with a subscription, run /logout so it takes the key, not the plan.

3. Cursor, Cline and other apps

4. Your own code

The official libraries read ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL from the environment by themselves. A quick check of the key from the terminal:

curl "${ANTHROPIC_BASE_URL:-https://api.anthropic.com}/v1/messages" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-sonnet-5-5", "max_tokens": 50, "messages": [{"role": "user", "content": "Hi!"}]}'

You get JSON back with Claude's text: it works.

Warranty

The warranty term is in the product description. If the key stops working within it, write to support with the order number and we replace the key. A used-up balance isn't a warranty case.

Check the key as soon as you get it: problems are easier to fix that way.

Errors and what to do

Still stuck, write to support @Volarchik: the order number and the error text.

Products this guide is for

Claude 100$ API · 30 days warranty$3.60API 10M Token Claude · 1 day warranty$2.20API 50M Token Claude · 2 days warranty$5.50Claude 500$ API · 30 days warranty$9.30

Other guides

How to buy: balance, payment, deliveryHow to sign in to a ready ChatGPT Plus accountRenewing a plan on your own account: ChatGPT, Claude, GrokHow to connect a Codex key: Codex CLI and IDEsHow to sign in to a ready Grok accountHow to activate Google AI Pro (Gemini) with a linkCHow to sign in to a CapCut Pro account