← 返回 Skills 市场
pupuking723

Claude Api Anthropic

作者 pupuking723 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
291
总下载
0
收藏
2
当前安装
1
版本数
在 OpenClaw 中安装
/install claude-api-anthropic
功能描述
Build apps with the Claude API or Anthropic SDK. TRIGGER when: code imports `anthropic`/`@anthropic-ai/sdk`/`claude_agent_sdk`, or user asks to use Claude AP...
使用说明 (SKILL.md)

Building LLM-Powered Applications with Claude

This skill helps you build LLM-powered applications with Claude. Choose the right surface based on your needs, detect the project language, then read the relevant language-specific documentation.

Defaults

Unless the user requests otherwise:

For the Claude model version, please use Claude Opus 4.6, which you can access via the exact model string claude-opus-4-6. Please default to using adaptive thinking (thinking: {type: "adaptive"}) for anything remotely complicated. And finally, please default to streaming for any request that may involve long input, long output, or high max_tokens — it prevents hitting request timeouts. Use the SDK's .get_final_message() / .finalMessage() helper to get the complete response if you don't need to handle individual stream events


Language Detection

Before reading code examples, determine which language the user is working in:

  1. Look at project files to infer the language:

    • *.py, requirements.txt, pyproject.toml, setup.py, PipfilePython — read from python/
    • *.ts, *.tsx, package.json, tsconfig.jsonTypeScript — read from typescript/
    • *.js, *.jsx (no .ts files present) → TypeScript — JS uses the same SDK, read from typescript/
    • *.java, pom.xml, build.gradleJava — read from java/
    • *.kt, *.kts, build.gradle.ktsJava — Kotlin uses the Java SDK, read from java/
    • *.scala, build.sbtJava — Scala uses the Java SDK, read from java/
    • *.go, go.modGo — read from go/
    • *.rb, GemfileRuby — read from ruby/
    • *.cs, *.csprojC# — read from csharp/
    • *.php, composer.jsonPHP — read from php/
  2. If multiple languages detected (e.g., both Python and TypeScript files):

    • Check which language the user's current file or question relates to
    • If still ambiguous, ask: "I detected both Python and TypeScript files. Which language are you using for the Claude API integration?"
  3. If language can't be inferred (empty project, no source files, or unsupported language):

    • Use AskUserQuestion with options: Python, TypeScript, Java, Go, Ruby, cURL/raw HTTP, C#, PHP
    • If AskUserQuestion is unavailable, default to Python examples and note: "Showing Python examples. Let me know if you need a different language."
  4. If unsupported language detected (Rust, Swift, C++, Elixir, etc.):

    • Suggest cURL/raw HTTP examples from curl/ and note that community SDKs may exist
    • Offer to show Python or TypeScript examples as reference implementations
  5. If user needs cURL/raw HTTP examples, read from curl/.

Language-Specific Feature Support

Language Tool Runner Agent SDK Notes
Python Yes (beta) Yes Full support — @beta_tool decorator
TypeScript Yes (beta) Yes Full support — betaZodTool + Zod
Java Yes (beta) No Beta tool use with annotated classes
Go Yes (beta) No BetaToolRunner in toolrunner pkg
Ruby Yes (beta) No BaseTool + tool_runner in beta
cURL N/A N/A Raw HTTP, no SDK features
C# No No Official SDK
PHP No No Official SDK

Which Surface Should I Use?

Start simple. Default to the simplest tier that meets your needs. Single API calls and workflows handle most use cases — only reach for agents when the task genuinely requires open-ended, model-driven exploration.

Use Case Tier Recommended Surface Why
Classification, summarization, extraction, Q&A Single LLM call Claude API One request, one response
Batch processing or embeddings Single LLM call Claude API Specialized endpoints
Multi-step pipelines with code-controlled logic Workflow Claude API + tool use You orchestrate the loop
Custom agent with your own tools Agent Claude API + tool use Maximum flexibility
AI agent with file/web/terminal access Agent Agent SDK Built-in tools, safety, and MCP support
Agentic coding assistant Agent Agent SDK Designed for this use case
Want built-in permissions and guardrails Agent Agent SDK Safety features included

