BeClaude
GuideBeginnerAPI2026-05-21

Your First Steps with Claude: A Complete API Quickstart Guide

Learn how to get started with the Claude API in minutes. This guide covers account setup, authentication, and your first API call using Python, TypeScript, and cURL.

Quick Answer

This guide walks you through creating an Anthropic Console account, obtaining an API key, and making your first call to the Claude API using cURL, Python, or TypeScript. You'll learn the core Messages API pattern and where to go next.

Claude APIQuickstartPythonTypeScriptMessages API

Introduction

Welcome to the Claude API. Whether you're building a chatbot, an AI-powered tool, or integrating Claude into your existing application, this guide will get you from zero to your first API call in minutes. We'll cover everything from account setup to running your first request using cURL, Python, or TypeScript.

By the end of this guide, you'll have a working API integration and a clear understanding of the core patterns you'll use in every Claude-powered project.

Prerequisites

Before you start, you'll need:

  • An Anthropic Console account – Sign up at console.anthropic.com
  • An API key – Generated from the Console dashboard after logging in
  • Basic familiarity with the command line – For cURL or SDK setup
  • Python 3.7+ or Node.js 14+ – If you plan to use the SDKs

Step 1: Create Your Anthropic Console Account

  • Navigate to console.anthropic.com
  • Click Sign Up and follow the registration flow (email + password, or Google/GitHub OAuth)
  • Verify your email address if prompted
  • Once logged in, you'll land on the Console dashboard
Tip: The Console also provides a web-based Playground where you can test prompts before writing any code. It's a great way to experiment with Claude's behavior.

Step 2: Get Your API Key

  • From the Console dashboard, click on API Keys in the left sidebar
  • Click Create Key
  • Give your key a descriptive name (e.g., "Development" or "My App")
  • Copy the generated key immediately – you won't be able to see it again
  • Store it securely (use environment variables, not hardcoded in your source code)
# Recommended: store as an environment variable
export ANTHROPIC_API_KEY="sk-ant-..."

Step 3: Make Your First API Call

You can call the Claude API using raw HTTP (cURL) or one of the official SDKs. We'll show all three approaches.

Option A: cURL (Quickest Test)

Open your terminal and run:

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-3-5-sonnet-20241022",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Hello, Claude!"}
    ]
  }'

You should receive a JSON response containing Claude's greeting.

Option B: Python SDK

First, install the SDK:

pip install anthropic

Then create a file hello_claude.py:

import anthropic

client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY from environment

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

print(message.content[0].text)

Run it:

python hello_claude.py

Option C: TypeScript SDK

First, install the SDK:

npm install @anthropic-ai/sdk

Then create a file hello_claude.ts:

import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic(); // reads ANTHROPIC_API_KEY from environment

async function main() { const message = await client.messages.create({ model: 'claude-3-5-sonnet-20241022', max_tokens: 1024, messages: [ { role: 'user', content: 'Hello, Claude!' } ] });

console.log(message.content[0].text); }

main();

Run it (using ts-node or compile first):

npx ts-node hello_claude.ts

Understanding the Response

When you make a successful API call, the response contains several important fields:

  • id – Unique identifier for the message
  • type – Always "message"
  • role – Always "assistant"
  • content – Array of content blocks (usually one text block)
  • model – The model that generated the response
  • stop_reason – Why the generation stopped (e.g., "end_turn", "max_tokens", "stop_sequence")
  • usage – Token counts for input and output
Example response snippet:
{
  "id": "msg_01ABC123...",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "model": "claude-3-5-sonnet-20241022",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 10
  }
}

Next Steps: Core Patterns to Learn

You've made your first API call. Now it's time to build on that foundation. Here are the essential patterns you'll use in every Claude integration:

1. Multi-turn Conversations

Send a list of messages to maintain context across turns:

messages = [
    {"role": "user", "content": "What's the capital of France?"},
    {"role": "assistant", "content": "The capital of France is Paris."},
    {"role": "user", "content": "What is it famous for?"}
]

2. System Prompts

Set the behavior and persona of Claude using a system prompt:

response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    system="You are a helpful assistant that speaks like a pirate.",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tell me about the weather."}]
)

3. Handling Stop Reasons

Check stop_reason to understand why Claude stopped generating:

  • "end_turn" – Claude finished naturally
  • "max_tokens" – Hit the token limit; you may need to continue
  • "stop_sequence" – A custom stop sequence was encountered
  • "tool_use" – Claude wants to call a tool (advanced)

4. Streaming Responses

For real-time output, use streaming:

stream = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True
)

for chunk in stream: if chunk.type == "content_block_delta": print(chunk.delta.text, end="")

Explore Further

Once you're comfortable with the basics, dive into these resources:

  • Models Overview – Compare Claude models by capability, speed, and cost
  • Features Overview – Browse all capabilities: tools, context management, structured outputs, and more
  • Client SDKs – Reference docs for Python, TypeScript, Java, and other libraries
  • Messages API Guide – Deep dive into all API parameters

Key Takeaways

  • Get started in minutes: Sign up for an Anthropic Console account, generate an API key, and make your first call with cURL, Python, or TypeScript.
  • Master the Messages API: All interactions use the /v1/messages endpoint with a simple messages array structure.
  • Use environment variables: Always store your API key in ANTHROPIC_API_KEY – never hardcode it.
  • Learn core patterns: Multi-turn conversations, system prompts, stop reasons, and streaming are essential for building real applications.
  • Explore the ecosystem: Claude supports tools, structured outputs, prompt caching, and much more – the API docs are your best friend.