claude-api

Implements Anthropic Claude API patterns for Python and TypeScript applications.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill claude-api-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-api
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/claude-api
Command: npx skills add https://github.com/ibytechaos/claude --skill claude-api-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires anthropic, @anthropic-ai/sdk.

What problem does it solve? Developers building applications on the Anthropic Claude API often struggle to recall correct SDK syntax, model IDs, and advanced features like streaming, tool use, prompt caching, and batch processing across Python and TypeScript. ## Core Features & Use Cases - SDK Patterns for Python and TypeScript: Ready-to-use code for basic messages, streaming, system prompts, and error handling with the anthropic and @anthropic-ai/sdk packages. - Advanced Capabilities: Covers tool use loops, vision inputs, extended thinking, prompt caching, the Batches API, and agentic loops with the Claude Agent SDK. - Cost Optimization Guidance: Compares prompt caching, batch processing, and model selection (Opus, Sonnet, Haiku) to reduce API spend. - Use Case: You are building a support chatbot in Python that must stream responses, call internal tools, and cache a large system prompt; this Skill provides the exact code patterns for each requirement. ## Quick Start Ask the assistant to write a Python script that streams a Claude Sonnet response with tool use and prompt caching enabled.

Frequently Asked Questions about claude-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stream responses from the Claude API in Python?

Use client.messages.stream() as a context manager and iterate over stream.text_stream to print tokens as they arrive. In TypeScript, iterate the stream with for await and handle content_block_delta events containing text_delta payloads.

How do I implement tool use with the Anthropic SDK?

Define tools with name, description, and input_schema, pass them to messages.create, then inspect response content blocks for tool_use types. Execute the tool locally and send results back in a tool_result content block to continue the conversation.

Which Claude model should I use for my application?

Use Sonnet 4 (claude-sonnet-4-0) for most development tasks, Opus 4.1 for complex reasoning, and Haiku 3.5 for high-volume cost-sensitive workloads. For production, prefer pinned snapshot IDs over aliases.

Does the Claude API support prompt caching to reduce costs?

Yes, add cache_control with type ephemeral to system prompt blocks to cache large contexts. Cached tokens can reduce costs by up to 90 percent, and usage is reported via cache_read_input_tokens and cache_creation_input_tokens.

How do I handle rate limit errors from the Anthropic API?

Catch RateLimitError from the anthropic package and back off before retrying, typically waiting around 60 seconds. Also handle APIConnectionError for network issues and generic APIError for other status codes.

When should I use the Batches API instead of real-time requests?

Use the Batches API for non-time-sensitive bulk processing, which offers a 50 percent cost reduction. Submit requests with custom_id values, poll the batch status until processing ends, then iterate over results.