[ ABORT TO HUD ]
SEQ. 1

SDK Installation & Setup

📦 Official SDKs15 min100 BASE XP⌨ HANDS-ON LAB

Official SDK Ecosystem

Anthropic provides first-party SDKs for four languages: Python, TypeScript, Go, and Java. These SDKs wrap the raw REST API with idiomatic helpers, type safety, automatic retries, and streaming utilities — dramatically reducing boilerplate and improving reliability in production.

Python SDK

The Python SDK (anthropic) is the most mature and widely used. It provides synchronous and async clients, streaming helpers, and full type annotations.

# Installation
pip install anthropic

# Basic usage
import anthropic

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

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

# Streaming
with client.messages.stream(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a poem."}]
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

TypeScript SDK

The TypeScript SDK (@anthropic-ai/sdk) provides full type safety, streaming iterators, and works in both Node.js and edge runtimes (Deno, Bun, Cloudflare Workers).

// Installation
// npm install @anthropic-ai/sdk

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

const client = new Anthropic();  // Uses ANTHROPIC_API_KEY env var

const message = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude!" }]
});
console.log(message.content[0].text);

// Streaming
const stream = client.messages.stream({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Write a haiku." }]
});
for await (const event of stream) {
  if (event.type === "content_block_delta") {
    process.stdout.write(event.delta.text);
  }
}

Go & Java SDKs

Anthropic also offers official SDKs for Go (github.com/anthropics/anthropic-sdk-go) and Java (com.anthropic:anthropic-java). Both provide idiomatic interfaces, streaming support, and automatic retries.

Common SDK Features

FeatureDescription
Automatic RetriesAll SDKs implement exponential backoff with jitter for 429 and 5xx errors (default: 2 retries).
Streaming HelpersHigh-level abstractions for SSE streaming — no manual event parsing required.
Type SafetyFull type definitions for all request/response objects, enabling IDE autocompletion and compile-time checks.
WIF SupportWorkload Identity Federation for GCP and AWS — authenticate without static API keys using cloud-native identity.
Environment ConfigAPI key auto-loaded from ANTHROPIC_API_KEY environment variable. Base URL configurable for proxies.
🔑 Enterprise Tip: For production deployments on GCP or AWS, use Workload Identity Federation (WIF) instead of static API keys. The SDKs support WIF natively — your application authenticates using its cloud service account, eliminating the need to manage and rotate API keys.
⌨ HANDS-ON LABInstall the Official SDKs
⭐ +100 XP

Provision both official Anthropic SDKs — Python for data pipelines, TypeScript for your web stack.

1Install the official Python SDK with pip.
2Install the official TypeScript/Node SDK with npm.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 3
Which environment variable do all Anthropic SDKs auto-detect for authentication?
CLAUDE_API_KEY
ANTHROPIC_API_KEY
CLAUDE_SECRET
API_TOKEN
SDK Installation & Setup Tutorial | Official SDKs — Claude Academy