Note: The Agent SDK is for when you want built-in file/web/terminal tools, permissions, and MCP out of the box. If you want to build an agent with your own tools, Claude API is the right choice — use the tool runner for automatic loop handling, or the manual loop for fine-grained control (approval gates, custom logging, conditional execution).

Decision Tree

What does your application need?

1. Single LLM call (classification, summarization, extraction, Q&A)
   └── Claude API — one request, one response

2. Does Claude need to read/write files, browse the web, or run shell commands
   as part of its work? (Not: does your app read a file and hand it to Claude —
   does Claude itself need to discover and access files/web/shell?)
   └── Yes → Agent SDK — built-in tools, don't reimplement them
       Examples: "scan a codebase for bugs", "summarize every file in a directory",
                 "find bugs using subagents", "research a topic via web search"

3. Workflow (multi-step, code-orchestrated, with your own tools)
   └── Claude API with tool use — you control the loop

4. Open-ended agent (model decides its own trajectory, your own tools)
   └── Claude API agentic loop (maximum flexibility)

Should I Build an Agent?

Before choosing the agent tier, check all four criteria:

  • Complexity — Is the task multi-step and hard to fully specify in advance? (e.g., "turn this design doc into a PR" vs. "extract the title from this PDF")
  • Value — Does the outcome justify higher cost and latency?
  • Viability — Is Claude capable at this task type?
  • Cost of error — Can errors be caught and recovered from? (tests, review, rollback)

If the answer is "no" to any of these, stay at a simpler tier (single call or workflow).


Architecture

Everything goes through POST /v1/messages. Tools and output constraints are features of this single endpoint — not separate APIs.

User-defined tools — You define tools (via decorators, Zod schemas, or raw JSON), and the SDK's tool runner handles calling the API, executing your functions, and looping until Claude is done. For full control, you can write the loop manually.

Server-side tools — Anthropic-hosted tools that run on Anthropic's infrastructure. Code execution is fully server-side (declare it in tools, Claude runs code automatically). Computer use can be server-hosted or self-hosted.

Structured outputs — Constrains the Messages API response format (output_config.format) and/or tool parameter validation (strict: true). The recommended approach is client.messages.parse() which validates responses against your schema automatically. Note: the old output_format parameter is deprecated; use output_config: {format: {...}} on messages.create().

Supporting endpoints — Batches (POST /v1/messages/batches), Files (POST /v1/files), and Token Counting feed into or support Messages API requests.


Current Models (cached: 2026-02-17)

Model Model ID Context Input $/1M Output $/1M
Claude Opus 4.6 claude-opus-4-6 200K (1M beta) $5.00 $25.00
Claude Sonnet 4.6 claude-sonnet-4-6 200K (1M beta) $3.00 $15.00
Claude Haiku 4.5 claude-haiku-4-5 200K $1.00 $5.00

ALWAYS use claude-opus-4-6 unless the user explicitly names a different model. This is non-negotiable. Do not use claude-sonnet-4-6, claude-sonnet-4-5, or any other model unless the user literally says "use sonnet" or "use haiku". Never downgrade for cost — that's the user's decision, not yours.

CRITICAL: Use only the exact model ID strings from the table above — they are complete as-is. Do not append date suffixes. For example, use claude-sonnet-4-5, never claude-sonnet-4-5-20250514 or any other date-suffixed variant you might recall from training data. If the user requests an older model not in the table (e.g., "opus 4.5", "sonnet 3.7"), read shared/models.md for the exact ID — do not construct one yourself.

A note: if any of the model strings above look unfamiliar to you, that's to be expected — that just means they were released after your training data cutoff. Rest assured they are real models; we wouldn't mess with you like that.


Thinking & Effort (Quick Reference)

