| name | claude-api |
| description | 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. |
| license | Complete terms in LICENSE.txt |
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:
- Model: Claude Opus 4.6 (
claude-opus-4-6) — ALWAYS use unless explicitly asked otherwise
- Thinking: Adaptive thinking (
thinking: {type: "adaptive"}) for anything remotely complicated
- Streaming: Default for long input/output requests — use
.get_final_message() / .finalMessage() to get the complete response
Language Detection
Before reading code examples, determine which language the user is working in:
-
Look at project files to infer the language:
*.py, requirements.txt, pyproject.toml, setup.py, Pipfile → Python
*.ts, *.tsx, package.json, tsconfig.json → TypeScript
*.js, *.jsx (no .ts files present) → TypeScript (JS uses the same SDK)
*.java, pom.xml, build.gradle → Java
*.go, go.mod → Go
*.rb, Gemfile → Ruby
*.cs, *.csproj → C#
*.php, composer.json → PHP
-
If multiple languages detected: Check which the user's current file relates to; if ambiguous, ask.
-
If language can't be inferred: Default to Python and note it.
Language-Specific Feature Support
| Language | Tool Runner | Agent SDK |
|---|
| Python | Yes (beta) | Yes |
| TypeScript | Yes (beta) | Yes |
| Java | Yes (beta) | No |
| Go | Yes (beta) | No |
| Ruby | Yes (beta) | No |
| C#, PHP | No | No |
Which Surface Should I Use?
Start simple. Default to the simplest tier that meets your needs.
| Use Case | Recommended Surface |
|---|
| Classification, summarization, extraction, Q&A | Claude API |
| Multi-step pipelines with code-controlled logic | Claude API + tool use |
| Custom agent with your own tools | Claude API + tool use |
| AI agent with file/web/terminal access | Agent SDK |
| Agentic coding assistant | Agent SDK |
Decision Tree
1. Single LLM call → Claude API (one request, one response)
2. Claude needs to read/write files, browse web, run shell commands itself?
└── Yes → Agent SDK (built-in tools, don't reimplement them)
3. Multi-step workflow with your own tools → Claude API with tool use
4. Open-ended agent (model decides trajectory) → Claude API agentic loop
Architecture
Everything goes through POST /v1/messages. Tools, structured outputs, and constraints are features of this single endpoint — not separate APIs.
Current Models
| 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. Do not downgrade for cost — that's the user's decision.
Thinking & Effort
- Opus 4.6 / Sonnet 4.6: Use
thinking: {type: "adaptive"} — do NOT use budget_tokens (deprecated on both)
- Effort parameter:
output_config: {effort: "low"|"medium"|"high"|"max"} — default is high; max is Opus 4.6 only
Python SDK Examples
Basic Message
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, Claude!"}]
)
print(message.content[0].text)
With Adaptive Thinking
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=16000,
thinking={"type": "adaptive"},
messages=[{"role": "user", "content": "Solve this complex problem..."}]
)
Streaming
with client.messages.stream(
model="claude-opus-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a story"}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
message = stream.get_final_message()
Tool Use
tools = [{
"name": "get_weather",
"description": "Get weather for a location",
"input_schema": {
"type": "object",
"properties": {"location": {"type": "string", "description": "City name"}},
"required": ["location"]
}
}]
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
tools=tools,
messages=[{"role": "user", "content": "What's the weather in NYC?"}]
)
Structured Outputs
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
output_config={"format": {"type": "json_object"}},
messages=[{"role": "user", "content": "Return JSON with name and age"}]
)
TypeScript SDK Examples
Basic Message
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const message = await client.messages.create({
model: "claude-opus-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, Claude!" }],
});
console.log((message.content[0] as Anthropic.TextBlock).text);
Streaming
const stream = client.messages.stream({
model: "claude-opus-4-6",
max_tokens: 1024,
messages: [{ role: "user", content: "Write a story" }],
});
for await (const chunk of stream) {
if (chunk.type === "content_block_delta" && chunk.delta.type === "text_delta") {
process.stdout.write(chunk.delta.text);
}
}
const message = await stream.finalMessage();
Common Pitfalls
- Don't truncate inputs — if too long, notify user and discuss options (chunking, summarization)
- Opus 4.6/Sonnet 4.6 thinking: Use
thinking: {type: "adaptive"} — NOT budget_tokens (deprecated)
- Opus 4.6 prefill: Assistant message prefills return 400 — use
output_config.format or system prompts instead
- Large outputs require streaming: Opus 4.6 supports 128K
max_tokens but needs streaming
- Structured outputs: Use
output_config: {format: {...}} — NOT deprecated output_format
- Tool call JSON: Always parse with
json.loads() / JSON.parse() — never string-match serialized input
- Don't reimplement SDK: Use
stream.finalMessage(), typed exceptions (Anthropic.RateLimitError), SDK types (Anthropic.MessageParam, Anthropic.Tool)
Installation
pip install anthropic
npm install @anthropic-ai/sdk