Логотип Anthropic Sdk

Anthropic Sdk

Організація
TerminalSkills
anthropic-sdk

Integrate Claude AI into applications with the Anthropic SDK. Use when a user asks to add Claude to an app, use Claude for text generation, build a chatbot with Claude, use Claude's long context window, implement tool use with Claude, stream Claude responses, use Claude for code generation, document analysis, or reasoning tasks. Covers Messages API, streaming, tool use, vision, system prompts, extended thinking, and batch processing.

Огляд

ВидавецьTerminalSkills
Репозиторійskills
Назва навичкиanthropic-sdk
Зірки
155
Форки
21
Файли в пакеті
1
ЛіцензіяApache-2.0
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Файлів у комплекті: 1

    Скрипти, шаблони й довідкові матеріали, які модель може читати під час роботи. Файли доступні лише для читання й ніколи не виконуються.

  • Відкритий вихідний код

    Видавець на GitHub: TerminalSkills. Перед установленням перегляньте вихідні файли навички.

Встановлення

Установіть навичку ШІ Anthropic Sdk у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки на GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до розділу «Плагіни» → «Навички».
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/TerminalSkills/skills/tree/main/skills/anthropic-sdk
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Додати навичку → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/TerminalSkills/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/anthropic-sdk .claude/skills/anthropic-sdk
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Anthropic Sdk в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Anthropic Sdk, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для певного постачальника, тому навичка Anthropic Sdk не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож поки навичка не потрібна, токени на її інструкції не витрачаються.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Anthropic SDK

Overview

The Anthropic SDK provides access to Claude models (Opus, Sonnet, Haiku) for text generation, analysis, coding, and reasoning. Claude excels at long-context understanding (200K tokens), careful instruction following, code generation, and complex reasoning. This skill covers the Messages API, streaming, tool use (function calling), vision, extended thinking, system prompts, and best practices for prompt engineering with Claude.

Instructions

Step 1: Installation

bash
# Node.js
npm install @anthropic-ai/sdk

# Python
pip install anthropic
typescript
// lib/anthropic.ts — Client initialization
import Anthropic from '@anthropic-ai/sdk'

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
})

Step 2: Messages API

typescript
// chat.ts — Basic message creation
const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  system: 'You are a senior software engineer. Provide clear, production-ready code with comments.',
  messages: [
    { role: 'user', content: 'Write a rate limiter middleware for Express.js using a sliding window algorithm.' },
  ],
})

console.log(message.content[0].type === 'text' ? message.content[0].text : '')
// message.usage: { input_tokens: 42, output_tokens: 512 }
python
# Python equivalent
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    system="You are a senior software engineer.",
    messages=[
        {"role": "user", "content": "Write a rate limiter for Express.js."}
    ],
)
print(message.content[0].text)

Step 3: Streaming

typescript
// stream.ts — Stream responses for real-time UI
const stream = anthropic.messages.stream({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Explain how B-trees work.' }],
})

for await (const event of stream) {
  if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
    process.stdout.write(event.delta.text)
  }
}

// Or using the helper
const stream2 = anthropic.messages.stream({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Explain B-trees.' }],
})

stream2.on('text', (text) => process.stdout.write(text))
await stream2.finalMessage()

Step 4: Tool Use (Function Calling)

typescript
// tools.ts — Let Claude call your functions
const tools: Anthropic.Tool[] = [
  {
    name: 'get_stock_price',
    description: 'Get the current stock price for a ticker symbol. Use when the user asks about stock prices.',
    input_schema: {
      type: 'object',
      properties: {
        ticker: { type: 'string', description: 'Stock ticker symbol (e.g., AAPL, GOOGL)' },
      },
      required: ['ticker'],
    },
  },
  {
    name: 'execute_sql',
    description: 'Execute a read-only SQL query against the analytics database.',
    input_schema: {
      type: 'object',
      properties: {
        query: { type: 'string', description: 'SQL SELECT query to execute' },
      },
      required: ['query'],
    },
  },
]

const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  tools,
  messages: [{ role: 'user', content: 'What is Apple stock at right now?' }],
})

// Process tool use
if (response.stop_reason === 'tool_use') {
  const toolUse = response.content.find(b => b.type === 'tool_use')!
  const result = await executeFunction(toolUse.name, toolUse.input)

  // Send result back to Claude
  const finalResponse = await anthropic.messages.create({
    model: 'claude-sonnet-4-20250514',
    max_tokens: 1024,
    tools,
    messages: [
      { role: 'user', content: 'What is Apple stock at right now?' },
      { role: 'assistant', content: response.content },
      { role: 'user', content: [{ type: 'tool_result', tool_use_id: toolUse.id, content: JSON.stringify(result) }] },
    ],
  })
}

Step 5: Vision

typescript
// vision.ts — Analyze images with Claude
import { readFileSync } from 'fs'

// URL-based image
const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  messages: [{
    role: 'user',
    content: [
      { type: 'image', source: { type: 'url', url: 'https://example.com/chart.png' } },
      { type: 'text', text: 'Analyze this chart. What trends do you see?' },
    ],
  }],
})

