Anthropic Claude API
Claude's API — models particularly strong in code, long-form content and textual analysis.
About this API
Anthropic is a leading AI provider alongside OpenAI and Google. The Claude family (Haiku, Sonnet, Opus) is known for strong code, long-context analysis (up to 200K tokens) and the Constitutional AI approach that produces careful, accurate responses. The API is simple — a messages request, a clean response — priced similarly to OpenAI.
Who it's for
Coding and dev tools
Long-document summarization
Long-form, high-quality content
Products needing careful outputs
How to use it
- 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.
Installation & setup
`npm install @anthropic-ai/sdk` (Node) or `pip install anthropic` (Python). max_tokens is required (unlike OpenAI).
Code examples
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);Sample response
{
"id": "msg_01ABC…",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-20250514",
"content": [
{
"type": "text",
"text": "לפי המאמר, …"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 1250,
"output_tokens": 180
}
}FAQ
Code, long-document summarization, outputs needing care.
Tips & pitfalls
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.