Build on the Anthropic Claude API: Messages API, tool use, streaming, extended thinking, prompt caching, batches, files and citations, with the official SDKs.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Anthropic Claude Api?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/karthikrshet-anthropic-claude-api)
---
name: anthropic-claude-api
description: "Build on the Anthropic Claude API: Messages API, tool use, streaming, extended thinking, prompt caching, batches, files and citations, with the official SDKs."
tags: [ai-agents]
---
# Anthropic Claude Api
## When to use
- Any feature calling Claude models directly
## Procedure
1. Use the official SDK (@anthropic-ai/sdk or anthropic)
2. Read the model ID from config, never hardcode in many places
3. Use tool use or JSON schema for structured output
4. Add cache_control breakpoints on stable prefixes
5. Use the Batches API for offline bulk work
6. Handle 429/529 with retries and backoff
7. Log usage fields for cost tracking
## Example
```ts
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic(); // reads ANTHROPIC_API_KEY
const msg = await client.messages.create({
model: process.env.CLAUDE_MODEL!, max_tokens: 1024,
system: [{ type: 'text', text: SYSTEM_PROMPT, cache_control: { type: 'ephemeral' } }],
messages: [{ role: 'user', content: question }],
});
```
## Checklist
- [ ] API key from env
- [ ] Max tokens set deliberately
- [ ] Usage logged
## Anti-patterns
- Concatenating untrusted content into the system prompt
- Ignoring stop_reason