anthropic-api
Use when integrating Claude via the Anthropic API — messages, tool use, vision, streaming, or building AI features. Also use when working with the Anthropic SDK, managing API keys, or optimizing Claude API usage.
| Model | Source |
|---|---|
| sonnet | pack: ai |
Full Reference
┏━ 🔧 anthropic-api ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when integrating Claude via the Anthropic … ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Anthropic API
Section titled “Anthropic API”Direct Claude API access via the @anthropic-ai/sdk package. Uses a Messages API with a structured messages array, content blocks, and optional streaming. All models share a 200K token context window (1M beta for Opus/Sonnet 4.6).
Quick Reference
Section titled “Quick Reference”| Fact | Value |
|---|---|
| Install | npm install @anthropic-ai/sdk |
| Base URL | https://api.anthropic.com/v1 |
| API version header | anthropic-version: 2023-06-01 |
| Env var | ANTHROPIC_API_KEY |
| Opus 4.6 pricing | $5/MTok input · $25/MTok output · 128K max output |
| Sonnet 4.6 pricing | $3/MTok input · $15/MTok output · 64K max output |
| Haiku 4.5 pricing | $1/MTok input · $5/MTok output · 64K max output |
| Prompt caching | Cache write 1.25x · Cache read 0.1x (90% savings) |
| Batch API | 50% discount · 24hr processing · 100K requests/batch |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Install the SDK and initialize the client | reference/setup.md |
| Send a message, configure parameters, or build multi-turn conversations | reference/messages.md |
| Stream responses with async iterator or SSE events | reference/streaming.md |
| Define tools and run the tool use loop | reference/tool-use.md |
| Send images or PDFs and understand format limits | reference/vision.md |
| Use prompt caching or the Batches API for cost savings | reference/prompt-caching.md |
| Enable extended thinking or Opus adaptive mode | reference/extended-thinking.md |
| Handle errors, retry with backoff, and understand rate limits | reference/error-handling.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.