INITIALIZING SECURE CHANNEL...
CPU MEM NET PING9.2 ms SECSECURED
COFFEE—WEB v4.0 // eu-1
ONLINE 2 847 --:--:--
/english > 42. Claude API & Anthropic SDK
// УРОК 42

Claude API & Anthropic SDK

B2

Claude API & Anthropic SDK

Messages API — Key Parameters

ParameterPurpose
modelWhich Claude model to use (claude-opus-4-5, claude-sonnet-4-5...)
messagesConversation history as a list of role/content pairs
systemSystem prompt — sets the model's role and instructions
max_tokensMaximum tokens in the response
temperatureRandomness of output (0–1)
toolsTool definitions for function calling
streamWhether to stream the response token by token

Response Structure

  • content — list of content blocks (text or tool_use)
  • stop_reason — "end_turn", "tool_use", "max_tokens"
  • usage — input_tokens and output_tokens for cost tracking

Useful Phrases

  • "We use the Messages API with a system prompt to set the assistant's behavior."
  • "When stop_reason is 'tool_use', we execute the tool and send the result back."
  • "We track token usage per request to monitor and optimize costs."
// TERMINAL CHALLENGE

Проверь себя

Q1. What does the 'system' parameter in the Claude API do?
Q2. What does a stop_reason of 'tool_use' indicate?
Q3. What is 'streaming' in the context of the Claude API?
Q4. Why do you track 'usage' (input_tokens + output_tokens) in API responses?
Q5. Complete: 'When stop_reason is tool_use, we ___ the tool and send the result back in the next message.'
╔═ GL1TCH v0.1 ═[ПОДКЛЮЧЕНО]═╗ [×]
СОЕДИНЕНИЕ АКТИВНО
запросов:
// сессия #{} начата
>_
[ РАЗРЫВ СВЯЗИ ]
лимит исчерпан...
иду спать... zzZ
хочешь больше? [зарегистрироваться] // +10 запросов в день