Getting Started with the Claude API: Your First Call (Developer Intro)

How a developer makes their first Claude API call: getting a key, x-api-key auth, the first Messages endpoint call (curl), model strings, and how billing works.

🌐 This article was machine-translated and may contain inaccuracies. Refer to the Korean original if in doubt.

If you want to call Claude directly from your code, use the API. This is a beginner's guide that walks a developer through making their first Claude API call. (As of May 2026. Models and pricing may change — check the official docs for the latest.)

How the API differs from chat (claude.ai)

The claude.ai chat product and the API are separate products.

  • claude.ai / app: the interface where people chat directly. Used via a Pro/Max subscription.
  • API: the channel through which your program calls Claude. Get a key from the console and you're billed by token usage.

Important: a Pro/Max subscription and API usage are separate. Subscribing doesn't make the API free; the API is billed per token. There's no ongoing free tier, though new accounts sometimes get a small one-time credit.

Step 1: Account and API key

  1. Sign up / log in to the developer platform (platform.claude.com, the console).
  2. Create a new key under API Keys in settings.
  3. The full key is shown only once, so store it somewhere safe. The key is like a password — anyone who has it can spend your usage.
  4. Don't hard-code the key; handle it via an environment variable.
export ANTHROPIC_API_KEY='your-key-here'

Step 2: Your first API call (curl)

The foundation of the Claude API is the Messages endpoint. Here's the simplest possible call.

curl 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-4-6",
    "max_tokens": 1024,
    "messages": [
      { "role": "user", "content": "Hello, Claude!" }
    ]
  }'

On success you get HTTP 200 with a JSON response. The content array holds Claude's reply text, and usage holds the input/output token counts.

Three headers you must know

  • x-api-key — the auth key. (Different from OpenAI's Authorization: Bearer — Anthropic uses a custom header.)
  • anthropic-version — the API version, currently 2023-06-01. Required on every request.
  • content-typeapplication/json

If you use the official SDKs (Python, TypeScript, etc.), these headers are added automatically.

Model strings (as of May 2026)

In production, use the full versioned model string (an unversioned alias may resolve to a different model over time).

  • claude-opus-4-7 — maximum capability
  • claude-sonnet-4-6 — balanced (recommended default for most tasks)
  • claude-haiku-4-5-20251001 — speed and low cost

Sonnet is enough for most tasks; reserve Opus for genuinely demanding reasoning to stay cost-efficient.

Cost and limits

The API is billed by input/output token count. Per-model rates differ (Opus is the most expensive, Haiku the cheapest); check exact rates in the official docs. There are per-tier rate and spend limits that increase automatically with usage, and you can view your current limits in the console.

Next steps

  • Learn the core Messages API patterns: multi-turn conversations, system prompts, stop reasons
  • Use tool use (function calling) to let Claude invoke external functions
  • Optimize cost and latency with streaming responses, batch processing, and prompt caching

This article is for general guidance only. Model strings, pricing, limits, and the API version may change per Anthropic's policies. Always verify the latest values in the official docs (docs.claude.com) before implementing. (As of May 2026)