Перевірити рівеньКурсиПрограмиДля командТарифи
RUУвійтиРеєстрація
Перевірити рівеньКурсиПрограмиДля командТарифиТест із ClaudeПромптиБлогПитання та відповідіПошукРеєстраціяRU
AcademlКурсиClaude API from A to ZThe Messages API structure
Повідомлення користувача з двох блоків, текст і картинка, та відповідь моделіТермінал Claude Code: команда claude -p з дозволеними Read та EditПовторні запити після помилки 429: пауза щоразу вдвічі довша, потім успіх
Курс

Claude API from A to Z

Модуль 1 · Getting Started
01Your first API call02The Messages API structure03Choosing a model
Модуль 2 · Prompt Engineering for Claude
04Designing system prompts05The 1M context window06XML tags in prompts07Few-shot prompting
Модуль 3 · Tool Use
08Tool Use basics09Tool patterns10Multi-turn conversations11Computer Use and Browser Use
Модуль 4 · Production
12Streaming13Message Batches API14Prompt Caching15Vision16Production patterns
Claude API from A to Z · Урок 2

The Messages API structure

system/user/assistant roles, content blocks (text, image), multi-turn conversations with thinking blocks, mid-conversation system messages, and strict JSON through structured outputs instead of prefill.

ENМатеріали курсів поки англійською. Інтерфейс, ШІ-наставник і перевірка завдань — українською.

22 хв читанняОновлено 23.11.20262 питання у квізіГотовий промпт включено

Three roles

  • system — instructions and behavior for the whole conversation, set with the top-level system parameter.
  • user — the user's turns.
  • assistant — the model's replies. You add these back into history for the next turn.
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY

const res = await client.messages.create({
  model: "claude-opus-5-5",
  max_tokens: 1024,
  system: "You are a concise technical assistant. Get to the point.",
  messages: [
    { role: "user", content: "What is idempotency?" },
  ],
});

for (const block of res.content) {
  if (block.type === "text") console.log(block.text);
}

Current Claude models use adaptive thinking by default, so thinking blocks may come before the text in res.content. Look for the block of type text; reading res.content[0].text is unreliable here.

Далі урок відкривається після безкоштовної реєстрації

Реєстрація через email або Google відкриває перші два уроки кожного курсу назавжди і 7 днів повного доступу до всього каталогу. Картка не потрібна.

Зареєструватися безкоштовноАбо пробний урок без реєстрації →
У цьому уроці
Three rolescontent can be a string or an array of blocksMulti-turn conversationA system instruction mid-conversationStrict JSON without prefillПрактикаГотовий промптКвіз
КурсиКурси з LLMДля командТарифиПитання та відповідіБлогПро насКонфіденційність
© 2026 AcademlРозробка та просування сайтів —MMIX — Marketing Mix
Почати безкоштовно