AIUnlimited
🌳

Fondations IA

đŸŒ±
AI Seeds

Partez de zéro

🌿
AI Sprouts

Construisez les fondations

🌳
AI Branches

Mettez en pratique

đŸ•ïž
AI Canopy

Approfondissez

đŸŒČ
AI Forest

MaĂźtrisez l'IA

🔹

MaĂźtrise IA

✏
AI Sketch

Partez de zéro

đŸȘš
AI Chisel

Construisez les fondations

⚒
AI Craft

Mettez en pratique

💎
AI Polish

Approfondissez

🏆
AI Masterpiece

MaĂźtrisez l'IA

📘

Pratique IA

📖
Comprendre les modĂšles open-source

Fondamentaux et ressources pour les modĂšles open-source

🎯
Du problĂšme Ă  la tĂąche modĂšles

Transformer les problÚmes métier en tùches modÚles

⚡
Exécuter votre premier modÚle

Voyez vos premiers résultats en 30 minutes

🔧
Fine-tuning et évaluation

Affinez les modÚles et évaluez les performances

🚀
SystĂšmes d'application

Construisez des applications IA réelles

🎹
IA générative

Explorez les modĂšles AIGC open-source

đŸ€–
Agents

Apprenez les frameworks Agent et outils MCP

📐
Fondamentaux supplémentaires

Bases LLM et évaluation

🎓

Claude Académie

đŸ€–
Claude 101

Learn AI basics with Claude

đŸ’»
Claude Code 101

Code with Claude as your pair programmer

đŸ€
Introduction to Claude Cowork

Collaborate with Claude on complex projects

⚙
Claude Platform 101

Build apps with the Claude API

Labo

7 expériences chargées
🧬Bac Ă  sable neuronalđŸ€–IA ou Humain ?đŸ„‹Dojo d'ingĂ©nierie de prompts🏁Course d'algorithmes🧠Quiz IAđŸ—ïžCanevas de conception systĂšme
🎯Entretien simulĂ©Entrer dans le labo→
🚀

Développement de carriÚre

🚀
Rampe de lancement entretien

Commencez votre parcours

🌟
MaĂźtrise comportementale

Maßtrisez les compétences relationnelles

đŸ’»
Entretiens techniques

Réussissez l'épreuve de code

đŸ€–
Entretiens IA et ML

MaĂźtrisez l'entretien ML

🏆
Offre et au-delĂ 

Décrochez la meilleure offre

Commencer
AIUnlimited

Licence MIT

æČȘICP怇18025655ć·-11

Apprendre

  • Bases de l'IA
  • Pratique IA
  • Claude AcadĂ©mie
  • Labo
  • DĂ©veloppement de carriĂšre

Communauté

  • À propos
  • FAQ

Soutien

  • Conditions d'utilisation
  • Politique de confidentialitĂ©
  • Contact
Programmes d'IA et d'ingĂ©nierieâ€ș⚙ Claude Platform 101â€șLeçonsâ€șYour First API Call
🚀
Claude Platform 101 ‱ DĂ©butant⏱ 5 min de lecture

Your First API Call

Your first API call

Saying hi to Claude might warm your heart, but it's not really useful. In this lesson we'll send Claude something real and get structured insight back — in just under 20 lines of code.

Get set up

First, grab an API key from platform.claude.com. You'll need to purchase some credits beforehand.

Take the API key and store it in a .env.local file so it stays out of your version control. Hardcoding keys in source files is how they end up leaked on GitHub — keep them in environment files instead.

Next, install the SDK:

npm install @anthropic-ai/sdk

The anatomy of a request

Every API call goes through the messages.create function. You specify three things:

  • A model — which Claude model handles the request
  • A max tokens limit — a cap on how long the response can be
  • A list of messages — objects with either user or assistant roles, structured similarly to how you'd have a conversation with Claude elsewhere

Here's what that looks like in its most basic form:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const msg = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 2048,
  messages: [{
    role: "user",
    content: "Hello, Claude",
  }],
});

A real example: reviewing buggy code

Let's give Claude something a little more interesting than "hello." We'll point it at some buggy code and ask for a review. Here's the whole thing — one file, about 20 lines of code:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const buggyCode = `
function add(a, b) {
  return a - b;
}
`;

const response = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 2048,
  system: "You are a terse senior code reviewer. Give feedback in one paragraph.",
  messages: [
    { role: "user", content: `Review this code:\n${buggyCode}` },
  ],
});

for (const block of response.content) {
  if (block.type === "text") {
    console.log(block.text);
  }
}
Leçon 2 sur 130% terminé
←What is the Claude Platform?

Discussion

Se connecter pour rejoindre la discussion

Two things to notice here:

  1. The system prompt is where you shape the persona. I want a terse senior reviewer, not a chatty one — so I just say that.
  2. The message.content in the response is an array of blocks, not a string. For a basic text reply there's usually just one block of type text, but Claude can return multiple blocks — text, tool calls, thinking — so we always loop and check the type.

Run it, and Claude spots that add is subtracting and tells you in one paragraph. That's it. That's the whole API call.

From script to product

In a real product, this same messages.create shape is the engine behind something like a summarize endpoint. Pull a meeting transcript out of the database, hand it to Claude with a system prompt that says "extract insights and risks," save the result back on the row, and return it to the UI. It's the same call — just wrapped in a route handler.

Recap

  • Your first API call is a messages.create function with a model, a token limit, and messages.
  • Store your API key in a .env.local file to keep it out of version control.
  • Add a system prompt to shape Claude's behavior.
  • The response content is an array of blocks — loop and check each block's type.
  • From here, everything builds on this pattern.