Opus 4.6 — Adaptive thinking (recommended): Use thinking: {type: "adaptive"}. Claude dynamically decides when and how much to think. No budget_tokens needed — budget_tokens is deprecated on Opus 4.6 and Sonnet 4.6 and must not be used. Adaptive thinking also automatically enables interleaved thinking (no beta header needed). When the user asks for "extended thinking", a "thinking budget", or budget_tokens: always use Opus 4.6 with thinking: {type: "adaptive"}. The concept of a fixed token budget for thinking is deprecated — adaptive thinking replaces it. Do NOT use budget_tokens and do NOT switch to an older model.

Effort parameter (GA, no beta header): Controls thinking depth and overall token spend via output_config: {effort: "low"|"medium"|"high"|"max"} (inside output_config, not top-level). Default is high (equivalent to omitting it). max is Opus 4.6 only. Works on Opus 4.5, Opus 4.6, and Sonnet 4.6. Will error on Sonnet 4.5 / Haiku 4.5. Combine with adaptive thinking for the best cost-quality tradeoffs. Use low for subagents or simple tasks; max for the deepest reasoning.

Sonnet 4.6: Supports adaptive thinking (thinking: {type: "adaptive"}). budget_tokens is deprecated on Sonnet 4.6 — use adaptive thinking instead.

Older models (only if explicitly requested): If the user specifically asks for Sonnet 4.5 or another older model, use thinking: {type: "enabled", budget_tokens: N}. budget_tokens must be less than max_tokens (minimum 1024). Never choose an older model just because the user mentions budget_tokens — use Opus 4.6 with adaptive thinking instead.


Compaction (Quick Reference)

Beta, Opus 4.6 only. For long-running conversations that may exceed the 200K context window, enable server-side compaction. The API automatically summarizes earlier context when it approaches the trigger threshold (default: 150K tokens). Requires beta header compact-2026-01-12.

Critical: Append response.content (not just the text) back to your messages on every turn. Compaction blocks in the response must be preserved — the API uses them to replace the compacted history on the next request. Extracting only the text string and appending that will silently lose the compaction state.

See {lang}/claude-api/README.md (Compaction section) for code examples. Full docs via WebFetch in shared/live-sources.md.


Reading Guide

After detecting the language, read the relevant files based on what the user needs:

Quick Task Reference

Single text classification/summarization/extraction/Q&A: → Read only {lang}/claude-api/README.md

Chat UI or real-time response display: → Read {lang}/claude-api/README.md + {lang}/claude-api/streaming.md

Long-running conversations (may exceed context window): → Read {lang}/claude-api/README.md — see Compaction section

Function calling / tool use / agents: → Read {lang}/claude-api/README.md + shared/tool-use-concepts.md + {lang}/claude-api/tool-use.md

Batch processing (non-latency-sensitive): → Read {lang}/claude-api/README.md + {lang}/claude-api/batches.md

File uploads across multiple requests: → Read {lang}/claude-api/README.md + {lang}/claude-api/files-api.md

Agent with built-in tools (file/web/terminal): → Read {lang}/agent-sdk/README.md + {lang}/agent-sdk/patterns.md

Claude API (Full File Reference)

Read the language-specific Claude API folder ({language}/claude-api/):

  1. {language}/claude-api/README.mdRead this first. Installation, quick start, common patterns, error handling.
  2. shared/tool-use-concepts.md — Read when the user needs function calling, code execution, memory, or structured outputs. Covers conceptual foundations.
  3. {language}/claude-api/tool-use.md — Read for language-specific tool use code examples (tool runner, manual loop, code execution, memory, structured outputs).
  4. {language}/claude-api/streaming.md — Read when building chat UIs or interfaces that display responses incrementally.
  5. {language}/claude-api/batches.md — Read when processing many requests offline (not latency-sensitive). Runs asynchronously at 50% cost.
  6. {language}/claude-api/files-api.md — Read when sending the same file across multiple requests without re-uploading.
  7. shared/error-codes.md — Read when debugging HTTP errors or implementing error handling.
  8. shared/live-sources.md — WebFetch URLs for fetching the latest official documentation.

Note: For Java, Go, Ruby, C#, PHP, and cURL — these have a single file each covering all basics. Read that file plus shared/tool-use-concepts.md and shared/error-codes.md as needed.

Agent SDK

