1. Import the SDK
The official @anthropic-ai/sdk package gives you the typed Anthropic client used to call Claude.
import Anthropic from "@anthropic-ai/sdk";Typorithm · easy
Step 1 of 8 · intro card
Prompt Engineering
A Claude request sets a system prompt to define the model's role, passes a messages list of alternating user/assistant turns, picks a model id, and caps the reply length with max_tokens.
The system prompt is separate from the conversation: it sets the model's persona, tone, and rules. "You are a terse expert." steers every reply without being part of the visible chat.
messages is a list of turns that alternate between user and assistant. The first turn is always a user turn; the model produces the next assistant turn as its response.
You choose the model per request (claude-opus-4-8 is the most capable) and bound the output with max_tokens so a reply can't run on indefinitely.
system sets the model's role and behavior.
messages holds alternating user/assistant turns.
model picks the model; max_tokens caps the reply.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const msg = await client.messages.create({
model: "claude-opus-4-8",
max_tokens: 1024,
system: "You are a terse expert.",
messages: [{ role: "user", content: "Explain TLS." }],
});Connect each part of the code to the concept before you type.
The official @anthropic-ai/sdk package gives you the typed Anthropic client used to call Claude.
import Anthropic from "@anthropic-ai/sdk";claude-opus-4-8 is the most capable model; you pick the model per request by its id.
model: "claude-opus-4-8",max_tokens caps how many tokens the model may generate in its reply.
max_tokens: 1024,The system prompt sets the model's role and behavior for the whole conversation.
system: "You are a terse expert.",messages is the list of alternating user/assistant turns; here it holds a single user question.
messages: [{ role: "user", content: "Explain TLS." }],Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.