Home/Skills/claude-api
Anthropic skill

claude-api

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 API, Anthropic SDKs, or Agent SDK. DO NOT TRIGGER when: code imports `openai`/other AI SDK, general programming, or ML/data-science tasks.

claude, mcp, api
#skill
#agent
#workflow
#mcp
#pdf
Last updated

about 12 hours ago

Repository path

skills/claude-api

Source files

0

Use cases

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

Install / setup

# 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`, `Pipfile` → **Python** — read from `python/` - `*.ts`, `*.tsx`, `package.json`, `tsconfig.json` → **TypeScript** — read from `typescript/` - `*.js`, `*.jsx` (no `.ts` files present) → **TypeScript** — JS uses the same SDK, read from `typescript/` - `*.java`, `pom.xml`, `build.gradle` → **Java** — read from `java/` - `*.kt`, `*.kts`, `build.gradle.kts` → **Java** — Kotlin uses the Java SDK, read from `java/` - `*.scala`, `build.sbt` → **Java** — Scala uses the Java SDK, read from `java/` - `*.go`, `go.mod` → **Go** — read from `go/` - `*.rb`, `Gemfile` → **Ruby** — read from `ruby/` - `*.cs`, `*.csproj` → **C#** — read from `csharp/` - `*.php`, `composer.json` → **PHP** — 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

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`, `Pipfile` → **Python** — read from `python/` - `*.ts`, `*.tsx`, `package.json`, `tsconfig.json` → **TypeScript** — read from `typescript/` - `*.js`, `*.jsx` (no `.ts` files present) → **TypeScript** — JS uses the same SDK, read from `typescript/` - `*.java`, `pom.xml`, `build.gradle` → **Java** — read from `java/` - `*.kt`, `*.kts`, `build.gradle.kts` → **Java** — Kotlin uses the Java SDK, read from `java/` - `*.scala`, `build.sbt` → **Java** — Scala uses the Java SDK, read from `java/` - `*.go`, `go.mod` → **Go** — read from `go/` - `*.rb`, `Gemfile` → **Ruby** — read from `ruby/` - `*.cs`, `*.csproj` → **C#** — read from `csharp/` - `*.php`, `composer.json` → **PHP** — 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).

Repository files