Skip to content

SOP-001: Getting Started with Claude API

Fresh

Source: Building with the Claude API

Document Control

FieldValue
SOP IDSOP-001
Version1.0
StatusActive
Last Updated2024-12

Overview

This procedure covers setting up the Anthropic Claude API for direct integration.

Prerequisites

  • Python 3.8+ installed
  • Basic JSON knowledge
  • Anthropic API key

Setup Process

Step 1: Get API Key

  1. Navigate to console.anthropic.com
  2. Sign up or log in
  3. Go to API Keys section
  4. Click Create Key
  5. Copy and save securely

Security

Never commit API keys to version control. Use environment variables.

Step 2: Install SDK

bash
pip install anthropic

Or with specific version:

bash
pip install anthropic==0.39.0

Step 3: Configure Environment

Option A: Environment Variable

bash
export ANTHROPIC_API_KEY="sk-ant-api03-..."

Option B: .env file

ANTHROPIC_API_KEY=sk-ant-api03-...

Step 4: Test API Call

python
import anthropic

client = anthropic.Anthropic()  # Uses ANTHROPIC_API_KEY env var

message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude!"}
    ]
)

print(message.content[0].text)

Available Models

Verification Checklist

  • [ ] API key obtained from console
  • [ ] SDK installed successfully
  • [ ] Environment variable configured
  • [ ] Test call returns response
  • [ ] No errors in console

Troubleshooting

IssueSolution
AuthenticationErrorCheck API key is correct
RateLimitErrorWait and retry, or upgrade tier
InvalidRequestErrorCheck message format
Connection ErrorCheck network/firewall

See Also

Based on Anthropic Academy courses