What Is the Claude API?
The Claude API is a developer interface for integrating Anthropic’s generative AI models into your own applications or business tools. As of 2025, the Messages API is the core and makes it relatively easy to implement responses for chat, summarization, classification, code assistance, and internal knowledge search.
There are three key points that beginners should focus on first:
- Manage your API key securely: never hard-code it in source code
- Build a minimal setup with the Messages API: start with a single request/response round
- Understand streaming and token management: both directly impact perceived speed and cost
This article walks through everything from setting up Python/TypeScript to building a minimal chatbot, enabling streaming, and understanding pricing—practically from an implementation perspective.
Getting Started: Get Your API Key and Configure It Safely
First, issue an API key in Anthropic’s developer console. After you generate it, the standard approach is to manage it via environment variables. Accidentally committing it to GitHub is immediately risky, so use .env files for local development and secret management in your cloud environment.
Example Configuration in Python
export ANTHROPIC_API_KEY="your_api_key_here"Example Configuration in Node.js/TypeScript
export ANTHROPIC_API_KEY="your_api_key_here"For local development, you can also use python-dotenv or dotenv. In production, we recommend using Vercel, AWS Secrets Manager, Google Secret Manager, and similar services.
Installing the SDK
You can call the Claude API directly over HTTP, but it’s faster to start with the official SDK.
Python
pip install anthropicTypeScript / Node.js
npm install @anthropic-ai/sdkCompared to calling HTTP directly, the SDK’s advantages include easier authentication setup, streaming handling, and more comfortable type completion. In particular, TypeScript makes it easier to follow the response structure, improving maintainability.
Basics of the Messages API
The center of the Claude API is the Messages API. The concepts are simple: specify model, max_tokens, and messages to get a response. The typical approach is to keep conversation history on your side and send it each time.
Minimal Python Example
from anthropic import Anthropic
import os
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=300,
system="あなたは簡潔で実務的な日本語アシスタントです。",
messages=[
{"role": "user", "content": "ECサイトの商品説明文を100文字で作ってください。防水バッグです。"}
]
)
print(response.content[0].text)