# 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.

- Skill: `edorabma9304/claude-api` (Agent Skill)
- Install (CLI): `npx skillmds@latest add edorabma9304/claude-api`
- Raw SKILL.md: https://api.skillmd.com/api/skills/edorabma9304/claude-api/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: edorabma9304 (https://skillmd.com/u/edorabma9304)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/edorabma9304/claude-api

---


# Building LLM-Powered Applications with Claude

## Defaults

- Model: **Claude Opus 4.6** (`claude-opus-4-6`) unless user requests otherwise
- Thinking: `thinking: {type: "adaptive"}` for anything remotely complicated
- Streaming: default for long input/output or high `max_tokens`

## 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 user explicitly names a different model.**
**Use exact model ID strings — never append date suffixes.**

## Which Surface to Use?

| Use Case | Surface |
|----------|---------|
| Classification, summarization, Q&A | Claude API (single call) |
| Multi-step pipelines with code-controlled logic | Claude API + tool use |
| Custom agent with your own tools | Claude API + tool use |
| Agent with file/web/terminal access | Agent SDK |
| Built-in permissions and guardrails | Agent SDK |

## Language Detection

Check project files:
- `*.py`, `requirements.txt` → Python
- `*.ts`, `*.tsx`, `package.json` → TypeScript
- `*.js`, `*.jsx` → TypeScript (same SDK)
- `*.java`, `pom.xml` → Java
- `*.go`, `go.mod` → Go
- `*.rb`, `Gemfile` → Ruby

## Thinking & Effort

**Opus 4.6 / Sonnet 4.6**: Use `thinking: {type: "adaptive"}`. `budget_tokens` is deprecated.

**Effort parameter**: `output_config: {effort: "low"|"medium"|"high"|"max"}` (inside `output_config`). Default is `high`. `max` is Opus 4.6 only.

**Older models** (only if explicitly requested): `thinking: {type: "enabled", budget_tokens: N}`.

## Quick Start (Python)

```python
import anthropic

client = anthropic.Anthropic()

message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=16000,
    thinking={"type": "adaptive"},
    messages=[{"role": "user", "content": "Your prompt here"}]
)
```

## Quick Start (TypeScript)

```typescript
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic()

const message = await client.messages.create({
  model: 'claude-opus-4-6',
  max_tokens: 16000,
  thinking: { type: 'adaptive' },
  messages: [{ role: 'user', content: 'Your prompt here' }]
})
```

## Tool Use Pattern

```python
tools = [{
    "name": "get_weather",
    "description": "Get current weather for a location",
    "input_schema": {
        "type": "object",
        "properties": {
            "location": {"type": "string", "description": "City name"}
        },
        "required": ["location"]
    }
}]

message = client.messages.create(
    model="claude-opus-4-6",
    max_tokens=4096,
    tools=tools,
    messages=[{"role": "user", "content": "What's the weather in Jakarta?"}]
)
```

## Common Pitfalls

- Don't use `budget_tokens` on Opus 4.6 / Sonnet 4.6 — use adaptive thinking
- Don't lowball `max_tokens` — non-streaming: ~16000, streaming: ~64000
- Opus 4.6 supports up to 128K `max_tokens` (requires streaming)
- Use `output_config: {format: {...}}` not deprecated `output_format`
- Always parse tool inputs with `json.loads()` / `JSON.parse()` — never raw string matching
- Use SDK types (`Anthropic.MessageParam`, `Anthropic.Tool`) — don't redefine
- Don't truncate inputs silently — notify user and discuss options