// Base64 image (from file)
const imageData = readFileSync('screenshot.png').toString('base64')
const response2 = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 1024,
  messages: [{
    role: 'user',
    content: [
      { type: 'image', source: { type: 'base64', media_type: 'image/png', data: imageData } },
      { type: 'text', text: 'Extract all text and data from this screenshot.' },
    ],
  }],
})

Step 6: Extended Thinking

typescript
// thinking.ts — Enable extended thinking for complex reasoning tasks
const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-20250514',
  max_tokens: 16000,
  thinking: {
    type: 'enabled',
    budget_tokens: 10000,    // tokens allocated for internal reasoning
  },
  messages: [{
    role: 'user',
    content: 'Analyze this codebase for security vulnerabilities and provide a prioritized remediation plan.',
  }],
})

// Response contains both thinking blocks and text blocks
for (const block of response.content) {
  if (block.type === 'thinking') {
    console.log('Reasoning:', block.thinking)
  } else if (block.type === 'text') {
    console.log('Response:', block.text)
  }
}

Step 7: Multi-Turn Conversations

typescript
// conversation.ts — Maintain conversation history
const messages: Anthropic.MessageParam[] = []

async function chat(userMessage: string): Promise<string> {
  messages.push({ role: 'user', content: userMessage })

  const response = await anthropic.messages.create({
    model: 'claude-sonnet-4-20250514',
    max_tokens: 2048,
    system: 'You are a helpful assistant for a project management app.',
    messages,
  })

  const assistantContent = response.content
  messages.push({ role: 'assistant', content: assistantContent })

  return assistantContent.filter(b => b.type === 'text').map(b => b.text).join('')
}

Examples

Example 1: Build a code review bot

User prompt: "Build a bot that reviews pull requests. It should analyze the diff, check for bugs, security issues, and style problems, then post inline comments."

The agent will:

  1. Fetch PR diff via GitHub API.
  2. Send the diff to Claude with a system prompt tuned for code review.
  3. Use structured output to get file-specific comments with line numbers.
  4. Post comments back to GitHub using the PR review API.

Example 2: Document analysis pipeline with tool use

User prompt: "Build a system where users upload contracts and ask questions about them. The AI should be able to search across multiple documents and cite specific sections."

The agent will:

  1. Store document chunks with embeddings in a vector database.
  2. Define a search_documents tool that Claude can call.
  3. Claude formulates search queries, retrieves relevant chunks, and synthesizes answers with citations.
  4. Use Claude's 200K context window for full-document analysis when documents are small enough.

Guidelines

  • Claude Sonnet is the best default for most tasks — it balances quality, speed, and cost. Use Opus for the most complex reasoning and Haiku for high-volume, simple tasks.
  • Write detailed system prompts — Claude follows instructions carefully. Specify output format, constraints, tone, and edge case handling in the system prompt.
  • Use extended thinking for complex reasoning (math, multi-step analysis, code architecture). The thinking budget controls how much Claude reasons before responding.
  • Claude supports 200K token context windows — use this for long document analysis, large codebases, and conversations with extensive history.
  • For tool use, provide clear descriptions and examples in the tool definition. Claude uses descriptions (not just parameter names) to decide when and how to call tools.
  • Always handle the stop_reason field: end_turn means done, tool_use means Claude wants to call a function, max_tokens means the response was truncated.

Файли в пакеті

Модель читає ці файли за потреби, поки навичку завантажено. Вони доступні для читання й ніколи не виконуються.

Поширені запитання

Що робить навичка ШІ Anthropic Sdk?

Integrate Claude AI into applications with the Anthropic SDK. Use when a user asks to add Claude to an app, use Claude for text generation, build a chatbot with Claude, use Claude's long context window, implement tool use with Claude, stream Claude responses, use Claude for code generation, document analysis, or reasoning tasks. Covers Messages API, streaming, tool use, vision, system prompts, extended thinking, and batch processing.

Навіщо використовувати Anthropic Sdk у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Anthropic Sdk — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Anthropic Sdk у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/TerminalSkills/skills/tree/main/skills/anthropic-sdk. TypingMind прочитає файл SKILL.md, додасть супровідні файли та встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Anthropic Sdk?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Anthropic Sdk?

Зі скількома забажаєте. У TypingMind ви можете використовувати Anthropic Sdk із будь-якою моделлю, яка підтримує навички, зокрема з GPT, Claude, Gemini, Grok, DeepSeek, Mistral чи Llama. Для цього ви використовуєте власні ключі API.

Чи безкоштовна навичка ШІ Anthropic Sdk?

Так. На GitHub цю навичку публікує TerminalSkills за ліцензією Apache-2.0. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це набір інструкцій для повторного використання, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти, які вона може викликати, — код, який десь виконується й повертає результат. Натомість навичка ШІ дає моделі знання й пояснює порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний робочий простір зі ШІ вже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