Skip to content

SOP: Get Started with Claude API ​

Updated: 2026-05-26

Set up your Anthropic API key and make your first successful call to Claude.

Prerequisites ​

  • Anthropic Console account with billing configured
  • API key generated from the Console
  • cURL or a terminal with Python/Node.js installed

Steps ​

Step 1: Set Your API Key ​

bash
export ANTHROPIC_API_KEY='sk-ant-...'

Persist across sessions by adding to ~/.zshrc or ~/.bashrc.

Step 2: Make Your First API Call ​

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, Claude"}
    ]
  }'

Step 3: Verify the Response ​

A successful response looks like:

json
{
  "id": "msg_01...",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "model": "claude-sonnet-4-6",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 10
  }
}

Verification Checklist ​

  • [ ] API key is set as environment variable
  • [ ] curl returns 200 (not 401 unauthorized)
  • [ ] Response contains type: "message"
  • [ ] Response contains assistant text in content[0].text
  • [ ] usage object shows token counts

See Also ​