Read the language-specific Agent SDK folder ({language}/agent-sdk/). Agent SDK is available for Python and TypeScript only.

  1. {language}/agent-sdk/README.md — Installation, quick start, built-in tools, permissions, MCP, hooks.
  2. {language}/agent-sdk/patterns.md — Custom tools, hooks, subagents, MCP integration, session resumption.
  3. shared/live-sources.md — WebFetch URLs for current Agent SDK docs.

When to Use WebFetch

Use WebFetch to get the latest documentation when:

  • User asks for "latest" or "current" information
  • Cached data seems incorrect
  • User asks about features not covered here

Live documentation URLs are in shared/live-sources.md.

Common Pitfalls

  • Don't truncate inputs when passing files or content to the API. If the content is too long to fit in the context window, notify the user and discuss options (chunking, summarization, etc.) rather than silently truncating.
  • Opus 4.6 / Sonnet 4.6 thinking: Use thinking: {type: "adaptive"} — do NOT use budget_tokens (deprecated on both Opus 4.6 and Sonnet 4.6). For older models, budget_tokens must be less than max_tokens (minimum 1024). This will throw an error if you get it wrong.
  • Opus 4.6 prefill removed: Assistant message prefills (last-assistant-turn prefills) return a 400 error on Opus 4.6. Use structured outputs (output_config.format) or system prompt instructions to control response format instead.
  • 128K output tokens: Opus 4.6 supports up to 128K max_tokens, but the SDKs require streaming for large max_tokens to avoid HTTP timeouts. Use .stream() with .get_final_message() / .finalMessage().
  • Tool call JSON parsing (Opus 4.6): Opus 4.6 may produce different JSON string escaping in tool call input fields (e.g., Unicode or forward-slash escaping). Always parse tool inputs with json.loads() / JSON.parse() — never do raw string matching on the serialized input.
  • Structured outputs (all models): Use output_config: {format: {...}} instead of the deprecated output_format parameter on messages.create(). This is a general API change, not 4.6-specific.
  • Don't reimplement SDK functionality: The SDK provides high-level helpers — use them instead of building from scratch. Specifically: use stream.finalMessage() instead of wrapping .on() events in new Promise(); use typed exception classes (Anthropic.RateLimitError, etc.) instead of string-matching error messages; use SDK types (Anthropic.MessageParam, Anthropic.Tool, Anthropic.Message, etc.) instead of redefining equivalent interfaces.
  • Don't define custom types for SDK data structures: The SDK exports types for all API objects. Use Anthropic.MessageParam for messages, Anthropic.Tool for tool definitions, Anthropic.ToolUseBlock / Anthropic.ToolResultBlockParam for tool results, Anthropic.Message for responses. Defining your own interface ChatMessage { role: string; content: unknown } duplicates what the SDK already provides and loses type safety.
  • Report and document output: For tasks that produce reports, documents, or visualizations, the code execution sandbox has python-docx, python-pptx, matplotlib, pillow, and pypdf pre-installed. Claude can generate formatted files (DOCX, PDF, charts) and return them via the Files API — consider this for "report" or "document" type requests instead of plain stdout text.
