How to use Anthropic Claude API — a practical guide
If you're here, you probably want working code in five minutes. That's exactly what this guide does.
Five steps to get started
- 1Register at console.anthropic.com.
- 2Create a key (sk-ant-…).
- 3Install the SDK: `npm install @anthropic-ai/sdk`.
- 4Call messages.create with model, max_tokens, messages.
Shortest snippet that will actually run
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const msg = await client.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [
{ role: "user", content: "סכם את המאמר הזה בפסקה אחת: ..." },
],
});
console.log(msg.content[0].text);Common mistakes (the honest list)
Use Haiku for cheap/fast, Sonnet for balance, Opus for hardest tasks.
Claude's system prompt is a separate field (system), not a role inside messages.