jackspace/claudeskillz/claude-api
- community
Checking that the SKILL.md file is still in the repository.
This skill provides comprehensive knowledge for working with the Anthropic Messages API (Claude API). It should be used when integrating Claude models into applications, implementing streaming responses, enabling prompt caching for cost savings, adding tool use (function calling), processing images with vision capabilities, or using extended thinking mode. Use when building chatbots, AI assistants, content generation tools, or any application requiring Claude's language understanding. Covers both server-side implementations (Node.js, Cloudflare Workers, Next.js) and direct API access. Keywords: claude api, anthropic api, messages api, @anthropic-ai/sdk, claude streaming, prompt caching, tool use, vision, extended thinking, claude 3.5 sonnet, claude 3.7 sonnet, claude sonnet 4, function calling, SSE, rate limits, 429 errors
Install
npx vskill@latest install jackspace/claudeskillz/claude-apiSKILL.md
Claude API (Anthropic Messages API)
Status: Production Ready Last Updated: 2025-10-25 Dependencies: None (standalone API skill) Latest Versions: @anthropic-ai/sdk@0.67.0
Quick Start (5 Minutes)
1. Get API Key
Why this matters:
- API key required for all requests
- Keep secure (never commit to git)
- Use environment variables
2. Install SDK (Node.js)
CRITICAL:
- Always use server-side (never expose API key in client code)
- Set
max_tokens(required parameter) - Model names are versioned (use latest stable)
3. Or Use Direct API (Cloudflare Workers)
The Complete Claude API Reference
Table of Contents
- Core API
- Streaming Responses
- Prompt Caching
- Tool Use (Function Calling)
- Vision (Image Understanding)
- Extended Thinking Mode
- Rate Limits
- Error Handling
- Platform Integrations
- Known Issues
Core API (Messages API)
Available Models (October 2025)
| Model | ID | Context | Best For | Cost (per MTok) | |
|---|---|---|---|---|---|
| Claude Sonnet 4.5 | claude-sonnet-4-5-20250929 | 200k tokens | Balanced performance | $3/$15 (in/out) | |
| Claude 3.7 Sonnet | claude-3-7-sonnet-20250228 | 2M tokens | Extended thinking | $3/$15 | |
| Claude Opus 4 | claude-opus-4-20250514 | 200k tokens | Highest capability | $15/$75 | |
| Claude 3.5 Haiku | claude-3-5-haiku-20241022 | 200k tokens | Fast, cost-effective | $1/$5 |
Basic Message Creation
Multi-Turn Conversations
System Prompts
CRITICAL:
- System prompt MUST come before messages array
- System prompt sets behavior for entire conversation
- Can be 1-10k tokens (affects context window)
Streaming Responses (SSE)
Using SDK Stream Helper
Streaming with Manual Iteration
Streaming Event Types
| Event | When | Use Case | |
|---|---|---|---|
message_start | Message begins | Initialize UI | |
content_block_start | New content block | Track blocks | |
content_block_delta | Text chunk received | Display text | |
content_block_stop | Block complete | Format block | |
message_delta | Metadata update | Update stop reason | |
message_stop | Message complete | Finalize UI |
Cloudflare Workers Streaming
CRITICAL:
- Errors can occur AFTER initial 200 response
- Always implement error event handlers
- Use
stream.abort()to cancel - Set proper Content-Type headers
Prompt Caching (⭐ 90% Cost Savings)
Overview
Prompt caching allows you to cache frequently used context (system prompts, documents, codebases) to:
- Reduce costs by 90% (cache reads = 10% of input token price)
- Reduce latency by 85% (time to first token)
- Cache lifetime: 5 minutes (default) or 1 hour (configurable)
Minimum Requirements
- Claude 3.5 Sonnet: 1,024 tokens minimum
- Claude 3.5 Haiku: 2,048 tokens minimum
Basic Prompt Caching
Caching in Messages
Multi-Turn Caching (Chatbot Pattern)
Cost Comparison
CRITICAL:
cache_controlMUST be on LAST block of cacheable content- Cache shared across requests with IDENTICAL content
- Monitor
cache_creation_input_tokensvscache_read_input_tokens - 5-minute TTL refreshes on each use
Tool Use (Function Calling)
Basic Tool Definition
Tool Execution Loop
Beta Tool Runner (SDK Helper)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 92 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/claude-api/SKILL.md
Popularity
- Repository stars
- 12
- Repository forks
- 4
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 2 Apr 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jackspace/claudeskillz/claude-api)