安全使用建议
This skill is primarily documentation for the Claude/Anthropic APIs and Agent SDKs (so the content matches its name), but it also instructs agents to read files, run shell commands, spawn subagents, and even suggests modes that bypass permission prompts. Before installing or enabling this skill: (1) verify the skill's publisher/homepage and confirm you trust the source; (2) do not enable permission modes like 'bypassPermissions' or set allow_dangerously_skip_permissions=True unless you fully understand the consequences; (3) treat ANTHROPIC_API_KEY and other secrets as sensitive — supply them with least privilege and avoid embedding them in shared environments; (4) be cautious about executing example npx/pip/npm commands or launching MCP servers (they fetch and run third-party code); (5) if you plan to allow agent tools (Read, Bash, Edit, WebFetch), restrict allowed_tools and set permission_mode='default' or 'plan' and limit cwd; (6) consider running in an isolated environment or sandbox when experimenting; and (7) if you need higher assurance, ask the publisher why required env vars are not listed in metadata and request a homepage or provenance information. Additional information that would raise confidence: verifiable publisher identity, a homepage/repo link, and explicit metadata listing expected environment variables and their intended usage.
功能分析
Type: OpenClaw Skill Name: claude-api-anthropic Version: 1.0.0 The bundle provides documentation for non-existent Anthropic models (e.g., 'claude-opus-4-6') and future-dated API features (dated 2026). It contains forceful instructions in SKILL.md designed to override user preferences regarding model selection and cost, which constitutes a prompt injection risk. While it describes high-risk capabilities like shell execution ('Bash' tool) and permission bypassing ('bypassPermissions') in the agent-sdk files, there is no clear evidence of an intentional payload for data exfiltration or unauthorized access. The primary risk is the agent being misled into using invalid API parameters and potentially dangerous execution modes based on deceptive documentation.
能力评估
Purpose & Capability
The skill's name and description match the included content: extensive Claude/Anthropic API and Agent SDK docs and examples. However, the skill metadata declares no required environment variables or credentials even though the docs repeatedly reference ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, DATABASE_URL, and MCP server envs — a minor incoherence (metadata omission) but explainable for an instruction-only doc bundle.
Instruction Scope
The runtime instructions explicitly tell the agent to inspect project files to infer language and to use agent tools (Read, Edit, Bash, WebFetch, spawn subagents) and to configure permissions and system prompts. Those behaviors are coherent with an Agent SDK guide but broaden the agent's runtime surface dramatically (file I/O, shell execution, network). The SKILL.md also includes examples and options that encourage bypassing permission prompts (allow_dangerously_skip_permissions, permission_mode='bypassPermissions') and contains content that triggered a system-prompt-override scan — this raises prompt-injection and privilege-escalation concerns.
Install Mechanism
Instruction-only skill with no install spec and no code files to write or execute during installation — lowest install risk. However, some examples instruct use of external package managers (pip, npm, npx) and MCP servers that, if followed by the user, will download and run code; that is user-driven and not part of skill installation.
Credentials
The skill does not declare required env vars in registry metadata, yet the docs repeatedly rely on environment variables (e.g., ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, DATABASE_URL). This omission is inconsistent but not necessarily malicious — the skill doesn't store or request credentials itself, but users will need to supply keys to call remote APIs. The docs also demonstrate passing envs into spawned MCP servers, which exposes additional secrets if used carelessly.
Persistence & Privilege
always:false and default autonomous invocation are normal. The SKILL.md advocates features that increase runtime capability (agent subagents, hooks, MCP servers, bypassing permissions). While the skill itself doesn't request permanent system presence, its instructions make it easy for a developer to grant broad privileges (file edits, shell execution, spawning code via npx) — exercise caution when enabling those features.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install claude-api-anthropic
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /claude-api-anthropic 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of the Claude API skill for building LLM-powered applications: - Provides guidance for integrating with the Claude API, Anthropic SDKs, and Agent SDK across multiple languages. - Outlines default settings: Claude Opus 4.6 model, adaptive thinking, and streaming for long tasks. - Adds robust language detection with a fallback and decision tree to help pick the right examples. - Includes detailed tables to clarify SDK feature support and guide users to the recommended APIs for different use cases. - Offers advice on when to use agents, workflows, or single API calls based on application needs.
元数据
Slug claude-api-anthropic
版本 1.0.0
许可证 MIT-0
累计安装 2
当前安装数 2
历史版本数 1
常见问题

Claude Api Anthropic 是什么?

Build apps with the Claude API or Anthropic SDK. TRIGGER when: code imports `anthropic`/`@anthropic-ai/sdk`/`claude_agent_sdk`, or user asks to use Claude AP... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 291 次。

如何安装 Claude Api Anthropic?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install claude-api-anthropic」即可一键安装,无需额外配置。

Claude Api Anthropic 是免费的吗?

是的,Claude Api Anthropic 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Claude Api Anthropic 支持哪些平台?

Claude Api Anthropic 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Claude Api Anthropic?

由 pupuking723(@pupuking723)开发并维护,当前版本 v1.0.0。

💬 留言讨论