CLAUDE LABJP
OPUS — Claude Opus 4.7 is generally available, improving software engineering, long-running coding, and higher-resolution visionAPIKEY — You can now set an expiration on API keys in the Console, with email reminders before keys valid for 7+ days expireREFLECT — A monthly recap at Settings > Reflect shows your top topics, most active day, and peak hour (beta)M365 — The Microsoft 365 connector now supports write tools for email, calendar, and OneDrive/SharePoint filesCOWORK — Cowork expands to web and mobile, bringing Chat and Cowork into one shared home across devicesDESIGN — Claude Design, a new Anthropic Labs product, lets you co-create designs, prototypes, slides, and one-pagersOPUS — Claude Opus 4.7 is generally available, improving software engineering, long-running coding, and higher-resolution visionAPIKEY — You can now set an expiration on API keys in the Console, with email reminders before keys valid for 7+ days expireREFLECT — A monthly recap at Settings > Reflect shows your top topics, most active day, and peak hour (beta)M365 — The Microsoft 365 connector now supports write tools for email, calendar, and OneDrive/SharePoint filesCOWORK — Cowork expands to web and mobile, bringing Chat and Cowork into one shared home across devicesDESIGN — Claude Design, a new Anthropic Labs product, lets you co-create designs, prototypes, slides, and one-pagers
Articles/API & SDK
API & SDK/2026-03-04Intermediate

Claude API Quickstart — Your First API Call in 5 Minutes

Get started with the Claude API. From obtaining your API key to making your first request with Python and TypeScript SDKs — a 5-minute quickstart guide.

API26SDK4Python17TypeScript23Development3

The Claude API becomes remarkably easy to work with once you've made that very first call. From wiring up my own services as an indie developer, I've found the hard part isn't grasping the concepts — it's knowing the right order to get a minimal setup running. This guide lays out that path, from getting your API key to your first Python and TypeScript request, so you can reach a working call in five minutes without detours.

What is the Claude API?

The Claude API lets you integrate Claude's capabilities into your own applications. Through Anthropic's developer platform, you can programmatically access text generation, code generation, analysis, summarization, and more.

ℹ️
Using the API requires an Anthropic account and an API key. Free credits are provided, so you can start experimenting right away.

Getting Your API Key

  1. Visit console.anthropic.com
  2. Create an account or log in
  3. Navigate to the "API Keys" section and create a new key
  4. Save the key securely (it's only shown once)
# Set as environment variable
export ANTHROPIC_API_KEY="sk-ant-..."

Python SDK

Installation

pip install anthropic

Your First Request

import anthropic
 
client = anthropic.Anthropic()
 
message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Write a prime number checker in Python"}
    ]
)
 
print(message.content[0].text)

Streaming Responses

For real-time output:

with client.messages.stream(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain the basics of machine learning"}
    ]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

TypeScript SDK

Installation

npm install @anthropic-ai/sdk

Your First Request

import Anthropic from "@anthropic-ai/sdk";
 
const client = new Anthropic();
 
const message = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "Implement FizzBuzz in TypeScript" }
  ],
});
 
console.log(message.content[0].text);

Key Parameters

ParameterDescriptionExample
modelModel to useclaude-opus-4-6, claude-sonnet-4-6
max_tokensMaximum output tokens1024, 4096
temperatureRandomness (0–1)0 = deterministic, 1 = creative
systemSystem prompt"You are a Python expert"
stop_sequencesStop strings["nn"]

Using System Prompts

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system="You are a senior software engineer. Always include code examples and comment on performance.",
    messages=[
        {"role": "user", "content": "What are effective caching strategies?"}
    ]
)
💡
System prompts are a powerful way to consistently control Claude's behavior. Use them for expert personas, standardized output formats, and domain-specific rules.

Tool Use (Function Calling)

The Claude API supports calling external functions:

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    tools=[
        {
            "name": "get_weather",
            "description": "Get weather for a given city",
            "input_schema": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string",
                        "description": "City name (e.g., Tokyo)"
                    }
                },
                "required": ["city"]
            }
        }
    ],
    messages=[
        {"role": "user", "content": "What's the weather in Tokyo?"}
    ]
)

Choosing the Right Model

ModelStrengthsBest For
Claude Opus 4.6Highest capability, deep reasoningComplex analysis, high-quality code
Claude Sonnet 4.6Balanced speed and qualityEveryday tasks, chatbots
Claude Haiku 4.5Fastest, lowest costHigh-volume processing, classification
⚠️
API usage is billed per token. In production, manage `max_tokens` settings and rate limits carefully.

Next Steps

  • Vision (Image Input) — Analyze and describe images via the API
  • Advanced Tool Use — Automate complex multi-step workflows
  • Batch Processing — Handle large volumes of requests efficiently
  • MCP Integration — Connect services with Model Context Protocol

As an indie developer running the Dolice Labs sites, the thing that actually slowed down my first call wasn't auth — it was guessing the right model string. Run the official minimal sample untouched first, then immediately rewrite it into the smallest version of your own use case. That order is what gets you from zero to a working call in five minutes.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

API & SDK2026-07-12
A Long Non-Streaming Response Was Billed Twice Past the 10-Minute Wall: Redesigning the SDK's Default Timeout and Retries
The Anthropic SDK's default 10-minute timeout and two automatic retries can silently re-run a long non-streaming response and bill you twice. Here is how the trap works, and how to close it with streaming, explicit timeout/max_retries, and a small local ledger — with measured before/after numbers.
API & SDK2026-04-11
Migrating from OpenAI to the Claude API: Code Conversion to Zero-Downtime Production Rollout (2026)
How to migrate from OpenAI GPT-4 to the Claude API: authentication, message-format conversion, streaming, tool use, error handling, and a zero-downtime phased rollout, all with full implementation code.
API & SDK2026-03-15
Building an AI Chatbot with Claude API — Streaming, Conversation History & Cost Optimization
Build a production-ready AI chatbot with the Claude API from scratch. Learn streaming responses, conversation history management, and token cost optimization with working code examples.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →