DEV Community

Cover image for How to Use the Claude API (Secure Setup + Pricing Table)
junaid
junaid

Posted on

How to Use the Claude API (Secure Setup + Pricing Table)

Claude by Anthropic is quickly becoming one of the most developer-friendly AI APIs. This post will show you how to:

  • Get your Claude API key
  • Store it securely
  • Test with curl, Python, and Node.js
  • Compare model pricing

Step 1: Get Your API Key

  1. Sign up at the Anthropic Console
  2. Verify your email (check spam if it doesn’t arrive).
  3. Navigate to Settings → API Keys → Create Key.

    ⚠️ Keys are shown once — copy it safely.

Step 2: Store in .env

ANTHROPIC_API_KEY=your_key_here

Step 3: Test with Python

import anthropic, os
client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
msg = client.messages.create(
model="claude-3-haiku-20240307",
max_tokens=100,
messages=[{"role": "user", "content": "Hello, Claude!"}]
)
print(msg.content)

Pricing Table (2025)

Claude Pricing (2025)

Claude 4 Opus
Input: $15.00 per 1M

Output: $75.00 per 1M

Notes: Flagship, complex reasoning

*Claude 4 Sonnet *
Input: $3.00 (≤200K)

Output: $15.00 (≤200K)

Notes: Beta 1M context window beyond 200K

Claude 3.7 Sonnet
Input: $3.00 per 1M

Output: $15.00 per 1M

Notes: Assumed pricing

Claude 3.5 Sonnet
Input: $3.00 per 1M

Output: $15.00 per 1M

Notes: Balanced model

Claude 3.5 Haiku
Input: $0.80 per 1M

Output: $4.00 per 1M

Notes: Cost-efficient

Claude 3 Opus
Input: $15.00 per 1M

Output: $75.00 per 1M

Notes: High-performance legacy

Claude 3 Sonnet

Input: $3.00 per 1M

Output: $15.00 per 1M

Notes: Legacy

Claude 3 Haiku
Input: $0.25 per 1M

Output: $1.25 per 1M

Notes: Most affordable

✅ That’s it! You now have Claude API set up, secured, and running.

👉 Want complete tutorials on Claude api key, check out NapNox.com
.

Top comments (0)