In this guide
A simple overview of Getting Started With the Claude API for Developers. Learn what it means, when it helps, and what to check first.
Anthropic's Claude models are a strong choice for building AI features — coding, analysis, agents, and long-context work. This quickstart gets you from zero to a working integration with the official SDK.
Install the SDK
npm install @anthropic-ai/sdkYour First Message
Set ANTHROPIC_API_KEY in your environment, then call the Messages API. claude-opus-4-8 is the most capable model; claude-haiku-4-5 is the fastest and cheapest.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic(); // reads ANTHROPIC_API_KEY from the environment
const response = await client.messages.create({
model: "claude-opus-4-8",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain RAG in two sentences." }],
});
for (const block of response.content) {
if (block.type === "text") console.log(block.text);
}Stream the Response
For chat UIs, stream tokens as they're generated so the reply appears in real time:
const stream = client.messages.stream({
model: "claude-opus-4-8",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a haiku about TypeScript." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}Choosing a Model
claude-opus-4-8— most capable, for complex reasoning and agentic work.claude-sonnet-4-6— the best balance of speed and intelligence.claude-haiku-4-5— fastest and most cost-effective for simple, high-volume tasks.
Keep Your Key Server-Side
Never ship your API key to the browser. Call Claude from your backend (a route handler or server action) and expose only your own endpoint to the client.
Next Steps
From here, add tool use to let Claude call your functions, system prompts to set behavior, and prompt caching to cut costs on repeated context.
Relevant Scaleup Infotech Services
Keep Reading
How to Build a RAG Application (Retrieval-Augmented Generation)
A simple guide to How to Build a RAG Application (Retrieval-Augmented Generation). Learn what to build first, what to check, and where mistakes usually happen.
2 min readVector Databases Explained: pgvector, Pinecone and Embeddings
A simple overview of Vector Databases Explained: pgvector, Pinecone and Embeddings. Learn what it means, when it helps, and what to check first.
1 min readPrompt Engineering Techniques That Actually Work
A simple overview of Prompt Engineering Techniques That Actually Work. Learn what it means, when it helps, and what to check first.
1 min read